@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Big Shoulders Display';
  src: url('../fonts/big-shoulders-display-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --earth: #1e1914;
  --earth-2: #251f19;
  --line: #3a3027;
  --ink: #ece4d6;
  --dim: #c2b6a4;
  --ice: #8fd8f0;
  --ember: #ff9b52;
  --rosa: #f2a39b;
  --kai: #6fd3b7;
  --mei: #efcd78;
  --draft: #c4d5e8;
  --text: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --clock: 'Big Shoulders Display', 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --gutter: clamp(16px, 2.6vw, 40px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--earth); }
body {
  margin: 0;
  background: var(--earth);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
a:focus-visible, summary:focus-visible, video:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; border-radius: 2px; }

/* The top line scrolls away with the first screen; nothing on this page is fixed. */
.topline {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 14px var(--gutter);
  font-size: 14px;
  color: #f4efe6;
}
.topline a { text-decoration: none; border-bottom: 1px solid rgba(244, 239, 230, 0.45); }

/* ---- Scenes: tall scroll containers holding a sticky stage ---------------- */
.scene { position: relative; height: calc((100 + var(--travel, 300)) * 1svh); }
.stage { position: sticky; top: 0; height: 100svh; overflow: hidden; }

/* ---- The day stage: tall layout by default --------------------------------- */
.day-stage {
  --mode: tall;
  --sky-ink: #f4efe6;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "view" "caption";
  background: var(--earth);
}
.view {
  grid-area: view;
  display: grid;
  grid-template-rows: minmax(0, 1.7fr) minmax(0, 1fr);
  min-height: 0;
}
.view svg.shop, .view canvas.ground { display: block; width: 100%; height: 100%; min-height: 0; }
.clock {
  grid-area: view;
  align-self: start;
  justify-self: start;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 14px var(--gutter) 0;
  color: var(--sky-ink);
  pointer-events: none;
}
.clock .running { font-size: 14px; font-weight: 700; }
.clock .digits {
  font-family: var(--clock);
  font-weight: 800;
  font-size: clamp(2.6rem, min(13vw, 9svh), 6.2rem);
  line-height: 0.92;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.clock .date { font-size: clamp(13px, min(3.4vw, 2svh), 18px); }
/* Tall screens: the night street above, the title below it on the dark ground. */
.title {
  grid-area: view;
  align-self: end;
  z-index: 3;
  padding: 0 var(--gutter) clamp(18px, 4svh, 48px);
  color: #f4efe6;
}
.title h1 {
  margin: 0 0 0.4em;
  font-size: clamp(2.1rem, min(9vw, 7svh), 4.8rem);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.012em;
  max-width: 12ch;
}
.title .lede { margin: 0; max-width: 30ch; font-size: clamp(1.02rem, min(4.2vw, 2.7svh), 1.4rem); line-height: 1.4; }
.column { display: none; }
.caption {
  grid-area: caption;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: clamp(96px, 24svh, 260px);
  padding: 12px var(--gutter) 14px;
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.cap { font-size: clamp(15px, min(4.3vw, 3.4svh), 44px); line-height: 1.3; color: #f6f0e6; }
.cap + .cap { font-size: 0.78em; color: var(--dim); }
.cap .t { font-variant-numeric: tabular-nums; color: var(--dim); }
.cap .w { font-weight: 700; }
.cap b { color: var(--draft); }
.cap .n, .rules li::before {
  display: inline-grid;
  place-items: center;
  width: 1.45em; height: 1.45em;
  border-radius: 50%;
  background: #f4efe6;
  color: #1d1916;
  font-size: 0.72em;
  font-weight: 800;
  vertical-align: 0.12em;
}
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; }
.leaders path { fill: none; stroke: var(--draft); stroke-width: 1.4; }
.leaders circle { fill: var(--draft); }

/* Wide screens: the shop and its ground on the left, Rosa's words and the log on the right. */
@media (min-aspect-ratio: 5/4) and (min-height: 481px) {
  .day-stage {
    --mode: wide;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 26vw, 380px);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "view column";
  }
  .view { grid-template-rows: minmax(0, 1fr) clamp(160px, 30svh, 270px); }
  .clock { padding-top: 56px; }
  .title { align-self: start; padding: 64px var(--gutter) 0; color: var(--sky-ink); }
  .caption { display: none; }
  .column {
    grid-area: column;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    min-height: 0;
    padding: 56px 22px 20px;
    border-left: 1px solid var(--line);
    overflow: hidden;
  }
}
/* Phones held sideways: the shop on the left, the clock and one line on the right. */
@media (min-aspect-ratio: 3/2) and (max-height: 480px) {
  .day-stage {
    --mode: compact;
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "view clock" "view caption";
  }
  .view { grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr); }
  .clock { grid-area: clock; padding: 12px 16px 0; color: #f4efe6; }
  .clock .digits { font-size: clamp(2rem, 11svh, 3rem); }
  .caption { height: auto; border-top: 0; border-left: 1px solid var(--line); padding: 8px 16px 12px; }
  .cap { font-size: 15px; }
  .title { align-self: start; padding: 40px var(--gutter) 0; }
  .title h1 { font-size: 2rem; }
  .title .lede { font-size: 1rem; }
}

.column h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--dim); }
.words { min-height: 0; }
.description { margin: 0 0 12px; font-size: 16px; line-height: 1.5; }
.description p { margin: 0; }
.clause b { font-weight: 700; color: #fbf7ef; }
.clause.current b { color: var(--draft); }
.status { margin: 0 0 14px; font-size: 14.5px; color: var(--dim); }
.status .approved { color: var(--rosa); font-weight: 700; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 14.5px; line-height: 1.35; }
.rules li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 3px 6px 3px 2px;
  border-radius: 3px;
  background: rgba(244, 239, 230, calc(var(--pulse, 0) * 0.12));
}
.rules li::before { content: attr(data-rule); display: grid; width: 20px; height: 20px; font-size: 11.5px; margin-top: 1px; }
.rules li.active::before { background: var(--ice); }
.log { flex: 0 0 auto; }
.lines { --row: 46px; position: relative; height: calc(var(--row) * 6); overflow: hidden; }
.line {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--row);
  overflow: hidden;
  font-size: 14.5px;
  line-height: 1.3;
  color: var(--dim);
  will-change: transform, opacity;
}
.line .t { font-variant-numeric: tabular-nums; }
.line .w { font-weight: 700; color: var(--ink); }
.line.newest { color: #fbf7ef; }
[data-who="rosa"] .w { color: var(--rosa); }
[data-who="kai"] .w { color: var(--kai); }
[data-who="mei"] .w { color: var(--mei); }
[data-who="assistant"] .w { color: var(--draft); }
[data-who="sensor"] .w, [data-who="cool"] .w { color: var(--ice); }
[data-who="ovens"] .w { color: var(--ember); }

/* ---- The month stage ------------------------------------------------------------ */
.month-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--earth);
}
.chart { position: relative; min-height: 0; }
.month-canvas { display: block; width: 100%; height: 100%; }
.text {
  position: relative;
  height: clamp(150px, 36svh, 320px);
  padding: 12px var(--gutter) 14px;
  border-top: 1px solid var(--line);
}
.text h2 { margin: 0; font-size: clamp(1.05rem, 4.4vw, 1.5rem); line-height: 1.25; font-weight: 800; }
.step { position: absolute; left: var(--gutter); right: var(--gutter); top: calc(12px + 2.3em); }
.step p { margin: 0 0 0.55em; font-size: clamp(14.5px, min(3.9vw, 2.5svh), 19px); line-height: 1.4; }
.result { font-weight: 800; }
.result-1 { color: var(--kai); }
.result-2 { color: #f5b264; }
.aside { color: var(--dim); }
.imagined { font-weight: 800; }
@media (min-aspect-ratio: 5/4) and (min-height: 481px) {
  .month-stage { grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 430px); grid-template-rows: minmax(0, 1fr); }
  .text { height: auto; padding: 64px 28px 28px; border-top: 0; border-left: 1px solid var(--line); }
  .text h2 { font-size: 1.6rem; }
  .step { left: 28px; right: 28px; top: 150px; }
  .step p { font-size: 17px; }
}
@media (min-aspect-ratio: 3/2) and (max-height: 480px) {
  .month-stage { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .text { height: auto; border-top: 0; border-left: 1px solid var(--line); padding: 12px 16px; }
  .text h2 { font-size: 1rem; }
  .step { left: 16px; right: 16px; top: 52px; }
  .step p { font-size: 13.5px; margin-bottom: 0.4em; }
}

/* ---- The close ------------------------------------------------------------------------ */
#close { max-width: 46rem; margin: 0 auto; padding: 14svh var(--gutter) 16svh; }
.full-log summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.full-log table { width: 100%; border-collapse: collapse; margin: 10px 0 0; font-size: 15px; line-height: 1.4; }
.full-log th, .full-log td { text-align: left; vertical-align: top; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); }
.full-log th { color: var(--dim); font-weight: 700; }
.full-log td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.closing { margin: 2.2em 0 2.4em; font-size: clamp(1.1rem, 2.2vw, 1.3rem); line-height: 1.6; }
.film { margin: 0; }
.film video { display: block; width: 100%; height: auto; background: #0e0b09; }
.film video.wide { aspect-ratio: 16 / 9; }
.film video.square { display: none; aspect-ratio: 1; }
/* Tall screens get the square cut, made to be read small. */
@media (max-aspect-ratio: 5/4) {
  .film video.wide { display: none; }
  .film video.square { display: block; }
}
.film figcaption { margin-top: 8px; font-size: 15px; color: var(--dim); }
.back { display: inline-block; margin-top: 2.6em; font-weight: 700; }

/* ---- Reduced motion: stills from the score ---------------------------------------- */
.stills { max-width: 60rem; margin: 0 auto; padding: 64px var(--gutter) 24px; }
.stills .title { padding: 0 0 1.5em; color: #f4efe6; }
.stills .words { max-width: 40rem; margin-bottom: 2em; }
.stills .words h2 { font-size: 15px; color: var(--dim); }
.still { margin: 0 0 2.2em; }
.still svg.shop { display: block; width: 100%; aspect-ratio: 2.1; }
.still canvas.ground { display: block; width: 100%; height: clamp(150px, 26vw, 250px); }
.still figcaption { margin-top: 8px; font-size: 16px; }
.month-still .chart { aspect-ratio: 1.5; }
.stills > h2 { font-size: 1.4rem; }
.stills .step { position: static; }

/* ---- The film's capture mode ---------------------------------------------------------- */
.endcard { display: none; }
html[data-capture] body { overflow: hidden; }
html[data-capture] .topline, html[data-capture] #close { display: none; }
html[data-capture] #day, html[data-capture] #month { position: fixed; inset: 0; visibility: hidden; }
html[data-capture][data-active="day"] #day,
html[data-capture][data-active="end"] #day,
html[data-capture][data-active="month"] #month { visibility: visible; }
html[data-capture] .scene { height: 100vh; }
html[data-capture] .stage { position: absolute; inset: 0; height: 100vh; }
html[data-capture] .endcard {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  background: var(--earth);
  color: #f4efe6;
  opacity: 0;
}
.endcard .mark { font-family: var(--clock); font-weight: 800; font-size: min(15vw, 20vh); line-height: 1; }
.endcard .addr { font-size: min(4.6vw, 5.2vh); }

/* The square film is watched small, on phones: more shop, one large line of words. */
html[data-capture="square"] .view { grid-template-rows: minmax(0, 2.3fr) minmax(0, 1fr); }
html[data-capture="square"] .caption { height: 18vh; }
