/* ==========================================================================
   Place of Padel — Chapters

   A chapter is a tall runway with a stage pinned inside it. You scroll the
   runway; the stage stays still and its contents move. That is the whole idea,
   and it is the same one likova.space spends 293KB of JavaScript on.

   How progress works
   ------------------
   The runway carries a view timeline. The runway also animates --px from 0 to 1
   along it, over the `contain` range — the window during which a subject taller
   than the viewport completely covers it, which is exactly the period the stage
   is pinned. --px inherits, so every layer inside reads the same number.

   Nothing else in this file knows where scroll came from. A layer says what it
   does with --px; js/px.js supplies --px for browsers without scroll timelines.
   That is the seam, and it is why there is no third code path.

   The timeline name is reused
   ---------------------------
   Every chapter declares `--chapter`, not a unique name. A named timeline is
   resolved against the element and its ancestors, so each stage finds the
   runway it is actually inside. Chapters two through six cost no new names.

   Reduced motion
   --------------
   The runway collapses and the stage unpins. This matters more than removing
   the movement: a pinned chapter decouples scrolling from travel, which is
   nauseating for vestibular users even when nothing is moving. --px is forced
   to 1, so what is left is the composed final frame of the chapter — the plate
   at rest, the words fully arrived. Nobody loses content.
   ========================================================================== */

/* --------------------------------------------------------------------------
   The runway and the stage
   -------------------------------------------------------------------------- */

.chapter {
  position: relative;
  height: var(--pin-long);
  view-timeline: --chapter block;

  /* Skip rendering work for chapters nowhere near the viewport. Two things
     worth knowing before touching this:

     It saves no bytes. `loading="lazy"` governs fetching; this governs style,
     layout and paint. Measured in both states, the transfer is identical.

     It does not break the pin. All five chapters keep a running ViewTimeline
     and a sticky stage with it applied, which was verified directly rather
     than assumed.

     It was briefly removed during a polish pass on the belief that it stopped
     the plate painting. That was wrong: the blank renders were the headless
     decode race documented in README under "Testing this page", which lands
     about one run in five whatever this property is set to. */
  content-visibility: auto;

  /* Explicit rather than `auto`: guessing wrong makes the scrollbar jump
     during a fast scroll, which is worse than the work saved. */
  contain-intrinsic-size: auto var(--pin-long);
}

/* The one place scroll becomes a number.
   `contain` is the range in which a subject taller than the scrollport covers
   it completely — start when the runway's top reaches the viewport top, end
   when its bottom reaches the viewport bottom. That is precisely the window the
   stage is pinned for, so --px is 0 the moment the stage locks and 1 the moment
   it releases, with no arithmetic anywhere. */
@keyframes px-run { to { --px: 1; } }

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .chapter {
      animation: px-run linear both;
      animation-timeline: --chapter;
      animation-range: contain 0% contain 100%;
    }
  }
}

.chapter__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;          /* the mask every moving layer works inside */
  display: grid;
  align-content: end;
  background: var(--ground-deep);
}

/* --------------------------------------------------------------------------
   Layers
   -------------------------------------------------------------------------- */

/* The plate overhangs its mask, so a layer that moves can never expose an edge.
   Same reasoning, and the same token, as the renders in the carousel. */
.chapter__plate {
  position: absolute;
  inset: var(--mask-inset);
  z-index: 0;
}

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

/* Three layers, and they are sized for the worst frame this chapter can show,
   not the average one.

   The courts render is the brightest plate on the site — a white shed roof
   under skylights — and cream type over its lower third measured under 2:1
   before this was rebuilt. So: a flat wash that takes the whole plate down a
   step, a deep rise from the bottom that the words actually sit on, and a
   band at the top so the plate doesn't meet the section above on a hard line.

   Test any change to this against the courts plate. Most of the library is
   darker and will hide a scrim that is too thin. */
.chapter__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to bottom,
      oklch(var(--scrim-ink) / 0.62) 0%,
      oklch(var(--scrim-ink) / 0) 26%),
    linear-gradient(to top,
      oklch(var(--scrim-ink) / 0.97) 0%,
      oklch(var(--scrim-ink) / 0.90) 22%,
      oklch(var(--scrim-ink) / 0.62) 42%,
      oklch(var(--scrim-ink) / 0.18) 66%,
      oklch(var(--scrim-ink) / 0) 82%),
    linear-gradient(oklch(var(--scrim-ink) / 0.22), oklch(var(--scrim-ink) / 0.22));
}

