/* The pegboard for the home and 404 pages. Tokens match static/viewer.html. */

@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Titan One"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/titan-one-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Titan One"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/titan-one-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --board: #e8e6f1;
  --dot: #a6a2c4;
  --tile: #ffffff;
  --ink: #1e1a4d;
  --text: #1e1a4d;
  --muted: #5a5680;
  --rule: #eceaf4;
  --focus: #d2387c;
  --select: #ffa8cc;
  --notice: #ffe592;
  --on-fill: #1e1a4d;
  --code: #f4f3f9;

  /* Pastel series colours: [soft, deep]. Lines use deep on light, soft on dark. */
  --red: #f7a8a1;    --red-deep: #c93a2e;
  --orange: #f9c38e; --orange-deep: #b85a0c;
  --yellow: #ffe592; --yellow-deep: #8c6d00;
  --green: #addca0;  --green-deep: #2f7a33;
  --teal: #93d7cc;   --teal-deep: #0f7067;
  --blue: #a3c7f5;   --blue-deep: #2458bd;
  --purple: #c9b5f2; --purple-deep: #6942bc;
  --pink: #ffa8cc;   --pink-deep: #c22f72;
  --gray: #cfcde0;   --gray-deep: #5a5680;
  --line-blue: var(--blue-deep);
  --line-orange: var(--orange-deep);

  --bw: 4px;
  --radius: 18px;
  --row: 64px;
  --channel: 12px;
  --pad: 24px;
  --drop: 5px;
  --drop-x: 3px;
  --logo-h: 76px;
  --display: "Titan One", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --board: #100e24;
  --dot: #47427a;
  --tile: #1e1a4d;
  --ink: #7b74c2;
  --text: #f4f2ff;
  --muted: #b8b3de;
  --rule: #2d2862;
  --focus: #ffa8cc;
  --select: #6b2a5c;
  --code: #17143a;
  --line-blue: var(--blue);
  --line-orange: var(--orange);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--board); color: var(--text);
  font: 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  scrollbar-color: var(--dot) var(--board);
}
::selection { background: var(--select); color: var(--text); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
a { color: var(--text); font-weight: 700; text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { text-decoration-color: var(--focus); }
code { font-family: var(--mono); font-size: .9em; }

/* ------------------------------------------------------------ board */

.board-wrap { padding: var(--pad); }
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 8), var(--row));
}
.dots { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.dots circle { fill: var(--dot); }

/* Before the layout script runs, tiles simply stack; after it, they snap to the grid. */
.board > .tile { grid-column: 1 / -1; }
.board.placed > .tile { grid-column: var(--gc); grid-row: var(--gr); }

.tile {
  position: relative; min-width: 0; min-height: 0;
  margin: var(--mt, 0) var(--mr, 0) var(--mb, 0) var(--ml, 0);
  background: var(--tile); color: var(--text);
  border: var(--bw) solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--drop-x) var(--drop) 0 var(--ink);
  padding: 12px 16px;
  display: flex; flex-direction: column; justify-content: center;
}
.board.measuring > .tile { align-self: start; }
.tile-head { display: flex; align-items: center; gap: 8px 12px; min-width: 0; }
.tile h2, .tile h3 {
  font-size: 16px; line-height: 1.3; font-weight: 700; margin: 0;
  flex: 1 1 auto; min-width: 0;
}
.tile p { margin: 0; }
.tile p + p, .tile .note { margin-top: 8px; }
.note { color: var(--muted); }

/* Lettering painted on the board: no border, no extrusion, dots show through. */
.tile.lettering {
  background: transparent; border-color: transparent; box-shadow: none;
  padding: 0 4px; justify-content: center;
}
.lettering h2, .lettering h1 {
  font-family: var(--display); font-weight: 400; color: var(--text);
  font-size: 36px; line-height: 1.05; letter-spacing: .005em; text-wrap: balance;
  flex: none;
}
.lettering p { margin: 6px 0 0; color: var(--muted); max-width: 46ch; text-wrap: pretty; }

/* Filled tile: soft shade, inner keyline in the deep shade, ink extrusion. */
.tile.filled {
  background: var(--fill); color: var(--on-fill);
  box-shadow: inset 0 0 0 3px var(--fill-deep), var(--drop-x) var(--drop) 0 var(--ink);
}
.tile.filled .note { color: inherit; opacity: .82; }

/* Ghost: an empty slot waiting for content. */
.tile.ghost {
  background: var(--board); border-style: dashed; box-shadow: none;
  justify-content: center; padding: 20px 24px; gap: 6px;
}
.ghost h1, .ghost h2 { font-family: var(--display); font-size: 24px; font-weight: 400; line-height: 1.3; margin: 0; }
.ghost p { color: var(--muted); max-width: 46ch; }

