/* ChapterPin - ported from Framer code component ChapterPin.tsx
   A pinned section, taller than the viewport, with a sticky inner pane. The
   section's own scroll progress picks the live beat and drives the photo zoom:

     p   = clamp(-sectionTop / (sectionHeight - vh), 0, 1)
     idx = clamp(floor(p * beats * 0.999), 0, beats - 1)

   The live beat's photo and headline show; the others cross-fade out. The
   per-frame scale is written straight to the <img> by js/framer/chapterpin.js
   (ZOOM_FROM 1.04 -> ZOOM_TO 1.14), so nothing re-renders while the page moves.

   Below 810px the pin stays on in the TSX code's compact layout (a 16:10 frame
   inside the page gutter, the line and ticks underneath, 300vh of travel, zoom
   1.02 -> 1.08) - the approved 390 render shows it, so it wins over the TSX
   header comment. Under prefers-reduced-motion the pin is off at every width and
   beat 0 renders as a static hero; the JS detaches its scroll listener to match. */
.fr-chapterpin {
  --fr-chapterpin-line: #F4F1EA;
  --fr-chapterpin-tick: rgba(244, 241, 234, 0.16);
  --fr-chapterpin-tick-live: #A98A6E;
  --fr-chapterpin-gutter: 94px;
  --fr-chapterpin-bg: #080808;
  --fr-chapterpin-ease: cubic-bezier(.16, 1, .3, 1);
  position: relative;
  width: 100%;
  /* One viewport for the pinned pane plus 420vh of travel, so a four-beat
     sequence holds each beat for a little over a screen. The index maths divides
     the travel by the number of beats actually filled in. */
  height: 520vh;
  background: var(--fr-chapterpin-bg);
}
.fr-chapterpin__pane {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  align-items: end;
  background: var(--fr-chapterpin-bg);
}
/* The frame holds the photos, scrim and sheen. At desktop it IS the pane (full
   bleed); on the compact phone pin it becomes the 16:10 box. */
.fr-chapterpin__frame { position: absolute; inset: 0; }
.fr-chapterpin__figure {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: opacity 900ms var(--fr-chapterpin-ease);
}
.fr-chapterpin__figure.is-live { opacity: 1; }
.fr-chapterpin__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.04); /* ZOOM_FROM; the scroll pass owns this once live */
  transform-origin: 50% 50%;
  will-change: transform;
  filter: saturate(0.92) contrast(1.03);
}
.fr-chapterpin__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(15, 15, 15, 0.93), rgba(15, 15, 15, 0.3) 55%, rgba(15, 15, 15, 0.45));
}
.fr-chapterpin__sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(107deg, transparent 0 38%, rgba(244, 241, 234, 0.05) 38% 45%, rgba(168, 205, 232, 0.035) 45% 52%, transparent 52% 100%);
}
.fr-chapterpin__copy {
  position: relative;
  padding: 0 var(--fr-chapterpin-gutter) clamp(5rem, 12vh, 8rem);
  width: min(100%, 82rem);
  margin-inline: auto;
  z-index: 2;
}
/* The lines share one grid cell so they cross-fade in place. */
.fr-chapterpin__lines {
  position: relative;
  display: grid;
  margin: 0;
  max-width: 14ch;
  font-family: var(--jifu-font-display, "Heuvel Grotesk", Montserrat, sans-serif);
  font-weight: 700;
  font-size: clamp(2.6rem, 8.4vw, 8rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--fr-chapterpin-line);
}
/* Resting (not yet reached): waiting below at +40px. Lines before the live one
   have left upward at -24px; the copy moves with the direction of the scroll. */
.fr-chapterpin__line {
  grid-area: 1 / 1;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 680ms var(--fr-chapterpin-ease), transform 680ms var(--fr-chapterpin-ease);
}
.fr-chapterpin__line.is-next { transform: translateY(40px); }
.fr-chapterpin__line.is-past { transform: translateY(-24px); }
.fr-chapterpin__line.is-live { opacity: 1; transform: none; }
.fr-chapterpin__ticks {
  position: absolute;
  right: var(--fr-chapterpin-gutter);
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.fr-chapterpin__tick {
  width: 22px;
  height: 2px;
  background: var(--fr-chapterpin-tick);
  transition: background 520ms var(--fr-chapterpin-ease), width 520ms var(--fr-chapterpin-ease);
}
.fr-chapterpin__tick.is-live {
  width: 34px;
  background: var(--fr-chapterpin-tick-live);
}
/* Compact pin (phone, motion allowed): the TSX compact branch - 300vh section,
   sticky 100vh pane laid out as a centred grid (gap 22, padding 72/14/48), a
   16:10 frame with a bottom scrim, the line (clamp(1.5rem, 6.6vw, 2.1rem),
   16ch) and a row of ticks underneath. */
@media (max-width: 809px) and (prefers-reduced-motion: no-preference) {
  .fr-chapterpin { height: 300vh; }
  .fr-chapterpin__pane {
    display: grid;
    align-items: initial;
    align-content: center;
    gap: 22px;
    padding: 72px 14px 48px;
    box-sizing: border-box;
  }
  .fr-chapterpin__frame { position: relative; inset: auto; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; background: #111; }
  .fr-chapterpin__scrim { background: linear-gradient(to top, rgba(15, 15, 15, 0.55), rgba(15, 15, 15, 0) 45%); }
  .fr-chapterpin__sheen { display: none; }
  .fr-chapterpin__copy { width: 100%; padding: 0 10px; margin: 0; }
  .fr-chapterpin__lines { font-size: clamp(1.5rem, 6.6vw, 2.1rem); max-width: 16ch; }
  .fr-chapterpin__ticks { position: static; transform: none; flex-direction: row; padding: 0 10px; }
}
/* Static hero: the pin is off, the pane holds one screen, beat 0 rests at
   scale 1.06. Applies under reduced motion, at every width. */
@media (prefers-reduced-motion: reduce) {
  .fr-chapterpin { height: 100vh; }
  .fr-chapterpin__pane { position: relative; }
  .fr-chapterpin__img { transform: scale(1.06) !important; will-change: auto; }
}
/* Phone static hero (reduced motion): copy sits bottom-left with a lighter
   scrim; ticks run in a row underneath it. */
@media (max-width: 809px) and (prefers-reduced-motion: reduce) {
  .fr-chapterpin__copy { padding: 0 20px clamp(4rem, 12vh, 6rem); }
  .fr-chapterpin__scrim {
    background: linear-gradient(to top, rgba(15, 15, 15, 0.55), rgba(15, 15, 15, 0) 45%);
  }
  .fr-chapterpin__ticks {
    right: auto;
    left: 20px;
    top: auto;
    bottom: clamp(2rem, 7vh, 3rem);
    transform: none;
    flex-direction: row;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fr-chapterpin__figure,
  .fr-chapterpin__line,
  .fr-chapterpin__tick,
  .fr-chapterpin__img { transition: none; }
}
