/* ============================================================
   home.css — Homepage page-specific styles
   Tokens inherited from base.css (--dark, --teal-deep, --bg)
   Fonts inherited (Cormorant Garamond, DM Sans)
   ============================================================ */

/* DISCOVERY CAROUSEL --------------------------------------- */

.discovery {
  background: var(--bg, #F4F1EA);
  padding: clamp(48px, 8vw, 96px) 0;
  color: var(--dark, #0A1F1F);
}

.discovery__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
}

.discovery__heading {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1.1;
  margin: 0 0 12px;
  color: var(--dark, #0A1F1F);
}

.discovery__sub {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(16px, 1.4vw, 18px);
  line-height: 1.5;
  color: var(--dark, #0A1F1F);
  opacity: 0.7;
  max-width: 580px;
  margin: 0 0 clamp(32px, 5vw, 56px);
}

/* WRAP — positioning context for the flanking arrows.
   Arrows sit at the wrap's left/right edges, vertically centred on the tile row. */
.discovery__track-wrap {
  position: relative;
}

.discovery__track {
  display: flex;
  flex-direction: row;
  gap: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  /* Disable browser scroll anchoring: when an .is-expanded panel returns to
     flow on close, anchoring would otherwise shift scrollLeft by +step to
     keep the previously-visible (next) tile stable, landing on the wrong
     panel. See closeAllPanels() in discovery.js. */
  overflow-anchor: none;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 8px 0 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.discovery__track::-webkit-scrollbar {
  display: none;
}

.discovery__panel {
  scroll-snap-align: start;
  min-width: 0;
  flex: 0 0 clamp(280px, 32vw, 460px);
  height: calc(clamp(280px, 32vw, 460px) * 5 / 4);
  transition: flex-basis 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.discovery__panel.is-expanded {
  flex-basis: calc(2 * clamp(280px, 32vw, 460px) + 24px);
}

.discovery__media {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: #1a2e2e;
  width: 100%;
  height: 100%;
}

.discovery__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Expanded panels widen the media box to landscape (desktop) or fill a tall
   full-screen overlay (mobile); anchor the image to the top so faces stay in
   frame rather than being cropped at the crown. */
.discovery__panel.is-expanded .discovery__media img {
  object-position: center 25%;
}

.discovery__chip {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(10, 31, 31, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  z-index: 3;
}

.discovery__chip-icon {
  font-size: 14px;
  line-height: 1;
  color: var(--teal-deep, #00B8A0);
}

/* TOGGLE BUTTON (replaces the spotlight in collapsed view) */
.discovery__toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.discovery__toggle:hover,
.discovery__toggle:focus-visible {
  background: #fff;
  transform: scale(1.05);
}

.discovery__toggle-icon {
  position: relative;
  width: 16px;
  height: 16px;
}

.discovery__toggle-icon::before,
.discovery__toggle-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--dark, #0A1F1F);
  transition: transform 0.25s ease;
}

.discovery__toggle-icon::before {
  width: 16px;
  height: 2px;
  transform: translate(-50%, -50%);
}

.discovery__toggle-icon::after {
  width: 2px;
  height: 16px;
  transform: translate(-50%, -50%);
}

.discovery__panel.is-expanded .discovery__toggle-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.discovery__panel.is-expanded .discovery__toggle-icon::after {
  transform: translate(-50%, -50%) rotate(45deg);
}

/* COPY BLOCK */
.discovery__copy {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: clamp(20px, 3vw, 36px);
  width: 100%;
  max-width: 60%;
  color: #fff;
  z-index: 2;
  background: linear-gradient(
    to top,
    rgba(10, 31, 31, 0.92) 0%,
    rgba(10, 31, 31, 0.55) 60%,
    rgba(10, 31, 31, 0) 100%
  );
}

.discovery__headline {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.15;
  margin: 0;
  color: #fff;
}

.discovery__headline em {
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
  color: inherit;
}

/* REVEAL — body copy + CTA, hidden by default, shown when expanded.
   Chained: geometry settles first (~320ms on .discovery__media), then this
   block fades/grows in after an 80ms buffer so the tile doesn't briefly hit
   its full intrinsic height while the aspect-ratio is still mid-transition. */
.discovery__reveal {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 200ms ease, opacity 160ms ease, margin-top 200ms ease;
  margin-top: 0;
}

.discovery__panel.is-expanded .discovery__reveal {
  max-height: 400px;
  opacity: 1;
  margin-top: 14px;
  transition: max-height 200ms ease 400ms,
              opacity 200ms ease 400ms,
              margin-top 200ms ease 400ms;
}

.discovery__body {
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(14px, 1.1vw, 15px);
  line-height: 1.55;
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.88);
}

.discovery__cta {
  display: inline-block;
  padding: 12px 26px;
  background: #fff;
  color: var(--dark, #0A1F1F);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: normal;
  line-height: 1.3;
}

.discovery__cta:hover,
.discovery__cta:focus-visible {
  background: var(--teal-deep, #00B8A0);
  color: #fff;
}

/* SPOTLIGHT — hidden by default, shown only when panel is expanded on desktop */
.discovery__spotlight {
  position: absolute;
  top: 20px;
  right: 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: clamp(180px, 22%, 240px);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.discovery__panel.is-expanded .discovery__spotlight {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 200ms ease 400ms;
}

.discovery__spotlight-card,
.discovery__spotlight-widget {
  background: rgba(10, 31, 31, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
}

.discovery__spotlight-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.discovery__spotlight-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-deep, #00B8A0), #006b5e);
  flex-shrink: 0;
}

.discovery__spotlight-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.discovery__spotlight-label {
  font-size: 11px;
  opacity: 0.65;
  line-height: 1.2;
}

.discovery__spotlight-disclosure {
  font-size: 10px;
  font-style: italic;
  opacity: 0.55;
  line-height: 1.2;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.discovery__spotlight-quote {
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-style: italic;
}

.discovery__widget-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  margin-bottom: 4px;
}

.discovery__widget-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--teal-deep, #00B8A0);
}

.discovery__widget-meta {
  font-size: 11px;
  opacity: 0.7;
  line-height: 1.3;
}

/* CAROUSEL NAVIGATION ARROWS — flank the track, vertically centred on the tile row */
.discovery__nav {
  pointer-events: none;
}

.discovery__nav-btn {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--teal-deep, #00B8A0);
  background: rgba(255, 255, 255, 0.92);
  color: var(--teal-deep, #00B8A0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 180ms ease;
  z-index: 5;
}

.discovery__nav-btn--prev { left: -22px; }
.discovery__nav-btn--next { right: -22px; }

.discovery__nav-btn:hover,
.discovery__nav-btn:focus-visible {
  background: var(--teal-deep, #00B8A0);
  border-color: var(--teal-deep, #00B8A0);
  color: #fff;
}

/* INACTIVE (at first/last tile) — clickable still, just visually dimmed.
   Per brief: do NOT use pointer-events:none here. */
.discovery__nav-btn.is-inactive {
  opacity: 0.4;
}

.discovery__nav-btn.is-inactive:hover,
.discovery__nav-btn.is-inactive:focus-visible {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--teal-deep, #00B8A0);
  color: var(--teal-deep, #00B8A0);
}

/* MOBILE — full-screen modal overlay when expanded */
@media (max-width: 720px) {
  .discovery__track {
    gap: 16px;
    padding-right: 16px;
  }

  .discovery__panel {
    flex-basis: 86vw;
    height: calc(86vw * 4 / 3);
    transition: none;
  }

  /* Mobile expanded = fixed full-viewport overlay */
  .discovery__panel.is-expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
  }

  .discovery__panel.is-expanded .discovery__media {
    border-radius: 0;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  /* Full-bleed gradient scrim covering the seam zone between copy block
     and testimonial card. Mobile expanded view only. */
  .discovery__panel.is-expanded .discovery__media::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(
      to bottom,
      rgba(10, 31, 31, 0) 0%,
      rgba(10, 31, 31, 0.20) 20%,
      rgba(10, 31, 31, 0.55) 35%,
      rgba(10, 31, 31, 0.85) 50%,
      rgba(10, 31, 31, 0.95) 100%
    );
  }

  .discovery__panel.is-expanded .discovery__media img {
    position: absolute;
    inset: 0;
    z-index: 0;
  }

  .discovery__panel.is-expanded .discovery__copy {
    max-width: 100%;
    padding: 24px 20px 12px;
    position: relative;
    bottom: auto;
    top: auto;
    z-index: 2;
    height: auto;
    max-height: 75vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .discovery__panel.is-expanded .discovery__headline {
    font-size: 28px;
    margin-bottom: 0;
  }

  .discovery__panel.is-expanded .discovery__reveal {
    max-height: none;
    margin-top: 0;
  }

  .discovery__panel.is-expanded .discovery__body {
    font-size: 15px;
    line-height: 1.55;
    margin: 0;
  }

  .discovery__panel.is-expanded .discovery__spotlight {
    position: relative;
    z-index: 2;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 0 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 1;
    pointer-events: auto;
    box-sizing: border-box;
  }

  .discovery__panel.is-expanded .discovery__spotlight-card {
    order: 1;
    background: rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 2px solid var(--teal-deep, #00B8A0);
    padding: 12px 14px;
    width: 100%;
    box-sizing: border-box;
  }

  .discovery__panel.is-expanded .discovery__spotlight-widget {
    display: none;
  }

  .discovery__panel.is-expanded .discovery__cta {
    align-self: flex-start;
    margin-top: 4px;
  }

  .discovery__panel.is-expanded .discovery__spotlight-disclosure {
    font-size: 9px;
  }

  .discovery__copy {
    max-width: 100%;
    padding: 18px 18px 20px;
  }

  .discovery__headline {
    font-size: 22px;
  }

  .discovery__chip {
    top: 14px;
    left: 14px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .discovery__toggle {
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
  }

  .discovery__nav-btn {
    width: 40px;
    height: 40px;
  }
}

/* Lock body scroll when mobile modal is open */
body.discovery-modal-open {
  overflow: hidden;
}

/* MOBILE SCROLL INDICATOR — dot bar replaces flanking arrows on ≤720px.
   Hidden on desktop; arrows take over there. Updates from JS as the user swipes. */
.discovery__dots {
  display: none;
}

@media (max-width: 720px) {
  .discovery__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
  }

  .discovery__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(10, 31, 31, 0.3);
    transition: background 180ms ease;
  }

  .discovery__dot.is-active {
    background: var(--teal-deep, #00B8A0);
  }

  /* Mobile: arrows appear inside the open panel, bottom-right, Oura pattern */
  .discovery__nav {
    display: none;  /* hidden by default on mobile */
  }

  body.discovery-modal-open .discovery__nav {
    display: flex;
    position: fixed;
    bottom: 150px;
    right: 20px;
    z-index: 10000;  /* one above the .is-expanded panel's 9999 */
    gap: 12px;
    pointer-events: none;  /* matches base rule */
  }

  body.discovery-modal-open .discovery__nav-btn {
    position: static;       /* override desktop's absolute positioning */
    transform: none;        /* override desktop's translateY */
    width: 44px;
    height: 44px;
    background: rgba(20, 20, 20, 0.72);  /* dark grey fill, matches Oura */
    border: none;
    color: #ffffff;         /* white arrow */
    pointer-events: auto;
  }

  body.discovery-modal-open .discovery__nav-btn:hover,
  body.discovery-modal-open .discovery__nav-btn:focus-visible {
    background: rgba(20, 20, 20, 0.88);
    color: #ffffff;
  }

  /* True disabled state on edge tiles — not just visual */
  body.discovery-modal-open .discovery__nav-btn.is-inactive {
    opacity: 0.35;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .discovery__media,
  .discovery__reveal,
  .discovery__panel.is-expanded .discovery__reveal,
  .discovery__spotlight,
  .discovery__panel.is-expanded .discovery__spotlight {
    transition: none !important;
  }
}

/* ============================================================
   HOW IT WORKS
   Section between discovery carousel and "What our customers tell us"
   Desktop: two-column intro + tabbed image swap
   Mobile (≤900px): stacked intro + horizontal scroll-snap carousel
   Tokens inherited from base.css (--dark, --teal-deep, --bg, etc.)
   ============================================================ */

.how-it-works {
  padding: 48px 24px 112px;
  background: #F4F1EA;
  color: var(--dark);
}

.how-it-works__inner {
  max-width: 1200px;
  margin: 0 auto;
}

/* ---------- Top row: headline + aside ---------- */
.how-it-works__top {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 64px;
  align-items: start;
  margin-bottom: 72px;
}

.how-it-works__intro {
  min-width: 0;
}

.how-it-works__eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dark);
  opacity: 0.75;
  margin: 0 0 32px;
}

.how-it-works__headline {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(40px, 5.2vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--dark);
}

.how-it-works__line {
  display: block;
}

.how-it-works__line--italic {
  font-style: italic;
  padding-left: 1.2em;
}

/* ---------- Aside (How It Works header + body) ---------- */
.how-it-works__aside {
  padding-top: 12px;
}

.how-it-works__aside-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(22px, 2vw, 26px);
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  color: var(--dark);
  margin: 0 0 18px;
}

.how-it-works__aside-body {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--dark);
  opacity: 0.82;
  margin: 0;
}

/* ---------- Tabs (desktop) ---------- */
.how-it-works__tabs-wrap {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(10, 31, 31, 0.15);
  margin-bottom: 48px;
  overflow-x: auto;
  scrollbar-width: none;
}

.how-it-works__tabs-wrap::-webkit-scrollbar {
  display: none;
}

.how-it-works__tab {
  flex: 1;
  min-width: 0;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 18px 12px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--dark);
  opacity: 0.55;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: opacity 0.25s ease, color 0.25s ease;
}

.how-it-works__tab:hover {
  opacity: 0.85;
}

.how-it-works__tab::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--dark);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.how-it-works__tab.is-active {
  opacity: 1;
  font-weight: 600;
}

.how-it-works__tab.is-active::after {
  transform: scaleX(1);
}

.how-it-works__tab:focus-visible {
  outline: 2px solid var(--teal-deep);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- Panel (image swap) ---------- */
.how-it-works__panel {
  position: relative;
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(10, 31, 31, 0.06);
}

.how-it-works__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.how-it-works__image.is-active {
  opacity: 1;
}

/* ---------- Mobile carousel (hidden on desktop) ---------- */
.how-it-works__carousel {
  display: none;
}

/* ============================================================
   Mobile (≤900px)
   ============================================================ */
@media (max-width: 900px) {
  .how-it-works {
    padding: 32px 0 88px;
  }

  .how-it-works__top {
    grid-template-columns: 1fr;
    gap: 40px;
    margin-bottom: 40px;
    padding: 0 24px;
  }

  .how-it-works__eyebrow {
    margin-bottom: 20px;
  }

  .how-it-works__headline {
    font-size: clamp(36px, 9vw, 56px);
  }

  .how-it-works__line--italic {
    padding-left: 0.6em;
  }

  .how-it-works__aside {
    padding-top: 0;
  }

  .how-it-works__tabs-wrap,
  .how-it-works__panel {
    display: none;
  }

  .how-it-works__carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 24px;
    padding: 0 24px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .how-it-works__carousel::-webkit-scrollbar {
    display: none;
  }

  .how-it-works__slide {
    flex: 0 0 82%;
    margin: 0;
    scroll-snap-align: start;
  }

  .how-it-works__slide img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 8px;
    background: rgba(10, 31, 31, 0.06);
    display: block;
  }

  .how-it-works__slide figcaption {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
    margin-top: 14px;
    letter-spacing: 0.01em;
  }
}

/* ============================================================
   Tablet adjustment (901–1080px)
   ============================================================ */
@media (min-width: 901px) and (max-width: 1080px) {
  .how-it-works__top {
    grid-template-columns: 1.4fr 1fr;
    gap: 48px;
  }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .how-it-works__image,
  .how-it-works__tab::after,
  .how-it-works__tab {
    transition: none;
  }
}
