/**
 * Homepage hero (split banner). Markup: template-parts/home-banner.php
 * Script: assets/js/home-hero.js. All selectors are prefixed .cas- to avoid theme clashes.
 *
 * Accessibility notes
 *  - Text colours checked against WCAG 2.1 AA; idle carousel dots darkened to 3.3:1 (design was 1.4:1).
 *  - Focus rings restored (the theme has a global `a:focus { outline: none }`).
 *  - Animations (live-dot pulse, dot growth) stop for visitors who prefer reduced motion.
 */

.cas-hero {
  --cas-navy: #1c1c45;
  --cas-amber: #ffa521;
  --cas-amber-hover: #f29a12;
  --cas-grey: #6e6c90;
  --cas-line: #ecedf3;
  position: relative;
  background: #f5f7fa;
  color: var(--cas-navy);
  padding: 48px 0 56px;
  overflow: hidden;
  scroll-margin-top: 100px;
}
@media (min-width: 992px) {
  .cas-hero { padding: 64px 0 72px; }
}
.cas-hero p { margin: 0; }

.cas-hero .cas-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cas-hero a:focus-visible,
.cas-hero button:focus-visible,
.cas-hero input:focus-visible {
  outline: 3px solid var(--cas-navy);
  outline-offset: 3px;
}

/* Width, side padding and centring come from the theme's .container class. */
.cas-hero__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 48px 56px;
}
.cas-hero__copy { flex: 1 1 480px; max-width: 600px; }
.cas-hero__media { flex: 1 1 480px; position: relative; min-width: 0; }

/* Badges */
/* Stacked: the Google reviews badge always sits under the Live badge. */
.cas-badges { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.cas-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--cas-line);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--cas-navy);
  text-decoration: none;
}
a.cas-badge:hover { border-color: var(--cas-navy); color: var(--cas-navy); }
.cas-badge__live { font-weight: 600; color: #16824a; }     /* 4.85:1 on white */
.cas-badge__stars { color: #f6b30a; letter-spacing: 1px; } /* decorative; rating also given as text */
.cas-badge__muted { color: var(--cas-grey); }
.cas-badge--link strong { font-weight: 600; }

.cas-live-dot { position: relative; flex: none; display: inline-block; width: 8px; height: 8px; }
.cas-live-dot::before,
.cas-live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22a55b;
}
.cas-live-dot::before { animation: casLivePulse 1.6s ease-out infinite; }
@keyframes casLivePulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(2.6); opacity: 0; }
}
/* An infinite animation keeps the page doing work every frame even when the dot is far off screen;
   home-hero.js adds .is-offscreen while the hero is out of view. */
.cas-hero.is-offscreen .cas-live-dot::before { animation-play-state: paused; }

/* Headline */
.cas-hero .cas-hero__title {
  margin: 24px 0 0;
  font-size: var(--cas-fs-h1, clamp(2rem, 1rem + 3vw, 3.75rem));   /* scale: see the end of home-sections.css */
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--cas-navy);
  text-align: left;
}
.cas-hero__lede {
  margin-top: 20px !important;
  max-width: 520px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--cas-grey);
  text-wrap: pretty;
}

/* Search */
.cas-search {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--cas-navy);   /* visible before anyone clicks; the focus state below adds a ring instead of the border */
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(28, 28, 69, 0.1);
}
.cas-search__field {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0 12px;
  color: var(--cas-grey);
}
.cas-search__field svg { flex: none; }
.cas-search input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: 16px;               /* 16px prevents iOS zoom-on-focus */
  color: var(--cas-navy);
}
.cas-search input::placeholder { color: var(--cas-grey); opacity: 1; }
.cas-search input:focus-visible { outline-offset: 6px; border-radius: 4px; }

.cas-btn-primary {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 4px;
  background: var(--cas-amber);
  color: var(--cas-navy);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s;
}
.cas-btn-primary:hover { background: var(--cas-amber-hover); }
.cas-btn-primary__check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cas-navy);
}
@media (max-width: 575px) {
  .cas-btn-primary { flex: 1 1 100%; }
}