.chapter__say {
  position: relative;
  z-index: 2;
  /* The bottom padding carries the waitlist bar's measured height. The bar is
     fixed at the foot of the viewport and the say block is anchored to the
     bottom of a 100svh stage, so without this the last line of a note sits
     behind it: on a 390px phone the recovery chapter's note ran to 806px with
     the bar starting at 784. --joinbar-h is published by js/px.js and is 0
     whenever the bar is down, so this costs nothing the rest of the time. The
     gallery's rail and note already ride on the same variable. */
  padding: 0 var(--gutter) calc(var(--gap-wide) + var(--joinbar-h, 0px));
  max-width: var(--shell);
  margin-inline: auto;
  width: 100%;
  /* A grid item's default min-width is auto, which means it cannot shrink below
     its own min-content: one long unbreakable run in a title at --fs-hero and
     the whole block widens past the viewport, where the stage's overflow:hidden
     cuts it off. That is a defect the markup should not be able to cause, so
     the floor is removed here rather than being avoided word by word. */
  min-width: 0;
}

.chapter__label {
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  color: var(--pop-brass);
  margin-bottom: var(--gap-close);
}

/* The one number on the page that is allowed to be this size. It is the whole
   argument of the chapter, so it gets the whole stage. */
.chapter__title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: var(--lh-hero);
  letter-spacing: var(--ls-hero);
  text-transform: uppercase;
  font-weight: var(--fw-regular);
  color: var(--ink-bright);
  margin: 0;
}

.chapter__note {
  font-size: var(--fs-lede);
  line-height: var(--lh-body);
  color: var(--ink-body);
  max-width: var(--measure);
  margin-top: var(--gap-close);
}

/* --------------------------------------------------------------------------
   Patterns

   A pattern is a named thing a layer does with --px. This is the analogue of
   likova's data-parallax-pattern, at the size this page actually needs: the
   name is the behaviour, the rate is a token, and there is no JavaScript
   registry to keep in sync with the stylesheet.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {

  /* Scale within the mask. The plate starts overscaled and settles to rest, so
     the room appears to open out as you descend into it — the whole point being
     that this needs no separated layers, only resolution to spare. */
  /* Raw --px, not the held progress the readable layers use. This is the one
     layer nobody reads, and keeping it moving through the hold is what stops
     the held beat reading as a frozen page rather than a held shot. */
  [data-px="plate"] {
    transform: scale(calc(1 + var(--depth-plate) - var(--px) * var(--depth-plate)));
    transform-origin: 50% 46%;
  }

  /* Promoted only while the chapter is actually on screen. Leaving will-change
     on permanently is the classic parallax memory leak — it holds a layer per
     chapter for the life of the page. js/px.js adds .is-live on enter and takes
     it off on leave. */
  .chapter.is-live [data-px="plate"] { will-change: transform; }

  /* The words outrun the plate and settle before the chapter releases, on
     --px-hold rather than on raw scroll. They used to arrive at their resting
     position on the exact frame the stage unsticks, so the composition you were
     scrolling toward was never once on screen holding still. */
  [data-px="rise"] {
    transform: translateY(calc((1 - clamp(0, calc(var(--px) / var(--px-hold)), 1)) * var(--rise-from)));
    opacity: clamp(0, calc(var(--px) / var(--px-hold) / 0.28), 1);
  }
}

/* --------------------------------------------------------------------------
   The plan chapter

   The one chapter with no photograph in it. Twelve courts draw themselves in
   sequence as you descend, which is the only thing on this page that could not
   be lifted from someone else's site: it is this building, at this address,
   and the geometry is taken off the issued ground floor plan.

   The drawing is hand-authored rather than exported. pdftocairo turns these
   sheets into 94MB and 304,528 paths, because every hatch line and every text
   outline becomes its own path — see README. Twelve rectangles carry the idea.
   -------------------------------------------------------------------------- */

/* This is the one chapter whose stage is laid out rather than stacked. The
   others overlay type on a full-bleed plate, so absolute layers are right
   there; here the drawing and the words are two things that must not overlap,
   so the stage becomes two rows and each gets its own. */
