/* Immersive scroll heroes (pages with `hero_clip`; built by tools/build.py,
   driven by site/js/scrollscrub.js). Tokens only (see tokens.css).

   Static by default: a poster image with the page heading over a veil. When
   the head script has set .motion (JS on, no reduced motion, no save-data),
   the hero becomes a tall wrapper with a sticky panel, and the canvas scrubs
   the clip's frames as you scroll. The size is decided before first paint, so
   nothing shifts when the script arrives.

   Frame sets: portrait or narrow viewports get the mobile (m) set, whose
   aspect varies per clip (1:1, 4:5 or 9:16). Its full width always stays
   visible: the frame is fitted to the width, and any gap above and below is
   filled with a blurred, darkened copy of the same frame (canvas and poster
   alike). The desktop (d) set covers the panel. */

/* Full bleed without 100vw (which counts a classic scrollbar and would add
   horizontal scroll): <main> has one gutter of side padding, so the hero (or
   an article holding one) pulls out by exactly that much. */
.scroll-hero { position: relative; max-width: none; }
main > .scroll-hero,
main > .article--hero {
  max-width: none;
  margin-left: calc(-1 * var(--gutter));
  margin-right: calc(-1 * var(--gutter));
}
main > .scroll-hero--full { margin-left: 0; margin-right: 0; }   /* home: <main> has no padding */
.article--hero > .article-layout { padding-left: var(--gutter); padding-right: var(--gutter); }
/* Short heroes (every page but home) slide up under the sticky header. */
.scroll-hero--short { margin-top: calc(-1 * (var(--header-h) + var(--space-4))); }

.scroll-hero-sticky {
  position: relative;
  display: grid;
  align-items: end;
  justify-items: center;
  height: 75vh;
  height: 75svh;
  min-height: 28rem;
  overflow: hidden;
}
.scroll-hero--full .scroll-hero-sticky {
  align-items: center;
  height: 100vh;
  height: 100svh;
  min-height: 34rem;
}

/* Tall wrapper + sticky panel (scroll travel). While it scrubs, the panel
   fills the viewport, so there is never blank background under it; the
   heading keeps its place (it sits where the foot of the 75svh panel would
   be). Short: 185svh in all, 85svh of travel, the last 15svh overlapping the
   content that follows, which rises into the solid foot of the veil.
   Full (home): 280svh. */
.motion .scroll-hero--short { height: 185vh; height: 185svh; margin-bottom: -15vh; margin-bottom: -15svh; }
.motion .scroll-hero--short .scroll-hero-sticky { height: 100vh; height: 100svh; }
.motion .scroll-hero--short .scroll-hero-content { padding-bottom: calc(clamp(3rem, 12vh, 7rem) + 25svh); }
.motion .scroll-hero--full { height: 280vh; height: 280svh; }
.motion .scroll-hero .scroll-hero-sticky { position: sticky; top: 0; }
.motion .scroll-hero ~ * { position: relative; z-index: 1; }

.scroll-hero-media,
.scroll-hero-media::before,
.scroll-hero-sticky::after,
.scroll-hero-media picture,
.scroll-hero-poster,
.scroll-hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.scroll-hero-media { overflow: hidden; background: var(--bg); }  /* masked at the foot, below */
.scroll-hero-poster {
  max-width: none;
  object-fit: cover;
  object-position: 50% var(--fy, 50%);
}
.scroll-hero-canvas { opacity: 0; }
.scroll-hero.has-frames .scroll-hero-canvas { opacity: 1; }
.motion .scroll-hero .scroll-hero-canvas,
.motion .scroll-hero .smoke-l { will-change: transform, opacity; }

/* Mobile set: keep the frame's whole width (see the note at the top). The
   ::before backdrop is the same poster file, so it costs no extra request. */
.scroll-hero-media::before { content: none; }
@media (orientation: portrait), (max-width: 47.99rem) {
  .scroll-hero-poster { object-fit: contain; object-position: 50% var(--fy-m, var(--fy, 50%)); }
  /* Home: the frame sits near the top, the headline and buttons below it. */
  .scroll-hero--full { --fy-m: 10%; }
  .scroll-hero--full .scroll-hero-sticky { align-items: end; }
  .scroll-hero--full .scroll-hero-content { padding-bottom: clamp(4.5rem, 10vh, 6rem); }
  .scroll-hero-media::before {
    content: "";
    inset: -10%;
    width: auto;
    height: auto;
    background: var(--poster-m) 50% 50% / cover no-repeat;
    filter: blur(28px) brightness(0.5);
  }
}

