/* ============================================================
   AEIVA — Explore-page carousel
   Each chapter is a full-viewport slide on a horizontal
   scroll-snap track. Native swipe on touch (83% of traffic);
   arrows, arrow keys and a dot rail on desktop.
   Slides scroll vertically INSIDE themselves — chapter heights
   vary hugely, so a shared track height would leave dead space
   under the short ones.
   ============================================================ */

.carousel { position: relative; }

.carousel-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  /* NO scroll-behavior:smooth here — it swallows programmatic scrollLeft/scrollTo
     on this element (verified: with it set, track.scrollLeft = 375 reads back 0
     and never animates). js/carousel.js passes behavior:'smooth' per call instead. */
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }

.carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
  scroll-snap-align: start;
  height: 100svh;
  overflow-y: auto;
  /* NOT `contain`: that blocked chaining out of the slide, which left the ribbon
     CTA and the footer below the carousel unreachable by scroll. The snap track
     is protected separately by overscroll-behavior-x on .carousel-track. */
  overscroll-behavior-y: auto;
  /* Reveals change content height after load, and scroll anchoring reacts by
     nudging this container's scrollTop (measured: 65px), which slid the chapter
     row up under the fixed nav. Opt out — the slide must start at its top. */
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-gutter: stable;      /* keeps width identical whether a slide scrolls or not */
  /* clear the fixed nav, and give the chapter room to breathe */
  padding-top: clamp(4.5rem, 9vh, 6.5rem);
  /* Reserve the sticky .carousel-nav's height (~71-73px). Without this the bar
     painted over the last ~70px of every chapter: links there hit-tested to the
     Previous button and the film's native video controls were unreachable. */
  padding-bottom: calc(clamp(2rem, 5vh, 4rem) + 5.5rem + env(safe-area-inset-bottom));
}
.carousel-slide::-webkit-scrollbar { width: 6px; }
.carousel-slide::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* Sections inside a slide must not re-apply their own full-page padding */
.carousel-slide > .section { padding-top: 0; padding-bottom: 0; min-height: 0; }

/* ---------- Controls ---------- */
.carousel-nav {
  position: sticky; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 1.1rem;
  padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--obsidian) 35%, rgba(8, 8, 10, 0));
}
.carousel-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: rgba(255, 255, 255, 0.04); color: var(--cream);
  cursor: pointer; transition: border-color var(--dur), background var(--dur), opacity var(--dur);
}
.carousel-btn:hover:not(:disabled) { border-color: var(--gold); background: rgba(207, 181, 59, 0.12); }
.carousel-btn:disabled { opacity: 0.28; cursor: default; }
.carousel-btn svg { width: 16px; height: 16px; }
.carousel-btn.prev svg { transform: rotate(180deg); }

.carousel-dots { display: flex; align-items: center; gap: 0; }  /* padding tiles the targets — no dead gaps */
.carousel-dot {
  /* 7px dot, ~25px tappable: padding grows the hit area while background-clip
     keeps the visible dot small. */
  width: 7px; height: 7px; flex: none;
  padding: 18.5px 8px; box-sizing: content-box; background-clip: content-box;  /* 7 + 2x18.5 = 44px tall target */
  border: 0; border-radius: 50%;
  background-color: var(--line-strong); cursor: pointer;
  transition: background-color var(--dur), transform var(--dur);
}
.carousel-dot:hover { background-color: var(--gold-200); }
.carousel-dot[aria-current="true"] { background-color: var(--gold); transform: scale(1.5); }

.carousel-count {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--mute-2); min-width: 4.5em; text-align: center;
}

/* ---------- Reveal inside a horizontal track ----------
   ScrollTrigger is keyed to vertical scroll and never fires in here,
   so carousel.js sets .is-revealed via an IntersectionObserver rooted
   on the track. Without this rule the content stays at opacity 0. */
html.anim-ready .carousel [data-fade].is-revealed {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

/* ---------- No-JS / reduced motion: plain vertical stack ---------- */
@media (prefers-reduced-motion: reduce) {
  .carousel-track { scroll-snap-type: none; scroll-behavior: auto; flex-wrap: wrap; overflow-x: hidden; }
  .carousel-slide { height: auto; overflow-y: visible; }
  /* The stack reads as one long page, so the prev/next/dot controls no longer
     control anything — retire them with the mode rather than leave dead buttons. */
  .carousel-nav { display: none; }
  .carousel-slide { padding-bottom: clamp(2rem, 5vh, 4rem); }
}
html:not(.anim-ready) .carousel-slide { height: auto; overflow-y: visible; }

@media (max-width: 700px) {
  .carousel-slide {
    padding-top: clamp(4rem, 8vh, 5rem);
    padding-bottom: calc(clamp(2rem, 5vh, 4rem) + 5rem + env(safe-area-inset-bottom));
  }
  .carousel-nav { gap: 0.55rem; }
  .carousel-btn { width: 44px; height: 44px; }   /* 44px minimum tap target */
}


/* ---------- Nav backdrop on carousel pages ----------
   sections.css only gives .nav its scrim at [data-scrolled="true"], and that is
   written from window.scrollY (js/main.js). On a carousel page the window never
   scrolls — the slides scroll internally — so the nav stayed fully transparent
   and chapter copy scrolled straight through the logo, links and CTA. The
   carousel layer owns this deviation, so it sets the scrim unconditionally. */
body:has(.carousel) .nav {
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  box-shadow: 0 1px 0 var(--line);
}
