/* Kete by the numbers.
   Tokens copied from the Kete of Knowledge app (apps/web/src/styles/tokens.css, DESIGN.md sections 15 and 16).
   Light Te Taiao only. Never follows the OS dark preference. */
:root {
  color-scheme: light only;

  --deep: #1F3D2B;
  --forest: #2D5A3D;
  --moss: #4A7856;
  --leaf: #6B9B76;
  --river: #3A6B7A;
  --sky: #7FA8B3;
  --brown: #7A5C3E;
  --bark: #4A3826;
  --gold: #C08A2E;

  --tint-green: #E8F0E6;
  --tint-green-deep: #DCE8D6;
  --tint-clay: #F2DED7;
  --tint-sand: #F6E9C8;
  --tint-sky: #DEE9EC;
  --tint-bark: #EDE3D6;

  --bg: #FFFFFF;
  --ink: var(--deep);
  --muted: #59685C;
  --edge: rgba(31, 61, 43, .11);
  --divider: rgba(31, 61, 43, .07);
  --track: rgba(31, 61, 43, .14);

  --font-display: "Young Serif", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r-sm: 12px; --r-md: 20px; --r-lg: 28px; --r-pill: 999px;
  --shadow-card: 0 1px 2px rgba(31,61,43,.04), 0 4px 12px rgba(31,61,43,.05);

  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --gutter: max(20px, 4vw);
}

/* Scale up on big screens: 16px at 1440 wide, growing to 22px at 2560. Phones stay at 16px. */
html {
  font-size: clamp(16px, calc(0.5357vw + 8.29px), 22px);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; letter-spacing: -0.005em; }
