/* MANACA v3: the campaign chapters. "#nights" is the page's second set piece; ".split.grow" is the grow-in that turns
   the page dark (and this file is where the dark tokens for everything below it are defined, see "the dark half").
   Driven by js/chapter.js.

   #nights, in one sentence: a lit pocket in the plaster wall opens until the night fills the screen.
   Two layers share one layout. .ch-wall is the real copy, ink on plaster. .ch-night is the photo with the same
   copy in chrome, clipped to the pocket, so the type turns from ink to chrome exactly at the pocket's edge and
   the seated figure (a cut-out of the same photo) sits in front of the headline.
   Per frame only clip-path (two layers), transform and opacity change, all from custom properties that
   js/chapter.js writes on .chapter-stick. With no JS, reduced motion or a weak phone the defaults below are the
   final state: night open, full bleed, nothing pinned. */

/* ================= nights ================= */
.chapter { position: relative; height: 250vh; }
.chapter-stick {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; contain: paint;
  background: var(--ground); color: var(--ink); container-type: size;
  /* --q: how closed the pocket is (1 closed, 0 open)   --x: exit (0..1)   --l: lip width (0..1)
     --z: photo zoom   --d: type drift, px   --s: sweep position (0..1)   --so: sweep opacity */
  --q: 0; --x: 0; --l: 0; --z: 1; --d: 0; --s: 0; --so: 0;
  --W: 100vw; --H: 100vh;
  /* the photo is a 16:9 box that always covers the screen and keeps the seated figure's head on the centre line */
  --iw: max(calc(var(--W) * 1.02), calc(var(--H) * 1.7778));
  --ih: calc(var(--iw) * .5625);
  --sx: calc(var(--W) * .5 - var(--iw) * .509);
  --sy: calc((var(--H) - var(--ih)) * .45);
  --lw: clamp(5px, .6vw, 9px);
  /* the pocket: inset and corner radii of the opening, shared by the night layer and its lip */
  --pt: 11%; --ps: 26%; --pb: 15%; --xs: 2.2%; --xb: 14px; --xr: clamp(24px, 3.6vw, 54px);
}
@supports (width: 1cqw) { .chapter-stick { --W: 100cqw; --H: 100cqh; } }
@media (max-aspect-ratio: 1/1) { .chapter-stick { --pt: 13%; --ps: 8%; --pb: 17%; --xs: 3%; } }