.chapter--plan .chapter__stage {
  background: var(--ground-base);
  align-content: stretch;
  grid-template-rows: minmax(0, 1fr) auto;
}

.plan {
  min-height: 0;          /* without this the grid row refuses to shrink and
                             the drawing runs off the bottom of the stage */
  padding: var(--gap-wide) var(--gutter) var(--gap-step);
  display: grid;
  place-items: center;
}

.plan svg {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
}

/* Same allowance for the bar as the base rule: this override exists to reset
   the plan chapter's own bottom spacing, and dropping the bar's height with it
   put the note back underneath the bar. */
.chapter--plan .chapter__say {
  padding-bottom: calc(var(--gap-wide) + var(--joinbar-h, 0px));
}

/* Wide: the drawing is nearly square, so stacking it above the words in a
   landscape stage letterboxes it down to a thumbnail. Side by side it gets the
   full height of the stage and reads as the subject it is. Words left, drawing
   right — the drawing is where the eye should finish. */
@media (min-width: 901px) {
  .chapter--plan .chapter__stage {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
  }
  .chapter--plan .chapter__say {
    grid-column: 1;
    grid-row: 1;
    padding-bottom: 0;
  }
  .plan {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    padding: var(--gap-wide) var(--gutter) var(--gap-wide) 0;
  }
}

/* The shell is drawn in cream at low opacity so the courts read as the subject
   and the building reads as the ground they sit in. */
.plan__shell {
  fill: none;
  stroke: var(--rule-quiet);
  stroke-width: 2;
}

.plan__room {
  fill: oklch(0.95 0.01 92 / 0.045);
  stroke: var(--rule-quiet);
  stroke-width: 1.5;
}

.plan__court {
  /* Lime, and at a strength you can actually see. It sat at 10% opacity behind
     brass strokes, which is how the kit's one surprising colour ended up
     invisible. A padel court is this green; the drawing is the only place on
     the page that depicts a physical surface, so this is the one fill that is
     describing something rather than decorating it. */
  fill: oklch(0.87 0.16 118 / 0.26);
  stroke: var(--pop-brass);
  stroke-width: 2.5;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;   /* the still state: undrawn, and the reduced-motion
                             and no-support block below completes it */
}

/* Court 01, the competition court. It keeps the lime surface every other court
   has, because it is the same kind of thing and that fill is describing a real
   surface rather than marking a state. What raises it is weight: a denser fill
   and a firmer edge, drawn in the same brass as every other court line. Giving
   it a colour of its own would say it was a different surface, and giving it
   brass fill would spend the page's one accent on a floor. */
.plan__court--comp {
  fill: oklch(0.87 0.16 118 / 0.44);
  stroke-width: 4;
}

.plan__tag {
  fill: var(--pop-brass);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
}

.plan__num {
  fill: var(--ink-bright);
  font-family: var(--font-body);
  font-size: 21px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
}

.plan__label {
  fill: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
}

@media (prefers-reduced-motion: no-preference) {
  /* Each court gets a slice of the chapter: --i is its index, --plan-step how
     far apart the slices start, --plan-span how long one takes to draw. Both
     are read against the held progress, not raw scroll, so the last court
     finishes at 11*0.06 + 0.34 = 1.0 of the HELD window — which is 72% of the
     pinned one. The remaining 28% is the drawing sitting finished and still.

     It used to be 0.055 and 0.30, landing at 0.905 of raw scroll: the twelve
     courts completed 60px before the chapter released, which is less than one
     wheel notch and is why you scrolled past the end of it. */
  .plan__court {
    stroke-dashoffset: clamp(0, calc(1 - (clamp(0, calc(var(--px) / var(--px-hold)), 1) - var(--i) * var(--plan-step)) / var(--plan-span)), 1);
  }
  .plan__num,
  .plan__tag {
    opacity: clamp(0, calc((clamp(0, calc(var(--px) / var(--px-hold)), 1) - var(--i) * var(--plan-step) - var(--plan-span) * 0.6) / 0.12), 1);
  }
}

/* --------------------------------------------------------------------------
   Narrow

   The pin is the part that carries risk on a phone — sticky plus a scroll
   timeline is where support is thinnest, and a pinned chapter costs a phone
   more scroll than it is worth. So below the shell width a chapter is simply a
   full-height picture with words on it, which is a complete thing to be.
   -------------------------------------------------------------------------- */

