/* Shared shell. One palette, one density system, one way to say "unknown".
   The display face is loaded via <link> in each head, not @import — an @import
   cannot start downloading until this file has arrived, which delays first
   paint on the phone this is mostly used on. */

:root {
  --bg:      oklch(98% 0.005 250);
  --surface: oklch(100% 0 0);
  --fg:      oklch(22% 0.02 240);
  --muted:   oklch(50% 0.018 240);
  --border:  oklch(90% 0.008 240);
  --accent:  oklch(58% 0.16 145);

  /* Display carries the voice; body is the OS face because it renders best at
     13px on a phone in a dim kitchen; mono is for figures only, so columns of
     numbers line up. */
  --font-display: 'Instrument Sans', ui-sans-serif, 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* Six sizes, not eleven. */
  --t-display: 34px;   /* page title, the day you are standing in */
  --t-lg:      24px;   /* a day's figure — the content, so the largest number */
  --t-md:      17px;   /* section heads, secondary figures */
  --t-body:    15px;
  --t-sm:      13px;   /* UI, table rows */
  --t-cap:     11px;   /* caps labels, coverage lines */

  /* derived */
  --surface-2:  oklch(96% 0.006 250);
  --surface-3:  oklch(93.5% 0.008 250);
  --border-str: oklch(84% 0.01 240);
  --fg-invert:  oklch(99% 0 0);
  --accent-ink: oklch(38% 0.11 145);
  --accent-wash:oklch(95.5% 0.035 145);
  --outside:    oklch(48% 0.14 55);    /* target commentary only. never a block. */
  --outside-wash: oklch(96% 0.03 65);

  --r: 3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; font-weight: 600; }
/* clamped so the week title never orphans a word on a 360px phone */
h1 { font-size: clamp(26px, 6vw, var(--t-display)); line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: var(--t-md); line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: var(--t-sm); letter-spacing: 0; }
/* No word left alone on the last line, in a 212px column or a 65ch paragraph. */
h1, h2, h3 { text-wrap: balance; }
p  { margin: 0; text-wrap: pretty; }
.note, .sub, .slot .rname, .cand .cn { text-wrap: pretty; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- shell ---------- */

.shell { max-width: 1400px; margin: 0 auto; padding: 0 16px 96px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1400px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 20px;
}
.wordmark {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  text-decoration: none;
  font-size: var(--t-sm);
  padding: 6px 10px;
  border-radius: var(--r);
  color: var(--muted);
  border: 1px solid transparent;
}
.nav a:hover { background: var(--surface-3); color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--surface-2); border-color: var(--border); }

.pagehead {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.pagehead .sub { color: var(--muted); font-size: var(--t-sm); }

/* ---------- buttons ---------- */

.btn {
  font-size: var(--t-sm);
  padding: 6px 11px;
  border: 1px solid var(--border-str);
  background: var(--surface);
  border-radius: var(--r);
  cursor: pointer;
  line-height: 1.3;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"] { background: var(--surface-3); border-color: var(--muted); }
.btn-primary {
  background: var(--accent-ink);
  color: var(--fg-invert);
  border-color: var(--accent-ink);
}
.btn-primary:hover { background: oklch(30% 0.09 145); border-color: oklch(30% 0.09 145); color: var(--fg-invert); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--surface-3); color: var(--fg); border-color: transparent; }
.btn-sm { font-size: var(--t-sm); padding: 3px 8px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-str); }

/* ---------- fields ---------- */

.field {
  font-size: var(--t-sm);
  padding: 6px 9px;
  border: 1px solid var(--border-str);
  background: var(--surface);
  border-radius: var(--r);
  width: 100%;
  min-width: 0;
}
.field:hover { border-color: var(--muted); }
.field::placeholder { color: oklch(62% 0.015 240); }
.field[aria-invalid="true"] { border-color: var(--outside); box-shadow: inset 0 0 0 1px var(--outside); }
.num { font-family: var(--font-mono); text-align: right; }