p { margin: 0; text-wrap: pretty; }
.row__label, .big__label, .stat__label { text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--deep); color: #fff; padding: .75rem 1.25rem; border-radius: var(--r-pill);
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 1rem; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Centred container: up to about 1680px at 1920 wide, scaling with the type on bigger screens. */
.wrap {
  width: 100%;
  max-width: 90rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.kicker {
  display: inline-flex; align-items: center; gap: .6em;
  font: 600 1rem/1.3 var(--font-body);
  color: var(--forest);
  letter-spacing: .01em;
}
.kicker::before {
  content: ""; width: .7em; height: .7em; border-radius: 3px; background: var(--leaf);
  flex: none;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.hero__tiles { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero__inner {
  position: relative;
  text-align: center;
  padding-bottom: 7vh;
  display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
  pointer-events: none;
}
.hero__title { font-size: 4.25rem; line-height: 1.06; text-wrap: balance; }
.hero__title-sub { display: block; font-size: .72em; line-height: 1.15; color: var(--forest); margin-top: .12em; }
.hero__lead { font-size: 1.5rem; line-height: 1.45; color: var(--ink); }
.hero__cue {
  margin-top: 1.5rem;
  display: inline-flex; align-items: center; gap: .7em;
  font: 600 1rem/1.3 var(--font-body); color: var(--forest);
}
.cue-tile {
  width: .8em; height: .8em; border-radius: 3px; background: var(--forest);
  animation: cue 1.6s var(--ease-out) infinite;
}
@keyframes cue { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(.45em); opacity: .35; } }

/* ---------- Story: one stage, many beats ---------- */
.story {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  column-gap: 3.5rem;
}
.stage {
  grid-column: 2; grid-row: 1;
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  align-self: start;
}
.stage__tiles { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage__cord { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.stage__screen {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  overflow: hidden;
  border-radius: 18px;
  pointer-events: none;
  container-type: inline-size;
}
/* The app's opening, as AppOpening draws it: the woven mark, then the name, on white. */
.opening { position: absolute; inset: 0; background: var(--bg); opacity: 0; }
.opening.is-on { opacity: 1; }
.js-motion .opening.is-on { animation: flick 420ms steps(1, end); }
.opening__mark { position: absolute; left: 23.077cqw; top: 64.154cqw; width: 53.846cqw; }
.opening__mark svg { display: block; width: 100%; height: auto; overflow: visible; }
.kete-mark .km-glow { transform-box: fill-box; transform-origin: center; }
.kete-mark .km-thread { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.kete-mark .km-sheen { mix-blend-mode: soft-light; }
.opening__name {
  position: absolute; left: 0; right: 0; top: 119.2cqw; margin: 0;
  color: var(--deep); font: 400 7.18cqw/8.72cqw var(--font-display);
  text-align: center; white-space: nowrap;
}
.opening__name > span { display: inline-block; }
.opening__name > span + span { margin-left: .26em; }
.stage__screen img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
  opacity: 0;
}
.stage__screen img.is-on { opacity: 1; }

/* The check run: tiles draw the window, the run types itself inside. */
.stage__term {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  display: flex; flex-direction: column; gap: .9em;
  padding: 1.1em 1.4em;
  font: 500 var(--term-fs, 16px)/1.45 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--deep);
  background: var(--bg);
  white-space: nowrap;
  overflow: hidden;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
}
.stage__term.is-on { opacity: 1; }
.js-motion .stage__term.is-on { animation: flick 420ms steps(1, end); }
.term__head { display: flex; align-items: center; gap: .6em; font-weight: 600; color: var(--forest); }
.term__dot { width: .65em; height: .65em; border-radius: 3px; background: var(--leaf); }
.term__lines { display: flex; flex-direction: column; gap: .35em; flex: 1; }
.term__lines li { display: flex; align-items: baseline; gap: .7em; opacity: 0; white-space: nowrap; }
.term__lines li::before { content: ""; width: .55em; height: .55em; border-radius: 2px; background: var(--track); flex: none; transform: translateY(-.05em); }
.term__lines li.is-run { opacity: 1; }
.term__lines li.is-pass::before { background: var(--forest); }
.term__lines li.is-pass::after { content: "passed"; margin-left: auto; color: var(--forest); font-weight: 600; }
.term__foot { border-top: 1px solid var(--divider); padding-top: .7em; font-weight: 600; }
.term__count { font-family: var(--font-display); font-weight: 400; font-size: 1.6em; color: var(--forest); margin-right: .2em; }
.js-motion .stage__screen img.is-on { animation: flick 420ms steps(1, end); }
.beats { grid-column: 1; grid-row: 1; }
/* Each beat is more than two screens of scroll; its words stay put while the tiles change. */
.beat { min-height: 220vh; }
.beat__body {
  position: sticky; top: 0;
  min-height: 100vh; min-height: 100svh;
  width: 100%;
  display: flex; flex-direction: column; justify-content: center; gap: 1.5rem;
  padding-block: 8vh;
}
.beat h2 { font-size: 2.75rem; line-height: 1.12; color: var(--deep); }
.beat__text { font-size: 1.3125rem; line-height: 1.55; }

.big { display: flex; flex-direction: column; gap: .35rem; }
.big__num {
  font-family: var(--font-display);
  font-size: 6.5rem; line-height: 1;
  color: var(--forest);
  font-variant-numeric: tabular-nums lining-nums;
}
.big__unit { font-size: .32em; margin-left: .35em; color: var(--deep); vertical-align: .35em; }
.big__label { font-size: 1.375rem; line-height: 1.45; }
.pair { display: flex; flex-direction: column; gap: 1.75rem; }
.pair .big__num { font-size: 5.5rem; }

.rows { display: flex; flex-direction: column; }
/* Hairline divided rows: the text keeps a clear 16px or more from every rule line. */
.row {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1.25rem;
  align-items: baseline;
  padding: 1.25rem 0 1.125rem;
  border-top: 1px solid var(--divider);
}
.row:last-child { border-bottom: 1px solid var(--divider); }
.row__num {
  font-family: var(--font-display);
  font-size: 1.875rem; line-height: 1.1; color: var(--deep);
  font-variant-numeric: tabular-nums lining-nums;
}
.row__label { font-size: 1.0625rem; line-height: 1.5; }

.bar { display: block; height: .5rem; margin-top: .6rem; border-radius: var(--r-pill); background: var(--divider); overflow: hidden; }
.bar__fill { display: block; height: 100%; width: var(--w); border-radius: inherit; transform-origin: left center; }
.bar__fill--written { background: var(--forest); }
.bar__fill--removed { background: var(--brown); }

.guards { display: flex; flex-direction: column; gap: .85rem; }
.guards li { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); gap: .9rem; align-items: baseline; font-size: 1.1875rem; line-height: 1.5; text-wrap: pretty; }
.guards li::before { content: ""; width: .8rem; height: .8rem; border-radius: 3px; background: var(--forest); transform: translateY(.05em); }
.dates { display: flex; flex-wrap: wrap; gap: .75rem 2rem; font-size: 1.125rem; }
.dates__item strong { font-weight: 600; color: var(--forest); margin-right: .4em; }

.key { white-space: nowrap; font-weight: 600; }
.key::before {
  content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 3px;
  margin-right: .35em; vertical-align: .05em;
}
.key--brown::before { background: var(--brown); }
.key--river::before { background: var(--river); }
.key--gold::before { background: var(--gold); }

/* Text rises in as it reaches the reading line (DESIGN.md section 11 scroll reveal: 520ms, 18px). */
.js-motion .reveal { opacity: 0; transform: translateY(18px); transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out); }
.js-motion .reveal.is-in { opacity: 1; transform: none; }

/* ---------- Full width bands ---------- */
.band { padding-block: 9rem 6rem; }
.band__title { font-size: 3.25rem; line-height: 1.1; text-align: center; text-wrap: balance; }
.band__title--small { font-size: 2.25rem; }
.band__lead { margin-top: 1rem; font-size: 1.375rem; text-align: center; }

/* Timeline rail */
.rail {
  --n: 11;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  margin-top: 4.5rem;
  height: 12rem;
}
.rail::before, .rail::after {
  content: ""; position: absolute; left: calc(50% / var(--n)); right: calc(50% / var(--n));
  top: 50%; height: 4px; margin-top: -2px; border-radius: var(--r-pill);
}
.rail::before { background: var(--track); }
.rail::after { background: var(--forest); transform-origin: left center; transform: scaleX(var(--p, 1)); }
.stop { position: relative; display: flex; flex-direction: column; align-items: center; }
.stop__tile {
  position: absolute; top: 50%; left: 50%;
  width: 1.5rem; height: 1.5rem; margin: -.75rem 0 0 -.75rem;
  border-radius: 6px; background: var(--forest); z-index: 1;
  box-shadow: 0 0 0 5px var(--bg);
}
.stop__date, .stop__what { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; text-align: center; }
.stop__date { font: 600 1rem/1.2 var(--font-body); color: var(--forest); }
.stop__what { font: 400 1.0625rem/1.3 var(--font-body); }
.stop:nth-child(odd) .stop__date { bottom: calc(50% + 2.9rem); }
.stop:nth-child(odd) .stop__what { bottom: calc(50% + 1.4rem); }
.stop:nth-child(even) .stop__date { top: calc(50% + 1.4rem); }
.stop:nth-child(even) .stop__what { top: calc(50% + 2.9rem); }
.stop:first-child .stop__date, .stop:first-child .stop__what { left: 0; transform: none; text-align: left; }
.stop:last-child .stop__date, .stop:last-child .stop__what { left: auto; right: 0; transform: none; text-align: right; }
.js-motion .stop__tile { background: var(--tint-green-deep); transition: background-color 140ms linear; }
.js-motion .stop.is-on .stop__tile { background: var(--forest); animation: flick 420ms steps(1, end); }
@keyframes flick { 0% { opacity: 1; } 20% { opacity: .25; } 40% { opacity: 1; } 60% { opacity: .4; } 80%, 100% { opacity: 1; } }

/* Whole picture grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 4rem;
}
.stat {
  --tint: var(--tint-green);
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 2rem 2.25rem 2.25rem;
  min-height: 12rem;
  display: flex; flex-direction: column; justify-content: flex-end; gap: .6rem;
  background: var(--tint);
  box-shadow: var(--shadow-card);
}
.stat--wide { grid-column: 1 / -1; }
.stat:nth-child(4n + 2) { --tint: var(--tint-clay); }
.stat:nth-child(4n + 3) { --tint: var(--tint-sand); }
.stat:nth-child(4n + 4) { --tint: var(--tint-sky); }
.js-motion .stat { background: color-mix(in srgb, var(--tint) calc(var(--solid, 1) * 100%), transparent); box-shadow: none; }
.js-motion .stat.is-solid { box-shadow: var(--shadow-card); }
.stat canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.stat__num, .stat__label { position: relative; }
.stat__num {
  font-family: var(--font-display);
  font-size: 3.5rem; line-height: 1.05; color: var(--deep);
  font-variant-numeric: tabular-nums lining-nums;
}
.stat__pre, .stat__unit { font-size: .5em; }
.stat__label { font-size: 1.125rem; line-height: 1.45; }

/* Ratio */
.ratio {
  margin-top: 7rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.75rem;
  text-align: center;
}
.ratio__title { font-size: 2.25rem; line-height: 1.2; text-wrap: balance; }
.ratio__body {
  width: 100%;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4rem; align-items: center;
  margin-top: 1.5rem; text-align: left;
}
.ratio__side { display: flex; flex-direction: column; gap: 2.25rem; }
.ratio__text { font-size: 1.3125rem; }

/* A diff, drawn in the app's colours: ten lines written, three later taken out. Decorative only. */
.diff {
  counter-reset: none;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 0;
  overflow: hidden;
}
.diff__line {
  --in: 0;
  display: grid; grid-template-columns: 3.25rem 1.75rem minmax(0, 1fr);
  align-items: center;
  height: 2.6rem;
  padding-right: 1.5rem;
  background: var(--tint-green);
  transition: background-color 140ms linear;
}
.diff__line + .diff__line { margin-top: 2px; }
.diff__no { text-align: right; padding-right: 1rem; font-size: .9375rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.diff__mark { font: 600 1.25rem/1 var(--font-body); color: var(--forest); text-align: center; }
.diff__mark::before { content: "+"; }
.diff__code { display: flex; gap: .55rem; padding-left: calc(var(--in) * 1.6rem); }
.diff__code i { display: block; height: .7rem; width: calc(var(--l) * 1.5rem); max-width: 40%; border-radius: var(--r-pill); background: var(--forest); }
.diff__code i.t2 { background: var(--river); }
.diff__code i.t3 { background: var(--gold); }
.diff__line--out { background: var(--tint-clay); }
.diff__line--out .diff__mark { color: var(--brown); }
.diff__line--out .diff__mark::before { content: "\2212"; }
.diff__line--out .diff__code i { background: var(--brown); opacity: .55; }
.js-motion .diff__line--out { background: var(--tint-green); }
.js-motion .diff__line--out .diff__mark { color: var(--forest); }
.js-motion .diff__line--out .diff__mark::before { content: "+"; }
.js-motion .diff__line--out .diff__code i { background: var(--forest); opacity: 1; }
.js-motion .diff__line--out .diff__code i.t2 { background: var(--river); }
.js-motion .diff__line--out .diff__code i.t3 { background: var(--gold); }
.js-motion .diff__line--out.is-out { background: var(--tint-clay); animation: flick 420ms steps(1, end); }
.js-motion .diff__line--out.is-out .diff__mark { color: var(--brown); }
.js-motion .diff__line--out.is-out .diff__mark::before { content: "\2212"; }
.js-motion .diff__line--out.is-out .diff__code i { background: var(--brown); opacity: .55; }

.bars { width: 100%; display: flex; flex-direction: column; gap: 1.25rem; }
.bars__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label num" "track track";
  gap: .5rem 1.5rem; align-items: baseline; text-align: left;
}
.bars__label { grid-area: label; font-size: 1.125rem; }
.bars__track { grid-area: track; height: 1.25rem; border-radius: var(--r-pill); background: var(--divider); overflow: hidden; }
.bars__fill { display: block; height: 100%; width: var(--w); border-radius: inherit; transform-origin: left center; }
.bars__fill--written { background: var(--forest); }
.bars__fill--removed { background: var(--brown); }
.bars__fill--kept { background: var(--river); }
.bars__num { grid-area: num; font-family: var(--font-display); font-size: 1.75rem; text-align: right; font-variant-numeric: tabular-nums lining-nums; }

/* How we counted */
.counted { padding-block: 5rem 4rem; }
.notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; margin-top: 2.5rem; }
.note {
  position: relative; overflow: hidden;
  background: var(--tint-bark);
  border-radius: var(--r-md);
  padding: 1.5rem 1.75rem;
  font-size: 1.125rem; line-height: 1.5;
}
.note::after {
  content: ""; position: absolute; right: -1rem; bottom: -1.25rem; width: 7rem; height: 5.6rem;
  background: url("art/art-fern.svg") no-repeat center / contain; opacity: .12; pointer-events: none;
}