/* Layers, bottom to top: frames (poster, canvas) 0, smoke 1, veil 2,
   heading 3, toggle 4. The veil sits ABOVE the smoke.
   The foot: frames and smoke are masked out (gone by 88% / 82% of the panel)
   and the veil is at least 93% --bg from 85%, then fades to transparent. So
   the last 15% is at least 92% background (text rising into the 15svh overlap
   passes AA), and the hero dissolves into the page's own background (which is
   a touch lighter than --bg) with no hard edge. */
.scroll-hero .smoke { z-index: 1; mix-blend-mode: normal; filter: none; }   /* over imagery: as drawn */
.scroll-hero-media {
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 66%, transparent 88%);
  mask-image: linear-gradient(to bottom, black 0%, black 66%, transparent 88%);
}
.smoke--hero {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 56%, transparent 82%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 56%, transparent 82%);
}
/* Veil: darkens behind the heading and fades into the page at the foot. */
.scroll-hero-sticky::after {
  content: "";
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 36% at 50% 56%,
      color-mix(in srgb, var(--shade) 55%, transparent), transparent 75%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 60%, transparent) 0%,
      color-mix(in srgb, var(--shade) 15%, transparent) 26%,
      color-mix(in srgb, var(--shade) 30%, transparent) 50%,
      color-mix(in srgb, var(--bg) 45%, transparent) 64%,
      color-mix(in srgb, var(--bg) 78%, transparent) 75%,
      color-mix(in srgb, var(--bg) 93%, transparent) 85%,
      color-mix(in srgb, var(--bg) 93%, transparent) 88%,
      transparent 100%);
}
.scroll-hero--full .scroll-hero-sticky::after {
  /* Home: a soft shade behind the heading only, and a short fade at the very
     foot, so the roots and crystals stay in view. */
  background:
    radial-gradient(ellipse 58% 40% at 50% 42%,
      color-mix(in srgb, var(--shade) 42%, transparent), transparent 80%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 35%, transparent) 0%,
      transparent 22%,
      transparent 86%,
      color-mix(in srgb, var(--bg) 70%, transparent) 95%,
      var(--bg) 100%);
}
.scroll-hero--full .scroll-hero-media {
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 90%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 90%, transparent 100%);
}
.scroll-hero--full .smoke--hero {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 80%, transparent 98%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 80%, transparent 98%);
}

/* The page's own heading: over the veil, fading and lifting as the smoke
   thickens (--p, 0 to 1, from scrollscrub.js). Focus brings it straight back. */
.scroll-hero-content {
  /* Light on the image in both themes: inside the hero the text tokens are
     the hero's own (and --bg is the image shade, for the text shadow and the
     ghost button). */
  --text: var(--hero-text);
  --text-soft: var(--hero-text);
  --sage: var(--hero-accent);
  --link: var(--hero-accent);
  --focus: var(--hero-text);
  --bg: var(--shade);
  --plum-bright: var(--logo-lavender);
  --plum-light: var(--logo-lavender);
  --hairline-strong: color-mix(in srgb, var(--hero-accent) 60%, transparent);
  color: var(--hero-text);
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 54rem;
  padding: calc(var(--header-h) + var(--space-3)) var(--gutter) clamp(3rem, 12vh, 7rem);
  text-align: center;
  text-shadow: 0 1px 14px var(--bg), 0 0 2px var(--bg);
  opacity: calc(1 - var(--p, 0) * 2);
  transform: translateY(calc(var(--p, 0) * -5rem));
}
.scroll-hero--full .scroll-hero-content {
  max-width: 50rem;
  padding: 6rem var(--gutter) 8vh;
  opacity: calc(1 - (var(--p, 0) - 0.55) * 3);
  transform: translateY(calc(max(var(--p, 0) - 0.4, 0) * -8rem));
}
.scroll-hero-content:focus-within { opacity: 1; transform: none; }
/* Ghost buttons keep a near-solid shade behind their light text, so they
   pass AA wherever the hero foot fades to a light theme background. */