/* Phones are pinned too.

   They were not, for two phases: sticky plus a scroll timeline is the least
   supported combination in play, and a pinned chapter costs a phone more scroll
   than a short section does. The compromise was a one-shot entrance driven by a
   --px transition instead of a scrub.

   It was the wrong call. The scrubbed plate is the whole effect, and a phone
   getting a stack of static pictures is not the same page with less motion, it
   is a different and duller page. So the runway and the pin apply at every
   width, and --px comes from the same scroll timeline everywhere.

   Reduced motion still unpins completely, below. */

/* --------------------------------------------------------------------------
   Reduced motion, and no scroll timelines at all
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .chapter { height: auto; --px: 1; transition: none; }
  .chapter.is-in { --px: 1; }
  .chapter__stage { position: static; height: 100svh; }
}

/* Wherever --px never advances — reduced motion, narrow, or a browser with
   neither scroll timelines nor JavaScript — the plan must still be a finished
   drawing rather than an empty rectangle. The still state is the complete one. */
@media (prefers-reduced-motion: reduce) {
  .plan__court { stroke-dashoffset: 0; }
  .plan__num, .plan__tag { opacity: 1; }
}

/* No JavaScript at all.

   On a wide screen the scroll timeline is pure CSS and still scrubs, so this
   changes nothing there. On a narrow one the entrance is driven by .is-in,
   which only js/px.js ever adds — without it --px would sit at 0 forever and
   every chapter's words would stay at opacity 0. Verified the hard way: the
   text really was invisible before this rule existed.

   So: no JS means the finished state, everywhere. */
html:not(.js) .chapter { --px: 1; transition: none; }
html:not(.js) .plan__court { stroke-dashoffset: 0; }
html:not(.js) .plan__num, html:not(.js) .plan__tag { opacity: 1; }

@supports not (animation-timeline: view()) {
  html:not(.js) .plan__court { stroke-dashoffset: 0; }
}

/* ==========================================================================
   The waitlist bar

   Lives here rather than in styles.css because it exists for the chapters:
   moving the email field below a five-chapter narrative is what created the
   need for it.

   It is `hidden` in the markup and unhidden by js/px.js once the hero has
   gone, so a page without JavaScript never shows a bar that nothing controls —
   there the hero form is still in the first viewport and nothing is lost.

   It withdraws over the footer. Not because there is another form down there —
   there isn't — but because a fixed bar sitting on top of the footer's links
   and social icons makes them unreachable on a short screen.
   ========================================================================== */

.joinbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--pop-brass);
  color: var(--pop-pine);
  transform: translateY(101%);   /* 101% so no hairline of brass shows through */
  transition: transform var(--dur-base) var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.joinbar.is-up { transform: none; }

/* Once someone has joined there is nothing left to ask for. */
.is-joined .joinbar { transform: translateY(101%); }

.joinbar__inner {
  max-width: var(--shell);
  margin-inline: auto;
  padding: var(--gap-tight) var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--gap-close);
}

.joinbar__say {
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--ink-onbrass);
  margin-right: auto;
}

.joinbar__form {
  display: flex;
  align-items: center;
  gap: var(--gap-hair);
}

.joinbar__input {
  font: inherit;
  font-size: var(--fs-small);
  color: var(--pop-pine);
  background: var(--field-onbrass);
  border: 1px solid var(--field-onbrass-edge);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  min-height: 44px;            /* touch target floor */
  width: 15rem;
  max-width: 42vw;
}

.joinbar__input::placeholder { color: oklch(0.45 0.03 165 / 0.75); }

.joinbar__btn {
  font: inherit;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  color: var(--pop-cream);
  background: var(--pop-pine);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 1.1rem;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
}

.joinbar__done {
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--ink-onbrass);
}

/* Focus has to be visible on brass, where the usual brass ring would vanish. */
.joinbar__input:focus-visible,
.joinbar__btn:focus-visible {
  outline: 2px solid var(--pop-pine);
  outline-offset: 2px;
}