.ch-wall, .ch-lip, .ch-night { position: absolute; inset: 0; }
.ch-wall { z-index: 0; opacity: calc(1 - var(--x) * 8); }   /* covered by the night by then; hidden so no ink shows in the exit gap. Still tappable. */
.ch-lip, .ch-night {
  --a: calc(var(--l) * var(--lw) * var(--k, 0));
  clip-path: inset(
    calc(var(--q) * var(--pt) - var(--a))
    calc(var(--q) * var(--ps) + var(--x) * var(--xs) - var(--a))
    calc(var(--q) * var(--pb) + var(--x) * var(--xb) - var(--a))
    calc(var(--q) * var(--ps) + var(--x) * var(--xs) - var(--a))
    round calc(var(--q) * 50%) calc(var(--q) * 50%) calc(var(--q) * 16% + var(--x) * var(--xr)) calc(var(--q) * 16% + var(--x) * var(--xr))
    / calc(var(--q) * 42%) calc(var(--q) * 42%) calc(var(--q) * 12% + var(--x) * var(--xr)) calc(var(--q) * 12% + var(--x) * var(--xr)));
  will-change: clip-path; pointer-events: none;
}
/* the thickness of the poured wall around the pocket: lit from the LED under its top lip, in shade at the bottom */
.ch-lip { z-index: 1; --k: 1; background: linear-gradient(180deg, #fff 0%, #fbfbf6 30%, #cfcfc6 62%, #b9b9b0 100%); }
.ch-night { z-index: 2; background: #0b0b0a; color: #f4f5ef; overflow: hidden; }

.ch-photo, .ch-fg { position: absolute; max-width: none; transform: scale(var(--z)); will-change: transform; }
.ch-photo { left: var(--sx); top: var(--sy); width: var(--iw); height: var(--ih); transform-origin: 50.9% 44%; }
/* the cut-out is the photo's own pixels from x 37% to 64% and y 32.98% to 69.96%, so it lands exactly on itself */
.ch-fg { left: calc(var(--sx) + var(--iw) * .37); top: calc(var(--sy) + var(--ih) * .32978);
  width: calc(var(--iw) * .27); height: calc(var(--ih) * .36978); transform-origin: 51.48% 29.8%; }

/* photo dimmed behind the headline band only, so the chrome keeps its contrast over pale clothes; the cut-out is not dimmed */
.ch-dim, .ch-led, .ch-scrim { position: absolute; inset: 0; }
.ch-dim { left: 0; right: 0; top: var(--sy); bottom: auto; height: var(--ih);
  background: linear-gradient(180deg, transparent 24%, rgb(4 6 8 / .52) 35%, rgb(4 6 8 / .52) 60%, transparent 69%); }
@media (max-aspect-ratio: 1/1) { .ch-dim { background: linear-gradient(180deg, rgb(4 6 8 / .55) 0%, rgb(4 6 8 / .5) 34%, transparent 46%); } }
/* LED under the pocket's top lip, falling onto the photo; gone once the pocket is the whole screen */
.ch-led { opacity: calc(var(--q) * .8); transform: translate3d(0, calc(var(--q) * var(--pt)), 0);
  background: radial-gradient(46% 30% at 50% 0%, rgb(var(--led) / .62), rgb(var(--led) / .18) 55%, transparent 76%); }
/* one band of light crossing the room as the pocket opens */
.ch-sweep { position: absolute; top: -12%; left: 0; width: 46%; height: 124%; opacity: var(--so);
  transform: translate3d(calc(var(--s) * 345% - 112%), 0, 0) skewX(-16deg); will-change: transform, opacity;
  background: linear-gradient(90deg, transparent, rgb(var(--led) / .1) 28%, rgb(255 255 255 / .3) 50%, rgb(var(--led) / .1) 72%, transparent); }
.ch-scrim { background: linear-gradient(0deg, rgb(0 0 0 / .9), rgb(0 0 0 / .62) 20%, transparent 44%), linear-gradient(180deg, rgb(0 0 0 / .62), transparent 20%); }

/* ---------- the copy: the same grid in both layers ---------- */
.ch-copy { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto auto; justify-items: start; row-gap: 14px;
  padding: 86px var(--gut) max(26px, 4vh); }
.ch-kick { grid-row: 1; font: 600 17px/1.3 var(--body); }
.ch-line { grid-row: 3; margin: 0; font: inherit; }
.ch-cta { grid-row: 4; margin-top: 6px; }
.ch-sub, .ch-big { font-family: var(--display); font-weight: 820; font-stretch: 62%; letter-spacing: -.025em; text-transform: none; }
.ch-sub { display: block; font-size: clamp(40px, 5.4vw, 86px); line-height: .9; color: #55544e; }
.ch-night .ch-sub { color: rgb(var(--led)); }
.ch-wall .ch-kick { color: #2b2a26; }

/* the headline at scale. Wide screens: one line, the two words either side of her head, baseline on her collar, caps clear of the standing faces. */
.ch-big { position: absolute; inset: 0; display: block; pointer-events: none; color: var(--ink);
  --S: min(calc(var(--ih) * .325), calc((var(--W) * .5 - var(--iw) * .041 - var(--gut)) / 1.72));
  font-size: var(--S); line-height: 1; white-space: nowrap;
  transform: translate3d(0, calc(var(--d) * 1px), 0); will-change: transform; }
.ch-w1, .ch-w2 { position: absolute; top: calc(var(--sy) + var(--ih) * .575 - var(--S) * .834); }
.ch-w1 { right: calc(var(--W) * .5 + var(--iw) * .041); transform: translate3d(calc(var(--q) * -2.4vw), 0, 0); }
.ch-w2 { left: calc(var(--W) * .5 + var(--iw) * .05); transform: translate3d(calc(var(--q) * 2.4vw), 0, 0); }
/* tall screens: two lines on the wall above her, the last one tucked behind her hair */
@media (max-aspect-ratio: 1/1) {
  .ch-big { --S: min(calc(var(--W) * .345), calc((var(--H) * .398 - 104px) / 1.6)); }
  .ch-w1, .ch-w2 { left: var(--gut); right: auto; transform: none; }
  .ch-w2 { top: calc(var(--sy) + var(--ih) * .398 - var(--S) * .834); }
  .ch-w1 { top: calc(var(--sy) + var(--ih) * .398 - var(--S) * 1.7); }
  .ch-copy { padding-top: 76px; }
  .ch-kick { font-size: 15px; }
}
/* chrome: a bright body with one soft horizon, and a shadow so the edge holds over any part of the photo */
.ch-chrome { color: #f4f5ef; }
.ch-chrome .ch-w1, .ch-chrome .ch-w2 { filter: drop-shadow(0 2px 10px rgb(0 0 0 / .55)); }   /* on the word, which is the layer that moves, so it is drawn once */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .ch-chrome .ch-w1, .ch-chrome .ch-w2 { color: transparent; -webkit-background-clip: text; background-clip: text;
    background-image: linear-gradient(180deg, #fff 16%, #f4f7e8 36%, #cdd1c3 48%, #9da195 53.5%, #e9eddd 57%, #fff 74%, #ccd0c2 92%); }
}

.ch-cta:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
/* the real link sits under the night layer; show its focus ring on the visible twin */
.chapter-stick:has(.ch-wall .ch-cta:focus-visible) .ch-night .ch-cta { outline: 3px solid rgb(var(--led)); outline-offset: 3px; }

/* still version: no JS, reduced motion, or js/chapter.js judged the phone too weak */
html:not(.js) .chapter, .chapter.ch-still { height: auto; }
html:not(.js) .chapter-stick, .chapter.ch-still .chapter-stick { position: relative; }
.chapter.ch-still .ch-sweep, .chapter.ch-still .ch-led { display: none; }
@media (prefers-reduced-motion: reduce) {
  .chapter { height: auto; }
  .chapter-stick { position: relative; }
  .ch-lip, .ch-night { clip-path: none; }
  .ch-sweep, .ch-led { display: none; }
  .ch-photo, .ch-fg, .ch-big, .ch-w1, .ch-w2 { transform: none; }
}

/* ================= the dark half: tokens =================
   From the grow-in chapter down the page is dark. These are the only dark values: every section below styles itself
   with --ground / --panel / --well / --ink / --mute / --line (and --led), so it works in either tone.
   Scoped to what follows the chapter (and the footer), so the hero, Night outs and the header, which switch their own
   data-tone while you scroll, are not touched. */
.split.grow ~ [data-tone="dark"], body > footer[data-tone="dark"] {
  --ground: #0b0b0a; --panel: #161614; --well: #20201d; --ink: #f1f2ea; --mute: #a5a49b; --line: rgb(241 242 234 / .15);
  background-color: var(--ground); color: var(--ink); color-scheme: dark;
}
/* sections are capped at a max-width; the ground runs to both screen edges anyway */
.split.grow ~ [data-tone="dark"] { box-shadow: 0 0 0 100vmax var(--ground); clip-path: inset(-1px -100vmax); }
.split.grow ~ [data-tone="dark"] :focus-visible { outline-color: rgb(var(--led)); }

/* ================= the grow-in: the two-shoot composition grows until it holds the screen, and the page turns to night =================
   The shape is the round-2 one: a tall print on the left, a wide one overlapping it from the right, each a pocket set in
   a rounded plaster frame with a lit top lip and a shaded bottom lip, and the line in the notch under the wide print.
   .grow-stage pins for a little over two screens. .grow-comp is laid out at its final size and scaled up to it (one
   transform); inside, each pocket opens from an arch in thick plaster to a soft rectangle with a thin lip (one clip-path
   each). It ends as that shape, large, never as a full-bleed rectangle.
   js/chapter.js writes four numbers on the stage, all 0..1: --g grown, --k pocket still closed, --n night, --t type.
   Without JS, with reduced motion or on a weak phone the defaults below are the finished state and nothing is pinned. */
.split.grow { position: relative; display: block; height: 330vh; max-width: none; margin: 0; padding: 0; --night: #0b0b0a; }
.grow-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; contain: paint; background: var(--ground);
  --g: 1; --k: 0; --n: 1; --t: 1; --q: calc(1 - var(--g));
  /* the box the composition ends in: clear of the header, a thin margin of wall on the other three sides */
  --cx: clamp(12px, 2.4vw, 36px); --ct: calc(var(--trust) + var(--hdr) + 4px); --cb: clamp(14px, 2.6vh, 26px);
  --aw: 31%;                                  /* width of the tall print */
  --bl: 28.4%;                                /* where the wide print starts: it overlaps the tall one */
  --bt: 5.5%;                                 /* and how far below the tall one's top */
  --ch: clamp(132px, 22vh, 210px);            /* the notch under the wide print, kept for the line */
  --lip: clamp(7px, .85vw, 12px);              /* plaster left showing around a pocket once it is open */
  --r: clamp(20px, 2.5vw, 36px); }
.grow-night { position: absolute; inset: 0; background: var(--night); opacity: var(--n); }
.grow-comp { position: absolute; left: var(--cx); right: var(--cx); top: var(--ct); bottom: var(--cb);
  transform: translate3d(0, calc(var(--q) * 2.5%), 0) scale(calc(1 - var(--q) * .52)); transform-origin: 50% 50%; will-change: transform; }
/* the plaster: lit from above, in shade below. It stays lit when the ground goes dark, like a pocket in the store's wall at night
   (tried dimmed to --panel: the frame then reads as a grey border and the shape is lost) */
.grow-a, .grow-b { position: absolute; margin: 0; overflow: hidden; border-radius: var(--r);
  background: linear-gradient(rgb(11 11 10 / calc(var(--n) * var(--dim, .07))) 0 0), linear-gradient(180deg, #fff 0%, #f6f6f0 34%, #cdcdc4 70%, #b9b9b0 100%); }
.grow-a { left: 0; top: 0; bottom: 0; width: var(--aw); }
.grow-b { left: var(--bl); right: 0; top: var(--bt); bottom: calc(var(--ch) + clamp(10px, 1.6vh, 18px)); z-index: 1;
  box-shadow: -18px 10px 34px -16px rgb(0 0 0 / .55);                                        /* it stands in front of the tall print */
  transform: translate3d(calc(var(--q) * 5%), calc(var(--q) * 12%), 0); will-change: transform; }
.grow-p { position: absolute; inset: 0; display: block; overflow: hidden; background: #1c1c1a; will-change: clip-path;
  --ri: calc(var(--r) - var(--lip));
  clip-path: inset(calc(var(--lip) + var(--k) * 7%) calc(var(--lip) + var(--k) * 9%) calc(var(--lip) * 1.3 + var(--k) * 5%) calc(var(--lip) + var(--k) * 9%)
    round calc(var(--ri) + var(--k) * 41%) calc(var(--ri) + var(--k) * 41%) calc(var(--ri) + var(--k) * 6%) calc(var(--ri) + var(--k) * 6%)
    / calc(var(--ri) + var(--k) * 30%) calc(var(--ri) + var(--k) * 30%) calc(var(--ri) + var(--k) * 4%) calc(var(--ri) + var(--k) * 4%)); }
.grow-p img { width: 100%; height: 100%; max-width: none; object-fit: cover; transform: scale(calc(1 + var(--k) * .12)); will-change: transform; }
.grow-a img { object-position: 44% 50%; }
.grow-b img { object-position: 62% 50%; }
/* the pocket is recessed: the top lip throws a little shade onto the print */
.grow-p::after { content: ""; position: absolute; left: 0; right: 0; top: var(--lip); height: 16%; pointer-events: none;
  transform: translate3d(0, calc(var(--k) * 43.75%), 0);                                    /* 7% of the pocket = 43.75% of this band */
  background: linear-gradient(180deg, rgb(0 0 0 / .42), rgb(0 0 0 / .12) 34%, rgb(0 0 0 / 0)); }

.grow-kick { position: absolute; z-index: 1; left: 27.6%; top: calc(var(--trust) + var(--hdr) + 3.2vh); max-width: 24ch; font: 600 17px/1.35 var(--body); color: var(--ink);
  opacity: clamp(0, calc(1 - var(--g) * 3.4), 1); pointer-events: none; }
/* the line sits on the dark wall in the notch, bottom edge level with the tall print's: never on a face, never on the photo */
.grow-copy { position: absolute; z-index: 2; left: calc(var(--cx) + (100% - 2 * var(--cx)) * .31 + clamp(20px, 2.6vw, 42px)); right: var(--cx); bottom: var(--cb); height: var(--ch);
  display: grid; align-content: end; justify-items: start; gap: clamp(2px, .8vh, 10px); color: #f4f5ef;
  opacity: var(--t); transform: translate3d(0, calc((1 - var(--t)) * 22px), 0); will-change: transform, opacity; }
.grow-line { max-width: 22em; font-family: var(--display); font-weight: 820; font-stretch: 62%; letter-spacing: -.025em; line-height: .92; text-transform: none; text-wrap: balance;
  font-size: clamp(27px, min(4.7vw, 7.3vh), 76px); }
.grow-copy .more { color: #f4f5ef; margin-bottom: -12px; }                                  /* its underlined text, not its 44px box, lines up with the print's edge */
.grow-copy .more:focus-visible { outline: 2px solid rgb(var(--led)); outline-offset: 3px; }

/* tall screens (phones): the same shape turned upright. Tall print top left, wide print overlapping from the lower right, the line under both */
@media (max-aspect-ratio: 1/1) {
  .grow-stage { --ch: clamp(124px, 18.5vh, 190px); --r: clamp(18px, 5vw, 30px); --lip: 6px; }
  .grow-a { width: 73%; bottom: auto; height: 54%; }
  .grow-b { left: 13%; top: 48%; bottom: calc(var(--ch) + 12px); }
  .grow-a img { object-position: 42% 40%; }
  .grow-b img { object-position: 68% 50%; }
  .grow-kick { left: 26.5%; top: calc(var(--trust) + var(--hdr) + 5.5vh); font-size: 15px; max-width: 20ch; }
  .grow-copy { left: calc(var(--cx) + 2px); right: calc(var(--cx) + 2px); }
  .grow-line { font-size: clamp(25px, min(8.7vw, 4.3vh), 54px); }
}
/* a phone on its side: little height, so a thinner notch */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  .grow-stage { --ch: 96px; --ct: calc(var(--trust) + var(--hdr)); }
  .grow-line { font-size: 22px; }
}

/* still version: no JS, reduced motion, or js/chapter.js judged the phone too weak. The finished composition, page already dark, nothing pinned. */
html:not(.js) .split.grow, .split.grow.g-still { height: auto; }
html:not(.js) .grow-stage, .split.grow.g-still .grow-stage { position: relative; }
html:not(.js) .grow-kick, .split.grow.g-still .grow-kick { display: none; }
@media (prefers-reduced-motion: reduce) {
  .split.grow { height: auto; }
  .grow-stage { position: relative; --g: 1 !important; --k: 0 !important; --n: 1 !important; --t: 1 !important; }
  .grow-kick { display: none; }
}