.scroll-hero-content .btn-ghost { background: color-mix(in srgb, var(--shade) 88%, transparent); }
.scroll-hero-content .page-head,
.scroll-hero-content .article-header { max-width: none; margin: 0 auto; }
.scroll-hero-content .page-head .ornament,
.scroll-hero-content .article-header .ornament { margin-bottom: 0; }
.scroll-hero-content .breadcrumb { margin-bottom: var(--space-2); }
.scroll-hero-content .kicker { margin-top: 0; }
@media (prefers-reduced-motion: reduce) {
  .scroll-hero-content { opacity: 1; transform: none; }
}

/* Motion toggle (WCAG 2.2.2): shown by scrollscrub.js while frames scrub. */
.hero-toggle {
  position: absolute;
  right: var(--gutter);
  bottom: var(--space-3);
  z-index: 4;
  display: grid;
  place-items: center;
  width: 2.75rem;   /* 44px hit area */
  height: 2.75rem;
  padding: 0;
  /* Solid sage edge: well over 3:1 against the darkened frame behind it. */
  border: 1px solid var(--sage);
  border-radius: 50%;
  background: var(--veil-strong);
  color: var(--text);
  cursor: pointer;
}
.hero-toggle[hidden] { display: none; }
.hero-toggle:hover { border-color: var(--text); background: var(--panel); }
.hero-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.hero-toggle .icon-play,
.hero-toggle.is-paused .icon-pause { display: none; }
.hero-toggle.is-paused .icon-play { display: block; }
/* Short heroes: top right, clear of the heading block and its ornament. */
.scroll-hero--short .hero-toggle { top: calc(var(--header-h) + var(--space-2)); bottom: auto; }

/* Short landscape viewports (phones on their side): the panel grows to fit
   its heading so nothing is clipped. */
@media (max-height: 34rem) {
  .scroll-hero-sticky,
  .scroll-hero--full .scroll-hero-sticky { height: auto; min-height: 100vh; min-height: 100svh; }
  .scroll-hero--full .scroll-hero-content { padding: 6.5rem var(--gutter) var(--space-2); }
}

/* ==========================================================================
   White pages (29 Oct, "book cover" look)
   The moonlit scene is a picture plate on a white page: it no longer fades
   into the page (a dark photo fading to white turns muddy grey). It ends on a
   clean edge underlined by two fine "foil" lines, sage over lavender, and
   the content starts below it on white.
   ========================================================================== */
.scroll-hero-media { -webkit-mask-image: none; mask-image: none; }
.smoke--hero {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 80%, transparent 100%);
}
/* The smoke stays in the scene in both themes (it is hidden on white bands). */
:root:not([data-theme="dark"]) .scroll-hero .smoke { display: block; }
.scroll-hero-sticky::after {
  background:
    radial-gradient(ellipse 70% 36% at 50% 62%,
      color-mix(in srgb, var(--shade) 50%, transparent), transparent 75%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 60%, transparent) 0%,
      color-mix(in srgb, var(--shade) 15%, transparent) 26%,
      color-mix(in srgb, var(--shade) 30%, transparent) 55%,
      color-mix(in srgb, var(--shade) 70%, transparent) 100%);
}
/* Short heroes no longer overlap the content that follows. */
.motion .scroll-hero--short { margin-bottom: 0; }
.motion .scroll-hero--short .scroll-hero-content { padding-bottom: clamp(3rem, 12vh, 7rem); }
/* The two foil lines under every hero. */
.scroll-hero::after {
  content: "";
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-lavender);
  pointer-events: none;
}
.scroll-hero + *, .article--hero > .scroll-hero + * { margin-top: var(--space-4); }

/* ---------- Home: scroll to bring out the crystals ----------
   --p runs 0 to 1 as you scroll through the hero (scrollscrub.js). The whole
   scene glides down and in towards the crystals at the foot of the roots
   (a zoom about a point below and left of them, so they rise towards the
   middle and no edge of the frame ever shows), brightening a little. As the
   heading fades, three fine rings like the book cover's foil draw in around
   them, with a soft lavender glow behind. Static (no JS, reduced motion,
   save data): --p is 0, so the scene simply shows as it is. */
