/* About: a storybook. The chapters scroll on one side; one sticky stage stays in place on the
   other and shows the active chapter with the site's own tiles, board, rail and palettes (see
   js/about.js). Everything uses the site's tokens. Motion exists only without a reduced-motion
   request, so the reduced view is the static final state of every scene. */
.ab {
  --ab-stage: min(460px, 44vw, calc(100dvh - 32px));
  max-width: 1120px; margin: 0 auto; padding: 0 24px 32dvh; /* the room at the end lets the stage release */
  display: grid; grid-template-columns: minmax(0, 1fr) var(--ab-stage); column-gap: 56px;
}

/* ── the chapters ── */
.ab-chapters.page { grid-column: 1; grid-row: 1; max-width: none; margin: 0; padding: 0; width: auto; }
.ab-chapter { min-height: 78dvh; display: grid; align-content: center; padding: 8dvh 0; }
.ab-text { max-width: 34rem; }
.ab-text h1, .ab-text h2 { text-wrap: balance; margin: 0 0 18px; font-weight: 750; letter-spacing: -0.012em; }
.ab-text h1 { font-size: clamp(32px, 4.4vw, 48px); line-height: 1.08; }
.ab-text h2 { font-size: clamp(26px, 3.2vw, 34px); line-height: 1.12; }
.ab-text p, .ab-text li { margin: 0 0 14px; font-size: 18px; line-height: 1.6; }
.ab-text li { margin-bottom: 4px; }
.ab-text ul { margin: 0 0 14px; padding-left: 1.3em; }
.ab-text kbd { font-size: 14px; }
.ab-text .primary { margin-top: 6px; }
.ab-n {
  display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 14px; border-radius: 4px;
  background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline);
  font: 700 13px / 1 var(--sans); font-variant-numeric: tabular-nums;
}
.ab-chapter.is-active .ab-n { background: var(--accent); color: var(--on-accent); box-shadow: none; }

/* ── the stage ── */
.ab-stage {
  grid-column: 2; grid-row: 1; align-self: start; position: sticky; top: calc((100dvh - var(--ab-stage)) / 2);
  width: var(--ab-stage); aspect-ratio: 1; container-type: size; overflow: hidden; touch-action: pan-y;
  border-radius: 18px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line);
}
.ab-scene { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 18px; }
.ab-scene .cell { cursor: default; }
.ab-scene .cluebar .text { cursor: default; font-size: var(--fs, 18px); }
.ab-col { --w: min(72cqw, calc(100cqh - 124px)); width: var(--w); display: flex; flex-direction: column; gap: 12px; }
.ab-col .boardwrap { width: 100%; }

/* ── 1: the logo and the year ── */
.ab-scene[data-scene="open"] { --t: min(13.5cqw, 13.5cqh); --g: 3px; gap: 22px; }
.ab-year {
  width: calc(6 * var(--t) + 5 * var(--g)); display: grid; grid-template-columns: repeat(53, 1fr); grid-template-rows: repeat(7, auto);
  grid-auto-flow: column; gap: 2px;
}
.ab-year i { aspect-ratio: 1; border-radius: 1.5px; background: color-mix(in srgb, var(--accent) 38%, transparent); }
.ab-year i:first-child { grid-row-start: var(--r); }
.ab-year i:first-child, .ab-year i:last-child { background: var(--accent); }
.ab-dates { width: calc(6 * var(--t) + 5 * var(--g)); display: flex; justify-content: space-between; margin-top: -8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── 3: typing ── */
.ab-meta { display: flex; align-items: center; justify-content: space-between; height: 24px; }
.ab-keys { display: flex; gap: 4px; }
.ab-keys kbd { background: var(--paper); color: var(--ink); line-height: 1.5; }
.ab-keys kbd.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ── 4: check and reveal ── */
.ab-pills { display: flex; justify-content: center; gap: 8px; }
.ab-pill { cursor: default; font-weight: 600; }
.ab-pill.on { background: var(--hl-word); color: var(--on-hl); }
.ab-note { text-align: center; font-size: 15px; line-height: 20px; color: var(--muted); }
.ab-note b { color: var(--fg); font-weight: 600; }

/* ── 5: how a puzzle is made ── */
.ab-scene[data-scene="made"] { align-items: stretch; gap: 14px; padding: 22px; }
.ab-step { display: grid; gap: 7px; opacity: 0; transform: translateY(8px); }
.ab-step.on { opacity: 1; transform: none; }
.ab-label { font-size: 14px; line-height: 18px; font-weight: 600; color: var(--muted); }
.ab-pats { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.ab-pat { display: grid; grid: repeat(5, 1fr) / repeat(5, 1fr); gap: 1px; aspect-ratio: 1; padding: 1px; border-radius: 3px; background: var(--tline); }
.ab-pat i { background: var(--paper); }
.ab-pat i.k { background: var(--block); }
.ab-pat.pick { box-shadow: 0 0 0 2px var(--accent); }
.ab-scene.won .ab-pat:not(.pick) { opacity: 0.35; }
.ab-cands { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; }
.ab-cands i { aspect-ratio: 1; border-radius: 3px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--tline); opacity: 0; }
.ab-step.on .ab-cands i { opacity: 1; }
.ab-scene.sifted .ab-cands i.out { opacity: 0.22; }
.ab-scene.sifted .ab-cands i:not(.out) { background: var(--hl-cell); box-shadow: none; }
.ab-scene.won .ab-cands i.win { background: var(--accent); transform: scale(1.3); }
.ab-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ab-chips span { padding: 3px 10px; border-radius: 999px; font-size: 13px; line-height: 18px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline); }
.ab-result { display: flex; align-items: center; gap: 16px; }
.ab-score { display: flex; align-items: baseline; gap: 6px; }
.ab-score b { font-size: 44px; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--accent); }
.ab-score span, .ab-facts { font-size: 15px; line-height: 20px; color: var(--muted); }
.ab-facts { display: grid; }
.ab-seed { font: 12px / 16px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-height: 400px) {
  .ab-scene[data-scene="made"] { gap: 10px; padding: 14px 16px; }
  .ab-score b { font-size: 36px; }
}
@container (max-height: 340px) {
  .ab-cands { grid-template-columns: repeat(32, 1fr); gap: 2px; }
  .ab-cands i { border-radius: 2px; }
  .ab-scene.won .ab-cands i.win { transform: scale(1.5); }
  .ab-chips { display: none; }
}