@media (max-width: 620px) {
  /* The line of copy is the first thing to go: on a phone the bar has room for
     the ask and nothing else. */
  .joinbar__say { display: none; }
  /* min-width:0 on the form as well as the input. The input's own min-width:0
     lets IT shrink, but the form is a flex item too, and with min-width:auto its
     floor is its min-content: the input's ~224px intrinsic width plus the
     button. At 320px that floor is 304px inside a 280px content box, and the
     bar overflowed the viewport by 4px. */
  .joinbar__form { flex: 1; min-width: 0; }
  .joinbar__inner { padding-inline: var(--gap-close); }

  /* min-width:0 is the whole fix. A flex item will not shrink below its
     intrinsic minimum, and an <input> without a size attribute reports about
     224px. With a 184px nowrap button beside it the row measured 436px inside
     a 360px bar at 375px wide, and the button read "JOIN THE WAI". */
  .joinbar__input { width: auto; flex: 1; min-width: 0; max-width: none; }

  /* The label shortens to "Join". Hidden rather than removed, so the button's
     accessible name stays the full "Join the waitlist". */
  .joinbar__btn-long {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .joinbar { transition: none; }
}

/* ==========================================================================
   The preloader

   A curtain over the hero while the poster and the two faces land. The page
   underneath is fully built the whole time — this only delays seeing it, never
   assembling it, so every failure mode ends with the curtain simply lifting.
   ========================================================================== */

.preloader { display: none; }

/* Only ever shown by the head script, which decides before first paint. No JS,
   reduced motion, or a back/forward restore all mean the class is never added
   and this stays display:none — there is no curtain to get stuck behind.

   .is-gone is on this selector too, and has to be. js/preload.js drops
   .is-loading from <html> and adds .is-gone to this element on the same frame,
   so with the display hanging on .is-loading alone the curtain went display:none
   at the exact moment its fade was meant to begin. The 720ms dissolve below had
   never once played: the curtain hard-cut to the hero, which is the whole thing
   the match cut is built to avoid — the ground has to fade OFF the mark, not
   blink off it. */
.is-loading .preloader,
.preloader.is-gone {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--ground-deep);
  display: grid;
  place-items: center;
  opacity: 1;
  transition: opacity var(--dur-slow) var(--ease-out);
}

/* The lift is the ground leaving, and nothing else. The mark used to scale up
   and fade out on its way — a gesture that only made sense while the curtain
   showed a different mark from the one underneath it. Now they are the same
   lockup in the same box, so anything the mark does here is something the
   visitor watches the brand do twice. It holds, the ground goes, and what is
   left behind it is identical. */
.is-loading .preloader.is-gone,
.preloader.is-gone {
  opacity: 0;
  pointer-events: none;
  transition: opacity 720ms var(--ease-out-quart) 140ms;
}

.preloader__inner {
  display: grid;
  justify-items: center;
}

/* The lockup, used as a mask rather than an image, so the shape can be lit
   from the inside. Two layers sit behind it: a ghost that holds the outline
   before anything has happened, and a fill that rises through it.

   Unplaced, it is centred at its own size — the state this loader shipped with,
   and the one it falls back to if the measurement never lands. */
.preloader__mark {
  position: relative;
  display: block;
  width: clamp(132px, 18vmin, 186px);
  aspect-ratio: 1083 / 1250.78;     /* the primary lockup's own proportion */

  /* Fallback first: without mask support this is simply the lockup, sitting
     still. The alternative failure is a cream rectangle, which is worse than
     no animation at all. */
  background: url("../assets/logo_primary.svg") center / contain no-repeat;
}

/* Placed: the hero lockup's exact box, measured by the script under the hero.
   Positioned by transform rather than by top/left so it costs no layout.

   The transition is held behind .pl-smooth, which js/preload.js adds on the
   frame AFTER it has placed the mark. Unguarded it made the lockup arrive from
   the top-left corner of the screen: the element goes from `transform: none` to
   a translate, and a transition between those two runs from the origin — which,
   at top: 0 left: 0, is the corner. So the first thing the visitor saw was the
   mark sweeping in from the side, the one gesture this whole arrangement exists
   to avoid.

   It still earns its place afterwards. The parse-time measurement is taken
   against a document that is one <header> long: no scrollbar yet, and the
   layout viewport still settling. Both move the hero lockup by a handful of
   pixels once the rest of the page exists, and a correction that glides reads
   as the composition settling where one that snaps reads as a glitch. */
