/* Dominia — section 002, how it works: the core loop on one pinned board.

   THE MAP IS PINNED AND THE WORDS SCROLL. Each step is a card in normal page flow that moves up
   over the board, so nothing fades out before it is read and a fast scroller still passes every
   sentence. js/how.js plays each step on its own clock when its card crosses a trigger line, so
   scroll speed decides WHICH step you are on, never how much of it you see.

   This replaced the horizontal four-plate travel (css/travel.css, js/travel.js) on 2026-09-27.
   The travel was a set of assertions about the board; this teaches the loop to someone who has
   never heard of the game: your city divided, pick, walk anywhere, it's yours, defend it, team up,
   then a recap card. Iterated in assets/art/how-story-lab.html, which now loads these same files.

   Loaded after chrome.css: the state rules below must beat carto.css's `.on-plate` rules at equal
   specificity, and nothing between them and mobile.css touches this section. */

.sl { position: relative; background: var(--ink); --nav-h: 53px; }

/* The stage is pinned for the whole section; the steps are pulled up over it by one screen, so
   they scroll across a board that holds still. */
.sl-stage { position: sticky; top: 0; height: 100svh; overflow: hidden; }
.sl-steps { position: relative; z-index: 4; margin-top: -100svh; pointer-events: none; }

/* ---------------------------------------------------------------- the board
   Two layers, as on every board drawn over the satellite: the plate on a pseudo-element so its
   grade cannot reach the territories, the vector board above it. Size and position are solved
   from the live viewBox by js/how.js every frame, so the camera moves both together. */
.sl-view { position: absolute; inset: 0; }
.sl-view::before {
  content: ""; position: absolute; inset: 0;
  background-image: url("../assets/img/board-satellite.jpg");
  background-repeat: no-repeat;
  background-size: var(--plate-size, 100%) auto;
  background-position: var(--plate-x, 50%) var(--plate-y, 50%);
  filter: saturate(0.30) contrast(1.06) brightness(0.5);
}
.sl-view svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Step one: the grid is the subject, so it comes up brighter than it sits on the plate... */
.sl-view .territory[data-state="unclaimed"] {
  stroke: rgba(239, 235, 225, calc(0.26 + var(--grid-lift, 0) * 0.5));
  stroke-width: calc(0.65px + var(--grid-lift, 0) * 0.75px);
  /* Round joins: a few blocks have very acute corners, and at this width a mitre join there
     spikes out into a long bright wedge. */
  stroke-linejoin: round;
}
/* ...and the roads step back while it does, so the cells read as the structure. */
.sl-view.on-plate .cartography .road { opacity: calc(0.9 - var(--grid-lift, 0) * 0.6); }

/* Two states the game board does not have, because they only exist to explain it.
   picked  — the block you chose, outlined and nothing more.
   walking — the block filling as the distance comes in: the fill IS the progress, so the effort
             shows up on the map without anything saying where you are. */
.on-plate .territory[data-state="picked"] { fill: none; stroke: var(--bone); stroke-width: 2px; }
.on-plate .territory[data-state="walking"] {
  fill: color-mix(in srgb, var(--claim) calc(var(--walk, 0) * var(--fill-claim)), transparent);
  stroke: var(--claim);
  stroke-width: 1.6px;
}

/* The hero's scrim, so the card column reads over terrain and the board stays the subject. */
.sl-scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, color-mix(in srgb, var(--ink) 92%, transparent) 0,
                              color-mix(in srgb, var(--ink) 62%, transparent) 30%,
                              transparent 56%),
    linear-gradient(to top,    color-mix(in srgb, var(--ink) 70%, transparent) 0, transparent 30%),
    linear-gradient(to bottom, color-mix(in srgb, var(--ink) 70%, transparent) 0, transparent 18%);
}

/* ---------------------------------------------------------------- the readout on the board
   Hangs under the one named block and carries the one number each step is about. */
.sl-tag {
  position: absolute; z-index: 3;
  width: 232px;
  transform: translate(-50%, 0);
  background: color-mix(in srgb, var(--ink-2) 92%, transparent);
  border: 1px solid var(--hairline-strong);
  pointer-events: none;
  transition: opacity var(--dur-ui) var(--ease);
}
.sl-tag[hidden] { display: block; opacity: 0; }
.sl-tag .window__bar { color: var(--bone); gap: var(--s-2); padding: var(--s-2) var(--s-3); }
.sl-tag__body { display: grid; gap: var(--s-2); padding: var(--s-3); }
.sl-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); margin: 0; }
.sl-row .label { color: var(--slate); white-space: nowrap; }
.sl-row .data { white-space: nowrap; }
.sl-row .data small { font-size: var(--t-label-sm); color: var(--slate); margin-left: 2px; }
.sl-meter { display: block; height: 3px; background: var(--ink-3); }
.sl-meter i { display: block; height: 100%; width: 0; background: var(--claim-lit); }
.sl-meter--time i { background: var(--slate); }
.sl-lit { text-shadow: var(--g2-bone); }   /* G2: the step's one live number */
.sl-row--gap { margin-top: var(--s-1); }

/* ---------------------------------------------------------------- the chrome over the cards
   Fixed rather than inside the pinned stage: the stage is a stacking context below the cards, so
   anything in it would be painted over as a card went by. Shown only while the section holds the
   screen (js/how.js sets .is-pinned). Below the nav, which sits at z-index 50. */