.foot { border-top: 1px solid var(--divider); padding-block: 2.5rem 3rem; }
.foot__inner { display: flex; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; font-size: 1rem; color: var(--muted); }

/* ---------- Middle widths ---------- */


/* ---------- Phones and narrow tablets: everything stacks ---------- */
@media (max-width: 860px) {
  .hero__title { font-size: 2.125rem; }
  .hero__lead { font-size: 1.1875rem; }
  .hero__inner { padding-bottom: 6vh; }

  .story { display: block; padding-inline: 0; }
  .stage {
    position: sticky; top: 0; z-index: 2;
    height: 46vh; height: 46svh;
    background: var(--bg);
    border-bottom: 1px solid var(--divider);
  }
  .beats { position: relative; z-index: 1; }
  .beat { min-height: 140svh; padding: 0 var(--gutter) 3rem; }
  .beat__body { position: sticky; top: calc(46svh + 1.5rem); min-height: 0; justify-content: flex-start; padding-block: 0; gap: 1.1rem; }
  .beat h2 { font-size: 1.875rem; }
  .beat__text { font-size: 1.0625rem; }
  .big__num { font-size: 3.75rem; }
  .big__label { font-size: 1.125rem; }
  .pair { gap: 1.25rem; }
  .pair .big__num { font-size: 3.25rem; }
  .row { grid-template-columns: minmax(0, 1fr); gap: .15rem; padding: 1rem 0 .9rem; }
  .row__num { font-size: 1.375rem; }
  .row__label { font-size: 1rem; }
  .guards li { font-size: 1.0625rem; gap: .7rem; }

  .band { padding-block: 5rem 3.5rem; }
  .band__title { font-size: 2.125rem; }
  .band__title--small { font-size: 1.75rem; }
  .band__lead { font-size: 1.125rem; }

  .rail { display: flex; flex-direction: column; height: auto; margin-top: 2.5rem; gap: 0; }
  .rail::before, .rail::after { left: .75rem; right: auto; top: .75rem; bottom: .75rem; width: 4px; height: auto; margin: 0 0 0 -2px; }
  .rail::after { transform-origin: center top; transform: scaleY(var(--p, 1)); }
  .stop { display: grid; grid-template-columns: 2.75rem 1fr; grid-template-rows: auto auto; align-items: center; padding-block: .6rem; }
  .stop__tile { position: relative; top: auto; left: auto; margin: 0; grid-row: 1 / span 2; justify-self: start; }
  .stop__date, .stop__what,
  .stop:nth-child(n) .stop__date, .stop:nth-child(n) .stop__what,
  .stop:first-child .stop__date, .stop:first-child .stop__what,
  .stop:last-child .stop__date, .stop:last-child .stop__what {
    position: static; transform: none; text-align: left; white-space: normal;
  }

  .grid { grid-template-columns: 1fr; gap: 1rem; margin-top: 2.5rem; }
  .stat { min-height: 0; padding: 1.5rem 1.5rem 1.75rem; }
  .stat__num { font-size: 2.75rem; }

  .ratio { margin-top: 4.5rem; }
  .ratio__title { font-size: 1.375rem; }
  .ratio__body { grid-template-columns: 1fr; gap: 2rem; }
  .diff__line { height: 2.1rem; grid-template-columns: 2.5rem 1.5rem minmax(0, 1fr); padding-right: 1rem; }
  .diff__code i { width: calc(var(--l) * .8rem); }
  .bars__label { font-size: 1rem; }
  .bars__num { font-size: 1.25rem; }

  .notes { grid-template-columns: 1fr; gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cue-tile { animation: none; }
  .js-motion .reveal { opacity: 1; transform: none; transition: none; }
}

/* The cord appears with the same flicker as the tiles. */
.stage__cord { opacity: 0; }
.stage__cord.is-on { opacity: 1; }
.js-motion .stage__cord.is-on { animation: flick 420ms steps(1, end); }
@media (prefers-reduced-motion: reduce) {
  .kete-mark .km-trace { opacity: 0; }
}