/* ------------------------------------------------------------ code */

.code {
  position: relative; margin: 8px 0 0;
  background: var(--code); border-radius: 10px;
}
.tile.filled .code { background: var(--tile); color: var(--text); box-shadow: 0 0 0 2px var(--ink); }
/* A command tile: the code block takes the tile's spare height, so no band floats above it. */
.tile.cmd { justify-content: flex-start; }
.tile.cmd .code { flex: 1; margin-top: 0; }

.code pre {
  margin: 0; padding: 12px 56px 12px 14px; overflow-x: auto;
  font: 14px/1.55 var(--mono); tab-size: 2;
  scrollbar-color: var(--dot) transparent;
}
.copy {
  position: absolute; top: 4px; right: 4px;
  font: inherit; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  background: var(--code); border: 0; border-radius: 12px;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.tile.filled .copy { background: var(--tile); }
.copy:hover { background: var(--board); color: var(--text); }
.copy:active { transform: translateY(1px); }
.tile.filled .copy:hover { background: var(--fill); }
.copy svg { width: 22px; height: 22px; }
.copy .done { display: none; }
.copy[data-done] .idle { display: none; }
.copy[data-done] .done { display: block; color: var(--green-deep); }
:root[data-theme="dark"] .copy[data-done] .done { color: var(--green); }

/* ------------------------------------------------------------ hero */

.hero .logo { display: block; align-self: flex-start; height: 104px; width: auto; margin: 0 0 14px -4px; }
.hero h1 { font-size: 44px; line-height: 1.02; }
/* Half a board is narrow between phone and laptop widths; keep the heading to two lines. */
@media (min-width: 640px) and (max-width: 959px) {
  .hero h1 { font-size: 34px; }
  .lettering h2 { font-size: 30px; }
}
.hero p { font-size: 18px; line-height: 1.5; margin-top: 12px; max-width: 44ch; }

.notice {
  background: var(--notice); color: var(--on-fill); font-weight: 700;
  box-shadow: none;
  flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px;
}
.notice svg { flex: none; width: 24px; height: 24px; }

/* ------------------------------------------------------------ demo board */

.stat { padding-bottom: 8px; }
.stat-box { flex: 1; min-height: 0; container-type: size; display: flex; align-items: center; }
.stat-value {
  font-family: var(--display); font-weight: 400; white-space: nowrap; line-height: 1; letter-spacing: .01em;
  font-size: clamp(22px, min(80cqh, 16cqw), 120px);
}
.stat-unit { font-family: var(--font); font-size: .45em; font-weight: 800; opacity: .78; margin-left: .12em; letter-spacing: 0; }
.demo-tag { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; font-size: 14px; line-height: 1.4; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); flex: none; }
.legend b { font-weight: 800; }
.plot { flex: 1; min-height: 0; margin-top: 6px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot .grid { stroke: var(--rule); stroke-width: 2; }
.plot .tick { fill: var(--muted); font: 500 13px var(--font); font-variant-numeric: tabular-nums; }
.plot .line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.plot .pt { fill: var(--tile); stroke-width: 2.5; }

/* ------------------------------------------------------------ reference */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.chips code {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  background: var(--code); font-size: 14px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.swatches li { display: inline-flex; align-items: center; gap: 6px; }
.swatches i { width: 14px; height: 22px; border-radius: 4px; border: 2px solid var(--ink); }
.ref dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; }
.ref dt { font-weight: 700; }
.ref dd { margin: 0; min-width: 0; }

/* ------------------------------------------------------------ footer logo (404) */

.corner {
  position: fixed; right: 0; bottom: 0; z-index: 5;
  padding: 0 10px 10px 0;
}
.corner img { display: block; height: var(--logo-h); width: auto; transition: transform 180ms cubic-bezier(.2, .8, .2, 1); }
.corner:hover img { transform: rotate(-4deg) scale(1.04); }
.corner:focus-visible { outline-offset: 6px; }

@media (max-width: 639px) {
  :root { --pad: 16px; --row: 60px; --radius: 14px; --channel: 10px; --logo-h: 54px; }
  .hero .logo { height: 72px; margin-bottom: 10px; }
  .hero h1 { font-size: 36px; }
  .hero p { font-size: 17px; }
  .lettering h2 { font-size: 28px; }
  .code pre { font-size: 13px; }
  .ref dl { grid-template-columns: 1fr; gap: 2px; }
  .ref dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .copy, .corner img { transition: none; }
  .copy:active { transform: none; }
  .corner:hover img { transform: none; }
}