.preloader.is-placed .preloader__inner {
  position: absolute;
  inset: 0;
  display: block;
}
.preloader.is-placed .preloader__mark {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pl-w);
  height: var(--pl-h);
  aspect-ratio: auto;
  transform: translate3d(var(--pl-x), var(--pl-y), 0);
}
.preloader.is-placed.pl-smooth .preloader__mark {
  transition: transform 320ms var(--ease-out-quart);
}

.preloader__ghost,
.preloader__fill {
  display: none;
}

@supports (mask-image: url("../assets/logo_primary.svg")) or
          (-webkit-mask-image: url("../assets/logo_primary.svg")) {
  .preloader__mark {
    background: none;
    -webkit-mask-image: url("../assets/logo_primary.svg");
            mask-image: url("../assets/logo_primary.svg");
    -webkit-mask-size: contain;
            mask-size: contain;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
  }

  .preloader__ghost,
  .preloader__fill {
    display: block;
    position: absolute;
    inset: 0;
  }
}

/* Faint enough to read as an outline waiting to be filled, bright enough to
   be the only thing on the screen. */
.preloader__ghost {
  background: var(--pop-cream);
  opacity: 0.15;
}

/* Cream rising, with a brass line riding its surface: the same two colours the
   page is built from, doing the one job a loading bar used to do. */
.preloader__fill {
  background: linear-gradient(
    to bottom,
    var(--pop-brass) 0 2px,
    var(--pop-cream) 2px
  );
  transform: translateY(100%);
  animation: preload-rise 2500ms var(--ease-out-quart) forwards;
}

/* 2500ms is the curtain's own ceiling, and the curve is what makes that honest
   rather than slow: on an exponential ease-out the fill is 83% of the way up
   by 900ms, which is the earliest the curtain will ever lift.

   It no longer leaves at 83%, though. Whatever the fill has reached when the
   open signal arrives, js/preload.js runs it to the top over 240ms and only
   then starts the ground fading. A gesture that completes before it goes reads
   as resolved; one that vanishes mid-stroke reads as interrupted. The run-out
   goes 3px past the top so the brass line rides off the edge under the mask
   rather than parking on the crown of the mark. */
@keyframes preload-rise { to { transform: translateY(0); } }

/* While the curtain is up the page must not scroll behind it. */
.is-loading body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .preloader { display: none; }
}

/* ==========================================================================
   Short and wide

   Landscape phones, and a browser sharing a laptop screen with something else.
   A 100svh stage becomes a letterbox, and the bottom-anchored stack the tall
   layout uses stops fitting in it. Measured on an 844x390 phone: 326px of type
   trying to sit in a 303px box, with the recovery chapter overflowing outright.

   Scaling the type down would answer the symptom. The composition is what is
   wrong: a wide short frame wants its words held to one side, not spread along
   the bottom. So the chapter borrows the hero's own logic, which was built for
   exactly this shape — type anchored left, footage breathing to the right, the
   scrim turned through ninety degrees to follow it.
   ========================================================================== */