.scroll-hero--full {
  --ox: 32%;          /* zoom origin */
  --oy: 100%;
  --zoom: 1;          /* extra scale at the end: 1 -> 2 */
  --cx: 46%;          /* where the crystals settle: the rings' centre */
  --cy: 77%;
  --ring: min(16svh, 18vw);
  --rp: clamp(0, (var(--p, 0) - 0.58) * 3.2, 1);   /* rings: 0 -> 1 late in the scroll */
}
.scroll-hero--full .scroll-hero-sticky::after {
  /* Home veil: shade behind the heading only, darker edges as you go in. */
  background:
    radial-gradient(ellipse 58% 40% at 50% 42%,
      color-mix(in srgb, var(--shade) calc(42% * (1 - var(--p, 0))), transparent), transparent 80%),
    radial-gradient(circle at var(--cx) var(--cy), transparent 25%,
      color-mix(in srgb, var(--shade) calc(55% * var(--rp)), transparent) 75%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 35%, transparent) 0%,
      transparent 22%,
      transparent 80%,
      color-mix(in srgb, var(--shade) 45%, transparent) 100%);
}
.scroll-hero--full .scroll-hero-media {
  transform-origin: var(--ox) var(--oy);
  transform: scale(calc(1 + var(--p, 0) * var(--zoom)));
  filter: brightness(calc(1 + var(--p, 0) * 0.15)) saturate(calc(1 + var(--p, 0) * 0.15));
}
.scroll-hero--full .smoke--hero { opacity: calc(1 - var(--rp) * 0.5); }
.scroll-hero--full .scroll-hero-sticky::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: var(--cx);
  top: var(--cy);
  width: calc(var(--ring) * 2);
  height: calc(var(--ring) * 2);
  border: 1px solid var(--logo-sage-light);
  outline: 1px solid var(--logo-sage-light);
  outline-offset: 12px;
  border-radius: 50%;
  background:
    /* inner lavender ring, 14px inside */
    radial-gradient(circle closest-side, transparent calc(100% - 15px),
      var(--line-lavender) calc(100% - 15px), var(--line-lavender) calc(100% - 14px), transparent calc(100% - 14px)),
    /* the glow */
    radial-gradient(circle closest-side, color-mix(in srgb, var(--logo-lavender) 28%, transparent), transparent 85%);
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: var(--rp);
  transform: translate(-50%, -50%) scale(calc(1.18 - var(--rp) * 0.18));
}
@media (orientation: portrait), (max-width: 47.99rem) {
  /* Mobile frame: the crystals sit just right of centre, about half way down. */
  .scroll-hero--full { --ox: 80%; --oy: 64%; --zoom: 1.2; --cx: 50%; --cy: 45%; --ring: min(19svh, 38vw); }
  .scroll-hero--full .scroll-hero-sticky::before { outline-offset: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hero--full .scroll-hero-media { transform: none; filter: none; }
  .scroll-hero--full .scroll-hero-sticky::before { opacity: 0; }
}


/* ---------- Silver dawn: heroes with a light-theme version ----------
   Both posters sit in the media layer; the one for the current theme shows,
   and switching theme crossfades them. scrollscrub.js fades the canvas out,
   swaps to the other theme's frames and fades it back in. In the light theme
   the veil turns pale and the heading dark. */
.scroll-hero-pic { transition: opacity 1.2s ease; }
.scroll-hero-pic--light { opacity: 0; }
:root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-pic--light { opacity: 1; }
:root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-pic--night { opacity: 0; }
.scroll-hero-canvas { transition: opacity 0.8s ease; }
:root:not([data-theme="dark"]) .scroll-hero--dawn {
  --shade: var(--dawn-shade);
  --hero-text: var(--dawn-text);
  --hero-accent: var(--dawn-accent);
}
@media (orientation: portrait), (max-width: 47.99rem) {
  :root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-media::before {
    background-image: var(--poster-m-light);
    filter: blur(28px) brightness(1.04);
  }
}
/* The drifting smoke is grey: over dawn it muddies, so it is screened in as
   pale mist instead. */
:root:not([data-theme="dark"]) .scroll-hero--dawn .smoke,
:root:not([data-theme="dark"]) .scroll-hero--dawn .smoke-l { mix-blend-mode: screen; }
@media (prefers-reduced-motion: reduce) {
  .scroll-hero-pic, .scroll-hero-canvas { transition: none; }
}

/* Dawn heroes in the light theme: the picture at full strength. The night
   veil (a shade over the whole frame, made for light text on a dark scene)
   would wash dawn out, so here there is only a soft pale glow behind the
   heading, a whisper at the very top for the header, and lighter smoke. */
:root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-sticky::after {
  background:
    radial-gradient(ellipse 44% 24% at 50% 64%,
      color-mix(in srgb, var(--shade) 66%, transparent), transparent 78%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 34%, transparent) 0%,
      transparent 16%);
}
:root:not([data-theme="dark"]) .scroll-hero--full.scroll-hero--dawn .scroll-hero-sticky::after {
  background:
    radial-gradient(ellipse 46% 30% at 50% 44%,
      color-mix(in srgb, var(--shade) calc(60% * (1 - var(--p, 0))), transparent), transparent 80%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--shade) 30%, transparent) 0%,
      transparent 16%);
}
:root:not([data-theme="dark"]) .scroll-hero--dawn .smoke--hero { opacity: 0.45; }
:root:not([data-theme="dark"]) .scroll-hero--dawn:not(.scroll-hero--full) .scroll-hero-media {
  filter: contrast(1.06) saturate(1.12);
}
/* The heading reads on the image itself: a tighter, brighter halo. */
:root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-content {
  text-shadow: 0 0 18px var(--dawn-shade), 0 0 3px var(--dawn-shade), 0 0 1px var(--dawn-shade);
}