label.lbl {
  display: block;
  font-size: var(--t-cap);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

/* ---------- tags ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--t-sm);
  padding: 2px 7px;
  border: 1px solid var(--border-str);
  border-radius: 2px;
  background: var(--surface-2);
  white-space: nowrap;
  line-height: 1.6;
}
.tag.earned {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}
.tag.must { border-color: var(--fg); background: var(--fg); color: var(--fg-invert); }
.tag.leans { border-color: var(--accent-ink); color: var(--accent-ink); background: var(--accent-wash); }
.tag button {
  border: 0; background: none; padding: 0; margin: 0 -2px 0 1px;
  cursor: pointer; line-height: 1; font-size: var(--t-sm); opacity: 0.6;
}
.tag button:hover { opacity: 1; }
.tag.must button { color: var(--fg-invert); }
.tagrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ---------- the unknown token ---------- */

/* Unknown is an answer, not a gap. It takes the same optical size as the
   number it stands in for, so a column of them does not read as a column of
   holes. It stays muted, so real figures still pop dark when you scan. */
.unk {
  font-family: var(--font-mono);
  font-size: 1em;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.coverage {
  font-family: var(--font-mono);
  font-size: var(--t-cap);
  color: var(--muted);
  letter-spacing: 0.015em;
  line-height: 1.45;
}
.figure { font-family: var(--font-mono); font-weight: 500; letter-spacing: -0.01em; }
.figure .u { font-size: 0.62em; color: var(--muted); margin-left: 3px; letter-spacing: 0.02em; }

.note {
  font-size: var(--t-sm);
  color: var(--muted);
  line-height: 1.45;
}
.note-outside { color: var(--outside); }

.partial {
  font-size: var(--t-sm);
  color: var(--outside);
  background: var(--outside-wash);
  border: 1px solid oklch(88% 0.05 65);
  border-radius: var(--r);
  padding: 6px 9px;
}

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.tablewrap { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.data th {
  text-align: left;
  font-size: var(--t-cap); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.n, table.data th.n { text-align: right; font-family: var(--font-mono); }

.empty {
  color: var(--muted);
  font-size: var(--t-sm);
  padding: 22px 14px;
  text-align: center;
}

/* ---------- dialog ---------- */

/* Kitchen, one hand, phone at 20% brightness: real touch targets. */
@media (pointer: coarse) {
  .btn, .tickbtn, .tagpick { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .btn-sm { font-size: var(--t-sm); }
  .field { min-height: 44px; }
  .tag button { min-width: 28px; min-height: 28px; }
}

dialog[open] { display: flex; flex-direction: column; }
.dlg-body { flex: 1 1 auto; min-height: 0; }

dialog {
  border: 1px solid var(--border-str);
  border-radius: var(--r);
  padding: 0;
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 16px 48px oklch(22% 0.02 240 / 0.16);
  max-height: 88vh;
  width: min(760px, calc(100vw - 32px));
}
dialog::backdrop { background: oklch(22% 0.02 240 / 0.32); }
.dlg-head {
  position: sticky; top: 0; background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  z-index: 2;
}
.dlg-body { padding: 14px 16px; overflow: auto; }
.dlg-foot {
  position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; gap: 8px; align-items: center;
}

.srow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* toast: reversal confirmation, never a nag */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--fg); color: var(--fg-invert);
  font-size: var(--t-sm); padding: 8px 14px; border-radius: var(--r);
  display: flex; align-items: center; gap: 12px;
  z-index: 90; box-shadow: 0 6px 20px oklch(22% 0.02 240 / 0.2);
}
/* No motion anywhere in this product. Nothing here is async and nothing
   navigates, so a transition would be decoration in a working canvas. */
#toast[hidden] { display: none; }
#toast button {
  background: none; border: 0; color: var(--fg-invert);
  text-decoration: underline; cursor: pointer; font-size: var(--t-sm); padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