/* ── 6: the scene of the day (the page steps through three palettes; the strip copies the header's canvas; see about.js) ── */
.ab-band { display: block; align-self: stretch; height: auto; flex: none; }
.ab-scene[data-scene="palette"] .ab-col { --w: min(72cqw, calc(100cqh - 250px)); }
.ab-scene[data-scene="palette"] .ab-logo { --t: 15px; --g: 2px; }
.ab-head { display: flex; align-items: center; gap: 16px; }
.ab-tint { display: grid; gap: 2px; white-space: nowrap; font-size: 14px; line-height: 20px; color: var(--muted); }
.ab-tint strong { font-size: 18px; line-height: 22px; color: var(--fg); }
.ab-dots { display: flex; gap: 6px; margin-top: 4px; }
.ab-dots i { width: 12px; height: 12px; border-radius: 50%; }
.ab-dots i:nth-child(1) { background: var(--a1); }
.ab-dots i:nth-child(2) { background: var(--a2); }
.ab-dots i:nth-child(3) { background: var(--a3); }
.ab-dots i:nth-child(4) { background: var(--a4); }
.cell.ab-done:not(.word):not(.cur) { background: var(--hl-done); color: var(--on-hl); box-shadow: none; }

/* ── 7: the rail ── */
.ab-clues { width: min(100%, 440px); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.ab-list { min-width: 0; }
.ab-list .cluelist h2 { margin: 0; font-size: 13px; line-height: 20px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

/* ── 9: the day boundary and the shared result ── */
.ab-caption { font-size: 15px; line-height: 20px; color: var(--muted); }
.ab-scene[data-scene="day"] { --t: min(11cqw, 11cqh); --g: 4px; }
.ab-clock > b.ab-colon { background: none; box-shadow: none; color: var(--muted); }
.ab-days { display: grid; grid-template-columns: repeat(5, var(--t)); gap: var(--g); }
.ab-days .day { font-size: 14px; }
.ab-days .day.today { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline); }
.ab-share {
  margin: 0; padding: 10px 14px; max-width: 100%; border-radius: 10px; background: var(--paper); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--tline); font: 13px / 1.35 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; opacity: 0;
}
.ab-share.on { opacity: 1; }

/* ── a page without its puzzle: the text stands alone ── */
.ab-plain { display: block; max-width: 680px; }
.ab-plain .ab-stage { display: none; }

/* ── phones: the stage is stuck to the top, the chapters scroll under it ── */
@media (max-width: 899px) {
  .ab { display: block; padding: 0 0 22dvh; }
  .ab-stage { top: 0; z-index: 3; width: 100%; height: 46dvh; aspect-ratio: auto; border-radius: 0 0 18px 18px; }
  .ab-scene { padding: 12px; gap: 10px; }
  .ab-chapters.page { padding: 0 18px; }
  .ab-chapter { min-height: 52dvh; padding: 5dvh 0; }
  .ab-text h1 { font-size: 32px; }
  .ab-text h2 { font-size: 27px; }
  .ab-text p, .ab-text li { font-size: 17px; line-height: 1.55; }
  .ab-plain .ab-chapters.page { padding: 0 18px; }
}

/* ── motion: only when it is welcome ── */
@media (prefers-reduced-motion: no-preference) {
  .ab-scene:not(.ab-still) { animation: ab-in 320ms cubic-bezier(.2, .8, .2, 1) both; }
  .ab-scene:not(.ab-still) .ab-logo > b { animation: ab-tile 560ms cubic-bezier(.2, .9, .3, 1.15) both; animation-delay: calc(var(--c) * 70ms + var(--r) * 40ms); }
  .ab-scene:not(.ab-still) .ab-year i { animation: ab-tile 420ms cubic-bezier(.2, .9, .3, 1.15) both; animation-delay: calc(600ms + var(--i) * 2ms); }
  .ab-n { transition: background-color 200ms, color 200ms; }
  .ab-keys kbd { transition: background-color 120ms, color 120ms, border-color 120ms; }
  .ab-pill { transition: background-color 160ms; }
  .ab-step { transition: opacity 380ms ease-out, transform 380ms ease-out; }
  .ab-pat { transition: opacity 320ms, box-shadow 320ms; }
  .ab-cands i { transition: opacity 380ms, background-color 380ms, box-shadow 380ms, transform 380ms cubic-bezier(.3, 1.6, .5, 1); }
  .ab-step.on .ab-cands i { transition-delay: calc(var(--i) * 7ms); }
  .ab-scene.sifted .ab-cands i { transition-delay: calc(var(--i) * 3ms); }
  .ab-scene[data-scene="palette"] .cell, .ab-scene[data-scene="palette"] .xw > b, .ab-dots i { transition: background-color 420ms, color 420ms, box-shadow 420ms; }
  .ab-days .day { transition: background-color 300ms, color 300ms; }
  .ab-share { transition: opacity 420ms; }
}
@keyframes ab-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes ab-tile { from { opacity: 0; transform: scale(0.6); } }