@media (max-height: 560px) and (min-width: 621px) {
  .chapter__stage { align-content: center; }

  .chapter__say {
    max-width: min(56%, 40rem);
    /* The base rule centres the block inside --shell. Narrowing it without
       clearing that centres the words in the middle of the frame, which is
       exactly where the scrim has faded out and the plate is brightest — the
       note became unreadable. Anchor it to the dark edge instead. */
    margin-inline: 0;
    padding-block: var(--gap-close);
  }

  /* Driven by height rather than width: on this shape the short axis is what
     runs out. --fs-hero is left alone so the hero keeps the size it ships at. */
  .chapter__title { font-size: clamp(1.75rem, 8.5svh, 3.4rem); }

  .chapter__label { margin-bottom: var(--gap-hair); }

  .chapter__note {
    font-size: var(--fs-small);
    margin-top: var(--gap-tight);
    max-width: 44ch;
  }

  /* The scrim follows the type: heavy at the left edge, clearing to the right
     so the plate still has somewhere to be seen. */
  .chapter__scrim {
    background:
      linear-gradient(to right,
        oklch(var(--scrim-ink) / 0.95) 0%,
        oklch(var(--scrim-ink) / 0.82) 32%,
        oklch(var(--scrim-ink) / 0.34) 62%,
        oklch(var(--scrim-ink) / 0) 88%),
      linear-gradient(oklch(var(--scrim-ink) / 0.20), oklch(var(--scrim-ink) / 0.20));
  }

  /* The plan has width to spare here and no height at all, so it takes the
     two-column arrangement early rather than stacking a square drawing under
     the words in a letterbox. */
  .chapter--plan .chapter__stage {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
  }
  .chapter--plan .chapter__say {
    grid-column: 1;
    grid-row: 1;
    padding-block: var(--gap-hair);
  }
  /* The plan carries the longest note of any chapter, and here it has the
     narrowest column to put it in. It gets a tighter measure than the rest. */
  .chapter--plan .chapter__note { max-width: 30ch; margin-top: var(--gap-hair); }
  .chapter--plan .chapter__title { font-size: clamp(1.5rem, 7svh, 2.8rem); }
  .plan {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    padding: var(--gap-close) var(--gutter) var(--gap-close) 0;
  }

  /* 72px of fixed bar is 18% of a 390px viewport, so it gives some back — but
     only from its padding. The 44px targets stay: a landscape phone is still a
     phone, and PRODUCT.md sets that floor for phones, not for portrait ones. */
  .joinbar__inner { padding-block: var(--gap-hair); }
}


/* --------------------------------------------------------------------------
   The plan on a phone

   The drawing is authored in a 1000-unit square and renders about 320px wide
   on a 390px screen, a scale of 0.32. At that scale the court numbers came out
   at 6.7px and the room labels at 4.2px: the one bespoke, un-liftable asset on
   the page, illegible on the device most people use.

   The room labels go (the SVG is aria-hidden, so nothing is lost to a screen
   reader, and twelve numbered courts carry the idea on their own). The numbers
   roughly double, and the drawing takes back the gutter it was paying.
   -------------------------------------------------------------------------- */

@media (max-width: 620px) {
  .plan { padding-inline: var(--gap-close); }
  .plan__num { font-size: 38px; }
  /* The word is 11 characters. Scaled to fit a 250-unit court at a size that
     survives a phone it would run wider than the court it names, so on a narrow
     screen the drawing keeps the highlight and the note keeps the meaning. The
     room labels go for the same reason. */
  .plan__label,
  .plan__tag { display: none; }
}

/* ==========================================================================
   The gallery

   A horizontal rail driven by vertical scroll. The runway is a chapter like
   any other, so it inherits the view timeline, the pin, and --px running 0 to
   1 across the pinned window. The only new idea is what the track does with
   that number: it reads it as translateX instead of a scale or a fade.

   Four plates, each exactly one viewport wide, so the track is 400% and the
   travel is -75% of itself, which lands the fourth plate flush.

   No captions and no controls. The scroll gesture is the control, which is
   why this replaced a carousel with six of them.
   ========================================================================== */

.chapter--gallery {
  height: var(--pin-gallery);

  /* Its own placeholder. It inherited the chapters' `contain-intrinsic-size:
     auto var(--pin-long)`, so while its contents were skipped it claimed
     2026px against a real 3123px runway: an 1100px lie that the scrollbar has
     to reconcile the moment you approach it. */
  contain-intrinsic-size: auto var(--pin-gallery);
}

/* The stage stacks layers rather than aligning content to the bottom, and it
   must not inherit the chapters' grid. */
.chapter--gallery .chapter__stage {
  display: block;
  background: var(--ground-base);
}

.gallery__track {
  position: absolute;
  inset: 0;
  display: flex;
  width: 400%;                       /* four plates, one viewport each */
  will-change: transform;
}

.gallery__plate {
  flex: 0 0 25%;                     /* one quarter of the track = one screen */
  position: relative;
  overflow: hidden;
}

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

@media (prefers-reduced-motion: no-preference) {
  /* -75% of a 400% track is three screens: plate four ends flush with the
     right edge, with no overscroll past the last image. */
  .gallery__track {
    transform: translateX(calc(clamp(0, calc(var(--px) / var(--px-hold-gallery)), 1) * -75%));
  }
}