.sl-chrome {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur-ui) var(--ease), visibility 0s linear var(--dur-ui);
}
.sl.is-pinned .sl-chrome {
  opacity: 1; visibility: visible;
  transition: opacity var(--dur-ui) var(--ease), visibility 0s;
}
/* A band at the top that cards slide under, so the label never sits on moving text. */
.sl-chrome::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0;
  height: calc(var(--nav-h) + var(--s-8) + var(--s-24));
  background: linear-gradient(to bottom, var(--ink) 66%, transparent);
}
.sl-label {
  position: absolute;
  top: calc(var(--nav-h) + var(--s-8));
  left: var(--page-margin); right: var(--page-margin);
}

/* ---- the loop strip: where you are in the loop, and a way back to any step ---- */
.sl-loop {
  position: absolute;
  right: var(--page-margin); bottom: var(--s-8);
  width: 440px;
  padding: var(--s-4) var(--s-4) var(--s-3);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  border: 1px solid var(--hairline);
  pointer-events: auto;
}
.sl-loop ol {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 0; padding: 0; list-style: none;
}
.sl-loop a {
  display: grid; gap: var(--s-2); padding-right: var(--s-2);
  color: var(--slate); text-decoration: none;
}
.sl-loop a::before {
  content: ""; height: 2px; background: var(--hairline-strong);
  transition: background var(--dur-ui) var(--ease);
}
.sl-loop a:hover, .sl-loop a:focus-visible { color: var(--bone); }
.sl-loop li.is-past a::before, .sl-loop li.is-on a::before { background: var(--signal); }
.sl-loop li.is-on a { color: var(--bone); }

/* The return, from under "Defend it" back to under "Walk": holding ground means walking again. */
.sl-back {
  position: relative; height: 14px; margin: var(--s-2) 0 var(--s-2);
  margin-left: calc(25% + 10px); width: 50%;
  border: 1px solid var(--hairline-strong); border-top: 0;
  transition: border-color var(--dur-ui) var(--ease);
}
.sl-back::before {   /* the arrowhead, pointing up into Walk */
  content: ""; position: absolute; left: -5px; top: -6px;
  border: 4px solid transparent; border-bottom: 6px solid var(--hairline-strong); border-top: 0;
  transition: border-color var(--dur-ui) var(--ease);
}
.sl-back span {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  padding: 0 var(--s-2); background: var(--ink-2); color: var(--slate); line-height: 1;
}
.sl-back.is-on { border-color: var(--signal); }
.sl-back.is-on::before { border-bottom-color: var(--signal); }
.sl-back.is-on span { color: var(--bone); }

/* ---------------------------------------------------------------- the cards
   Bare text on the scrim on desktop, the way the section has always set its copy. Each step is
   most of a screen tall so only one card is ever in view. */
.sl-step {
  min-height: 78svh;
  display: flex; align-items: center;
  padding: 0 var(--page-margin);
}
.sl-step:first-child,
.sl-step:last-child { min-height: 100svh; }
.sl-card { width: 400px; max-width: 40%; pointer-events: auto; }
.sl-card .scene__index { margin: 0 0 var(--s-4); font-size: var(--t-title); }
.sl-card .body { margin: 0; max-width: 21em; }
.sl-card__n { display: block; margin-bottom: var(--s-3); color: var(--slate); }

/* The recap: the loop written out once, for anyone who went past the steps at speed. */
.sl-recap { display: grid; gap: var(--s-4); margin: var(--s-6) 0 0; padding: 0; list-style: none; }
.sl-recap li {
  display: grid; grid-template-columns: 96px 1fr; gap: var(--s-3); align-items: baseline;
  padding-top: var(--s-4); border-top: 1px solid var(--hairline-strong);
}
.sl-recap .label { color: var(--signal); }
.sl-recap .body { font-size: var(--t-body); color: var(--bone-2); }
.sl-recap li:last-child .label { color: var(--slate); }

/* ---------------------------------------------------------------- phone
   The board holds the top, cards scroll up through the bottom, and the label and the loop share
   one solid header under the nav: a see-through strip let a passing card's words show through. */
@media (max-width: 759px) {
  .sl-scrim {
    background:
      linear-gradient(to top, color-mix(in srgb, var(--ink) 92%, transparent) 0, transparent 40%),
      linear-gradient(to bottom, color-mix(in srgb, var(--ink) 70%, transparent) 0, transparent 18%);
  }
  .sl-chrome::before {
    height: calc(var(--nav-h) + var(--s-4) + var(--s-6) + 88px + var(--s-4));
    background: linear-gradient(to bottom, var(--ink) 84%, transparent);
  }
  .sl-label { top: calc(var(--nav-h) + var(--s-4)); }
  .sl-loop {
    left: var(--page-margin); right: var(--page-margin); width: auto;
    top: calc(var(--nav-h) + var(--s-4) + var(--s-6)); bottom: auto;
    padding: var(--s-3) var(--s-3) var(--s-2);
    background: var(--ink-2);
  }
  .sl-loop a { letter-spacing: 0.04em; white-space: nowrap; }

  /* Cards carry their own ground on a phone: they cross the whole board, not a scrim. */
  .sl-step { align-items: flex-end; min-height: 86svh; padding-bottom: 8svh; }
  .sl-step:first-child,
  .sl-step:last-child { min-height: 100svh; }
  .sl-card {
    width: 100%; max-width: none;
    padding: var(--s-4);
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
  }
  .sl-card .scene__index { font-size: var(--t-body-lg); margin-bottom: var(--s-3); }
  .sl-recap li { grid-template-columns: 84px 1fr; }
  .sl-tag { width: 200px; }
}