.cas-hero__links {
  margin-top: 18px !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  font-size: 14.5px;
}
.cas-hero__links a {
  font-weight: 600;
  color: var(--cas-navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cas-hero__links a:hover { text-decoration-thickness: 2px; color: var(--cas-navy); }
.cas-hero__links span { color: var(--cas-grey); }

/* Photo */
.cas-photo {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(28, 28, 69, 0.16);
}
.cas-photo img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
/* Rotator: the first slide sits in the flow and sets the height, the others are stacked over it and fade in. */
.cas-photo__slides { position: relative; }
.cas-photo__slide { opacity: 0; transition: opacity 0.6s ease; }
.cas-photo__slide + .cas-photo__slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.cas-photo__slide.is-active { opacity: 1; }
.cas-photo__slide + .cas-photo__slide img { height: 100%; }
.cas-photo__pause {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 28, 69, 0.82);
  color: #fff;
  cursor: pointer;
}
.cas-photo__pause:hover { background: var(--cas-navy); }
.cas-photo__pause:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--cas-navy); }
.cas-photo__pause .cas-icon-play { display: none; }
.cas-photo__pause[aria-pressed="true"] .cas-icon-pause { display: none; }
.cas-photo__pause[aria-pressed="true"] .cas-icon-play { display: block; }
.cas-photo__pause[hidden] { display: none; }
.cas-photo__tag {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 4px;
  background: rgba(28, 28, 69, 0.82);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

/* Review card */
.cas-review-wrap {
  position: relative;
  display: flex;
  max-width: calc(100% - 24px);
  margin: -36px 0 0 24px;
}
.cas-review-card {
  width: 340px;
  max-width: 100%;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--cas-line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(28, 28, 69, 0.14);
}
.cas-review { margin: 0; }
.cas-review[hidden] { display: none; }
.cas-review__head { display: flex; align-items: center; gap: 12px; }
.cas-review__head img { flex: none; width: 38px; height: 38px; border-radius: 50%; }
.cas-review__who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cas-review__name { font-size: 14.5px; font-weight: 600; }
.cas-review__time { font-size: 12.5px; color: var(--cas-grey); }
.cas-review__stars { color: #f6b30a; font-size: 14px; letter-spacing: 1px; }
.cas-review__text { margin: 12px 0 0; padding: 0; border: 0; min-height: 66px; font-size: 14.5px; line-height: 1.5; }
.cas-review__text p { margin: 0; }

.cas-review__foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cas-review__controls { display: flex; align-items: center; gap: 4px; }
.cas-review__controls[hidden] { display: none; }
.cas-review__all {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cas-navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cas-review__all:hover { color: var(--cas-navy); text-decoration-thickness: 2px; }

.cas-review__pause {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #c4c6d8;
  border-radius: 50%;
  background: #fff;
  color: var(--cas-navy);
  cursor: pointer;
}
.cas-review__pause:hover { border-color: var(--cas-navy); }
.cas-review__pause .cas-icon-play { display: none; }
.cas-review__pause[aria-pressed="true"] .cas-icon-pause { display: none; }
.cas-review__pause[aria-pressed="true"] .cas-icon-play { display: block; }
.cas-review__pause[hidden] { display: none; }

.cas-review__dots { display: flex; }
/* 24x24 hit area (WCAG 2.2 target size) around a small visible dot. */
.cas-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.cas-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: #8a8da6;           /* 3.3:1 on white */
  transition: width 0.25s, background-color 0.25s;
}
.cas-dot[aria-current="true"]::before { width: 20px; background: var(--cas-navy); }

@media (max-width: 575px) {
  .cas-review-wrap { margin-left: 12px; max-width: calc(100% - 12px); }
  .cas-review-card { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cas-live-dot::before { animation: none; opacity: 0; }
  .cas-photo__slide { transition: none; }
  .cas-btn-primary,
  .cas-dot::before { transition: none; }
}
@media (forced-colors: active) {
  .cas-dot[aria-current="true"]::before { background: Highlight; }
}

/* Desktop: slightly smaller field text and button padding so the placeholder isn't clipped inside the theme container. */
@media (min-width: 768px) {
  .cas-search input { font-size: 15px; }
  .cas-btn-primary { padding: 0 20px; }
}

/* Desktop split: 60% copy / 40% media. Below 992px the columns stack (flex-wrap above). */
@media (min-width: 992px) {
  .cas-hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 56px;
  }
  .cas-hero__copy,
  .cas-hero__media { flex: none; max-width: none; }
}

/* The theme has a legacy `#home-banner h1 { max-width: 670px; margin: auto }` (ID specificity) that centred
   the headline and removed its top margin. Override it with the same specificity. */
#home-banner .cas-hero__title {
  max-width: none;
  margin: 24px 0 0;
}

/* ───────────────────────── UX fixes from the full banner test ───────────────────────── */

/* 1. Anchor links must not land under the fixed header (~88px). */
#reviews,
#sample-reports { scroll-margin-top: 88px; }

/* 2. Touch targets: comfortable 44px for standalone links; larger carousel controls. */
.cas-hero__links a { display: inline-flex; align-items: center; min-height: 44px; }
.cas-badge--link { min-height: 44px; flex-wrap: wrap; row-gap: 2px; }
.cas-badge--link strong,
.cas-badge--link .cas-badge__muted { white-space: nowrap; }
.cas-review__all { display: inline-flex; align-items: center; min-height: 44px; }
.cas-review__pause { width: 36px; height: 36px; }
.cas-dot { width: 28px; height: 36px; }
.cas-review__foot { margin-top: 4px; }

/* 3. Search field: wraps the button under it before the placeholder can clip. */
.cas-search__field { flex: 1 1 290px; }   /* 290 = placeholder + icon + padding; the button wraps below before it can clip */
@media (max-width: 359px) {
  .cas-search input::placeholder { font-size: 14.5px; }
}

/* 4. Small phones: tighter vertical rhythm so the Verify button is on the first screen. */
@media (max-width: 575px) {
  .cas-hero { padding: 28px 0 40px; }
  .cas-badges { gap: 8px; }
  #home-banner .cas-hero__title { margin-top: 18px; }
  .cas-hero__lede { margin-top: 14px !important; font-size: 16px; line-height: 1.5; }
  .cas-search { margin-top: 22px; }
  .cas-hero__links { margin-top: 6px !important; }
  .cas-hero__inner { gap: 28px; }
}

/* 5. Desktop: top-align the photo so a late font swap in the text column can't nudge it (layout shift). */
@media (min-width: 992px) {
  .cas-hero__inner { align-items: start; }
}

/* 6. Tablet: don't let the single-column photo become enormous. */
@media (min-width: 576px) and (max-width: 991px) {
  .cas-hero__media { max-width: 600px; }
}

/* Search bar focus: no heavy outline around the input. The bar already has its navy border, so focus adds a ring
   outside it (white gap, then navy), which stays clearly visible (WCAG 2.4.7). Browsers without :has() keep the
   default outline. */
@supports selector(:has(*)) {
  .cas-search input:focus-visible { outline: 0; }
  .cas-search:has(input:focus-visible) { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--cas-navy), 0 14px 40px rgba(28, 28, 69, 0.1); }
}