/* The bottom strip carries the disclaimer and the rail, and it sits over
   whichever plate happens to be passing. Some of them are bright enough that
   the note measured 1.43:1 against them, which a text-shadow cannot rescue —
   a shadow softens an edge, it does not make a ground. So the strip gets a
   real one: the same scrim ink the chapters use, ramped so it is a hem rather
   than a bar. The note can then be a solid colour instead of a ghost. */
.chapter--gallery .chapter__stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(clamp(96px, 16svh, 168px) + var(--joinbar-h, 0px));
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to top,
    oklch(var(--scrim-ink) / 0.82) 0%,
    oklch(var(--scrim-ink) / 0.52) 42%,
    oklch(var(--scrim-ink) / 0) 100%
  );
}

/* The disclaimer gets its own ground rather than floating on the picture.
   Measured, not assumed: the bottom-right strip of every render is blown to
   white in its top 1% of pixels — light fittings, glazing, downlights — so a
   gradient hem at 50% left this at 1.18:1 and the text-shadow it had before
   was 1.75:1. A caption needs a surface. At 0.94 the chip holds 6.22:1 over
   the worst plate and 12.4:1 over the darkest, so it reads the same wherever
   the rail happens to have stopped. --ink-muted cannot do this job at any
   alpha worth using: it sits at mid-tone, which is the worst place to be when
   the backdrop moves. */
.gallery__note {
  position: absolute;
  right: var(--gutter);
  bottom: calc(var(--gap-step) + 14px);
  z-index: 2;
  padding: 0.4em 0.75em;
  border-radius: var(--radius-sm);
  background: oklch(var(--scrim-ink) / 0.94);
  font-size: var(--fs-label);
  color: var(--ink-body);
  transform: translateY(calc(-1 * var(--joinbar-h, 0px)));
  transition: transform var(--dur-base) var(--ease-out);
}

/* How much gallery is left. A line, not a widget: nothing to aim at, nothing
   to click, it just says where you are. */
.gallery__rail {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--gap-step);
  z-index: 2;
  height: 2px;
  background: oklch(0.95 0.01 92 / 0.22);
  overflow: hidden;
  transform: translateY(calc(-1 * var(--joinbar-h, 0px)));
  transition: transform var(--dur-base) var(--ease-out);
}

.gallery__rail-fill {
  display: block;
  height: 100%;
  background: var(--pop-lime);       /* position, matching the page rule */
  transform: scaleX(0.25);           /* one plate of four, before any scroll */
  transform-origin: left;
}

@media (prefers-reduced-motion: no-preference) {
  .gallery__rail-fill {
    /* The same hold as the track. On raw --px the rail would read full while
       the strip was still moving, which is the one thing a progress indicator
       must never do. */
    transform: scaleX(calc(0.25 + clamp(0, calc(var(--px) / var(--px-hold-gallery)), 1) * 0.75));
  }
}

/* --------------------------------------------------------------------------
   When the rail cannot run

   Reduced motion, or no JavaScript on a browser without scroll timelines. In
   both cases --px never travels, and a track parked at 0 would show plate one
   and hide the other three. So the rail stops being a rail: it unpins and
   becomes four stacked pictures, which is the same content in the order it was
   always in.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  /* Stacked, so there is no runway to predict and the placeholder must stop
     predicting one. */
  .chapter--gallery {
    height: auto;
    content-visibility: visible;
    contain-intrinsic-size: auto;
  }
  .chapter--gallery .chapter__stage { position: static; height: auto; overflow: visible; }
  .gallery__track { position: static; display: block; width: 100%; transform: none; }
  .gallery__plate { height: 78svh; }
  .chapter--gallery .chapter__stage::after { content: none; }
  .gallery__note { position: static; background: none; transform: none; padding: var(--gap-tight) var(--gutter); }
  .gallery__rail { display: none; }
}

html:not(.js) .chapter--gallery {
  height: auto;
  content-visibility: visible;
  contain-intrinsic-size: auto;
}
html:not(.js) .chapter--gallery .chapter__stage { position: static; height: auto; overflow: visible; }
html:not(.js) .chapter--gallery .chapter__stage::after { content: none; }
html:not(.js) .gallery__note { position: static; background: none; transform: none; padding: var(--gap-tight) var(--gutter); }
html:not(.js) .gallery__track { position: static; display: block; width: 100%; transform: none; }
html:not(.js) .gallery__plate { height: 78svh; }
html:not(.js) .gallery__rail { display: none; }