/* Dawn heroes, light theme: the heading sits on a frosted pane (a soft pale
   glass that blurs the scene just behind the words), so titles read clearly
   over busy, pale foliage while the rest of the picture stays at full strength. */
:root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-content {
  width: fit-content;
  min-width: min(32rem, calc(100% - 2 * var(--gutter)));
  max-width: min(54rem, calc(100% - 2 * var(--gutter)));
  margin-top: calc(var(--header-h) + var(--space-3));
  padding: clamp(1.4rem, 3vw, 2.2rem) clamp(1.4rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--dawn-shade) 62%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid color-mix(in srgb, var(--dawn-shade) 80%, transparent);
  border-radius: var(--r-img);
  box-shadow: 0 18px 50px -30px color-mix(in srgb, var(--dawn-text) 45%, transparent);
  text-shadow: none;
}
:root:not([data-theme="dark"]) .scroll-hero--short.scroll-hero--dawn .scroll-hero-content {
  margin-bottom: clamp(3rem, 12vh, 7rem);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root:not([data-theme="dark"]) .scroll-hero--dawn .scroll-hero-content {
    background: color-mix(in srgb, var(--dawn-shade) 88%, transparent);
  }
}
/* Home: the headline is large enough to read on the scene, so no pane: just
   a strong soft halo (the subtitle gets a little extra). */
:root:not([data-theme="dark"]) .scroll-hero--full.scroll-hero--dawn .scroll-hero-content {
  width: 100%;
  min-width: 0;
  max-width: 50rem;
  margin-top: 0;
  padding: 6rem var(--gutter) 8vh;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
  text-shadow: 0 0 22px var(--dawn-shade), 0 0 8px var(--dawn-shade), 0 0 2px var(--dawn-shade);
}
:root:not([data-theme="dark"]) .scroll-hero--full.scroll-hero--dawn .hero-sub {
  text-shadow: 0 0 12px var(--dawn-shade), 0 0 12px var(--dawn-shade), 0 0 4px var(--dawn-shade), 0 0 1px var(--dawn-shade);
}
:root:not([data-theme="dark"]) .scroll-hero--full.scroll-hero--dawn .hero-sub {
  display: table;
  margin-left: auto;
  margin-right: auto;
  max-width: 34rem;
  padding: 1.2rem 2.4rem;
  /* A soft glow that fades to nothing at its edges: no visible panel. */
  background: radial-gradient(closest-side, color-mix(in srgb, var(--dawn-shade) 82%, transparent) 55%,
              color-mix(in srgb, var(--dawn-shade) 40%, transparent) 78%, transparent 100%);
  text-wrap: balance;
  text-shadow: 0 0 10px var(--dawn-shade), 0 0 2px var(--dawn-shade);
}
