/* /tonight/ — the evening recap (UX run-14). A v2 page on the css/toys.css tokens (DESIGN.md § 8d):
   putty surface, physical depth, springy keys, light and dark, Geist + Geist Mono like /week/,
   /headcount/ and /class-chat/. The stage is the night: a near-black slab in both schemes (the
   evening the recap is read in), holding Vasya's message; one lemon accent, the lamp: the
   «Close the day» key, the ticks and the moon of a closed day. The shared header floats fixed over
   the page; the body clears its height. */
body.tn {
  --t-display: "Geist", ui-sans-serif, system-ui, sans-serif;
  --tn-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --tn-night: #141414;
  --tn-bubble: #23231f;
  --tn-text: #f2f0ea;
  --tn-text-2: #bdbab1; /* 9.4:1 on the bubble, 10.6:1 on the night */
  --tn-line: rgba(255, 255, 255, .12);
  --tn-lemon: #ffd23f;
  padding-top: var(--header-h);
  font-family: var(--t-display);
  font-variation-settings: normal;
}
@media (prefers-color-scheme: dark) {
  body.tn { --tn-night: #0e0e0d; --tn-bubble: #20201d; }
}
html:has(body.tn) { scroll-padding-top: calc(var(--header-h) + 18px); }
body.tn .t-wrap,
body.tn .container-wide { width: min(100% - 2 * var(--tn-gutter), 1240px); }
.tn-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Until tonight.js has written the recap, the app's room is laid out but not painted. */
html.tn-wait #tn-app,
html.tn-wait .tn-main > section:not(.tn-mast),
html.tn-wait .site-foot { visibility: hidden; animation: tn-show 0s 3s forwards; }
@keyframes tn-show { to { visibility: visible; } }
@media (scripting: none) { #tn-app { display: none; } }
.tn-noscript { margin: 0 0 32px; padding: 18px 20px; border-radius: var(--t-r-m); background: var(--t-card); box-shadow: inset 0 0 0 2px var(--t-line); }

/* Masthead */
.tn-main { padding-bottom: 40px; }
.tn-mast { padding: 36px 0 24px; }
.tn-kicker { margin: 0 0 14px; color: var(--t-ink-2); }
.tn-mast h1 {
  margin: 0; max-width: 13ch;
  font-size: 2.5rem; line-height: .94; font-weight: 800; letter-spacing: -.02em; text-wrap: balance;
  animation: tn-rise .7s var(--t-spring) both;
}
.tn-lede { margin: 20px 0 0; max-width: 52ch; font-size: 1.125rem; line-height: 1.4; color: var(--t-ink-2); text-wrap: pretty; }
.tn-lede strong { color: var(--t-ink); font-weight: 600; }
@keyframes tn-rise { from { transform: translateY(28px) scale(.97); } }
@media (min-width: 380px) { .tn-mast h1 { font-size: 2.75rem; } }
@media (min-width: 600px) { .tn-mast h1 { font-size: 4.25rem; } .tn-lede { font-size: 1.3125rem; } }
@media (min-width: 1100px) { .tn-mast { padding-top: 56px; } .tn-mast h1 { font-size: 5.5rem; } }

.tn-app { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }

/* Keys */
body.tn .tn-key {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px; border: 0; border-radius: var(--t-r-btn, 10px); cursor: pointer;
  background: var(--t-card); color: var(--t-ink); text-decoration: none; text-align: center;
  font: 600 .9375rem/1.2 var(--t-display);
  box-shadow: inset 0 0 0 1.5px var(--t-line), inset 0 -4px 0 rgba(0,0,0,.08);
  transition: transform var(--t-base) var(--t-spring);
}
body.tn .tn-key:active { transform: translateY(2px) scale(.97); }
body.tn .tn-key:disabled { cursor: default; }
body.tn .tn-key-ink { background: var(--t-ink); color: var(--t-surface); box-shadow: inset 0 -4px 0 rgba(255,255,255,.14); font-weight: 700; }
.tn-keys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* The stage: the night, holding Vasya's message. Light text in both schemes. */
.tn-stage {
  position: relative; padding: 18px 12px 18px; border-radius: 34px;
  background: var(--tn-night); color: var(--tn-text);
  box-shadow: inset 0 -10px 0 rgba(255,255,255,.05), 0 20px 40px -24px rgba(0,0,0,.6);
  transition: background-color .6s var(--t-out);
}
@media (prefers-color-scheme: dark) { .tn-stage { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.08), inset 0 -10px 0 rgba(255,255,255,.04); } }
@media (min-width: 600px) { .tn-stage { padding: 28px 28px 24px; } }
@media (min-width: 1100px) { .tn-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); column-gap: 40px; padding: 40px 44px 32px; align-items: start; } }
body.tn .tn-stage :focus-visible { outline: 3px solid var(--tn-lemon); outline-offset: 3px; }
.tn-stage a { color: var(--tn-text); text-underline-offset: .2em; }
.tn-top {
  display: flex; justify-content: space-between; gap: 12px; margin: 0 6px 14px;
  font: 600 .75rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tn-text-2);
}
.tn-clock { font-variant-numeric: tabular-nums; }
@media (min-width: 1100px) {
  .tn-top { grid-column: 1 / -1; }
  .tn-msg { grid-column: 1; }
  .tn-made { grid-column: 1 / -1; grid-row: 2; }
  .tn-closed, .tn-keys, .tn-remind, .tn-status { grid-column: 2; }
  .tn-msg { grid-row: 2 / span 6; }
  .tn-made:not([hidden]) + .tn-msg { grid-row: 3 / span 6; }
  .tn-stage .tn-keys { flex-direction: column; margin-top: 0; }
  .tn-stage .tn-keys > .tn-key { width: 100%; }
}
.tn-made { margin: 0 0 14px; padding: 12px 16px; border-radius: var(--t-r-m); border: 1.5px dashed var(--tn-text-2); }
.tn-made p { margin: 0; line-height: 1.45; }

/* Vasya's message: a chat bubble, the way the real recap arrives. */
.tn-msg {
  padding: 18px 16px 16px; border-radius: 8px 24px 24px 24px;
  background: var(--tn-bubble); box-shadow: inset 0 0 0 1px var(--tn-line), 0 18px 30px -24px rgba(0,0,0,.8);
  animation: tn-msg-in .6s var(--t-spring) both;
}
@keyframes tn-msg-in { from { transform: translateY(14px) scale(.985); } }
@media (min-width: 600px) { .tn-msg { padding: 24px 26px 20px; } }
.tn-msg.is-made { box-shadow: none; border: 1.5px dashed var(--tn-text-2); }
.tn-from { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.tn-tile {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--t-cobalt); color: #fff; font: 800 1rem/1 var(--t-display); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}
.tn-name { font-weight: 700; }
.tn-time { margin-left: auto; font: 500 .8125rem/1 var(--t-mono); color: var(--tn-text-2); font-variant-numeric: tabular-nums; }
.tn-tag-made { padding: 3px 8px; border-radius: 999px; border: 1.5px dashed currentColor; font: 600 .6875rem/1.2 var(--t-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--tn-text-2); }
.tn-title { margin: 0 0 6px; font-size: 1.75rem; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; }
.tn-title:focus { outline: none; }
@media (min-width: 600px) { .tn-title { font-size: 2.25rem; } }
.tn-summary { margin: 0 0 16px; max-width: 60ch; font-size: 1.0625rem; line-height: 1.45; color: var(--tn-text); text-wrap: pretty; }
.tn-sign { margin: 18px 0 0; color: var(--tn-text-2); }

.tn-sec { padding: 14px 0 4px; border-top: 1.5px solid var(--tn-line); }
.tn-sec-title {
  display: flex; justify-content: space-between; gap: 12px; margin: 0 0 6px;
  font: 600 .8125rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tn-text-2);
}
.tn-sec-n { font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.tn-rows { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.tn-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; padding: 4px 0; }
.tn-row-body { min-width: 0; padding-top: 10px; }
.tn-row-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0; font-size: 1.0625rem; line-height: 1.4; }
.tn-row-time { font: 600 .9375rem/1.4 var(--t-mono); font-variant-numeric: tabular-nums; color: var(--tn-lemon); }
.tn-row-title { min-width: 0; overflow-wrap: anywhere; }
.tn-row.is-done .tn-row-title { color: var(--tn-text-2); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.tn-row.is-done .tn-row-time { color: var(--tn-text-2); }
.tn-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; padding: 0; list-style: none; }
.tn-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 999px; font: 600 .6875rem/1.2 var(--t-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--tn-text-2); box-shadow: inset 0 0 0 1.5px var(--tn-line); }
.tn-tag-who { color: var(--tn-text); }

/* The tick: a 44 px key around a drawn box; a ticked thing fills it with the lamp. */
body.tn .tn-tick {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: none; color: var(--tn-text); cursor: pointer;
}
.tn-tick-box {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
  box-shadow: inset 0 0 0 2px var(--tn-text-2); transition: background-color var(--t-base), box-shadow var(--t-base), transform var(--t-slow) var(--t-spring);
}
body.tn .tn-tick:hover .tn-tick-box { box-shadow: inset 0 0 0 2px var(--tn-text); }
body.tn .tn-tick[aria-pressed="true"] .tn-tick-box { background: var(--tn-lemon); box-shadow: none; transform: scale(1.06); }
body.tn .tn-tick[aria-pressed="true"] .tn-tick-box::before {
  content: ""; width: 11px; height: 6px; border-left: 2.5px solid #141414; border-bottom: 2.5px solid #141414; transform: translateY(-1px) rotate(-45deg);
}
body.tn .tn-move, body.tn .tn-more {
  min-height: 44px; padding: 8px 12px; border: 0; border-radius: var(--t-r-btn, 10px); cursor: pointer;
  background: none; color: var(--tn-text); font: 600 .875rem/1.2 var(--t-display);
  box-shadow: inset 0 0 0 1.5px var(--tn-line);
}
body.tn .tn-more { margin: 6px 0 4px 54px; }
@media (max-width: 479px) {
  .tn-row { grid-template-columns: 44px minmax(0, 1fr); }
  body.tn .tn-move { grid-column: 2; justify-self: start; margin-bottom: 4px; }
}
.tn-empty, .tn-later, .tn-hand { margin: 4px 0 10px; color: var(--tn-text-2); line-height: 1.5; }
.tn-empty a, .tn-later a, .tn-hand a { display: inline-flex; align-items: center; min-height: 44px; color: var(--tn-text); font-weight: 700; }
.tn-hand { color: var(--tn-text); }

/* A closed day: the lamp goes out, the moon comes up. */
.tn-stage.is-closed { background: #090909; }
.tn-closed { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 18px; padding: 16px 18px; border-radius: var(--t-r-m); background: rgba(255,210,63,.08); box-shadow: inset 0 0 0 1.5px rgba(255,210,63,.35); }
@media (min-width: 1100px) { .tn-closed { margin-top: 0; margin-bottom: 18px; } }
.tn-closed p { margin: 0; line-height: 1.45; }
.tn-closed > div { flex: 1 1 12em; }
.tn-closed-big { font-size: 1.375rem; font-weight: 800; line-height: 1.15; }
.tn-moon {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  box-shadow: inset -12px -6px 0 0 var(--tn-lemon); transform: rotate(-20deg);
  animation: tn-moon .9s var(--t-spring) both;
}
@keyframes tn-moon { from { transform: rotate(-80deg) scale(.4); opacity: 0; } }

/* Keys on the night */
body.tn .tn-stage .tn-key { background: #2b2b27; color: var(--tn-text); box-shadow: inset 0 0 0 1.5px var(--tn-line), inset 0 -4px 0 rgba(0,0,0,.35); }
body.tn .tn-stage .tn-key-lemon { background: var(--tn-lemon); color: #141414; font-weight: 800; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 12px 24px -16px rgba(255,210,63,.6); }
body.tn .tn-stage .tn-key:disabled { color: #8d8a82; }
body.tn .tn-stage .tn-key-lemon:disabled { background: #6b5a1c; color: #e9e6dd; }
@media (max-width: 599px) { .tn-stage .tn-keys > .tn-key { flex: 1 1 100%; } }

.tn-remind { margin-top: 14px; padding: 16px; border-radius: var(--t-r-m); background: var(--tn-bubble); box-shadow: inset 0 0 0 1px var(--tn-line); }
@media (min-width: 1100px) { .tn-remind { margin-top: 14px; } }
.tn-remind-title { margin: 0 0 10px; font-weight: 700; }
.tn-remind-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.tn-field { display: inline-flex; align-items: center; gap: 10px; }
.tn-field select {
  min-height: 44px; padding: 8px 12px; border: 0; border-radius: var(--t-r-btn, 10px);
  background: var(--tn-text); color: #141414; font: 600 1rem/1.2 var(--t-mono); font-variant-numeric: tabular-nums;
}
.tn-cadence { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; border: 0; }
.tn-radio { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.tn-radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--tn-lemon); }
.tn-remind-note { margin: 8px 0 12px; font-size: .9375rem; color: var(--tn-text-2); }
.tn-status { min-height: 1.5em; margin: 14px 4px 0; line-height: 1.5; overflow-wrap: anywhere; }
.tn-status .tn-undo { min-height: 44px; margin-left: 6px; padding: 8px 14px; }

/* What the recap is written from */
.tn-h2 { margin: 0 0 8px; font-size: 1.75rem; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.tn-src-sub { margin: 0 0 16px; max-width: 64ch; color: var(--t-ink-2); }
.tn-src-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 760px) { .tn-src-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tn-src-card { display: grid; align-content: start; gap: 8px; padding: 18px; border-radius: var(--t-r-m); background: var(--t-card); box-shadow: inset 0 0 0 1.5px var(--t-line); }
.tn-src-card .t-label { margin: 0; color: var(--t-ink-2); }
.tn-src-state { margin: 0 0 6px; font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.tn-src-card .tn-key { justify-self: start; }

.tn-keep { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-top: 18px; border-top: 1.5px solid var(--t-line); }
.tn-note { flex: 1 1 22em; margin: 0; font-size: .9375rem; color: var(--t-ink-2); }

/* How it is written, and the real thing */
.tn-how { margin-top: 40px; }
.tn-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 16px 0 18px; padding: 0; list-style: none; }
@media (min-width: 900px) { .tn-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tn-steps li { padding: 18px; border-radius: var(--t-r-m); background: var(--t-card); box-shadow: inset 0 0 0 1.5px var(--t-line); }
.tn-step-n { display: block; margin-bottom: 8px; font: 600 .75rem/1 var(--t-mono); color: var(--toy-text); }
.tn-steps strong { display: block; margin-bottom: 4px; font-size: 1.125rem; }
.tn-steps p { margin: 0; color: var(--t-ink-2); }
.tn-limits { margin: 0; max-width: 72ch; color: var(--t-ink-2); }
.tn-real { margin-top: 40px; padding: 26px 22px; border-radius: var(--t-r-l); background: var(--t-surface-2); }
.tn-real .t-label { margin: 0 0 10px; color: var(--t-ink-2); }
.tn-real h2 { margin: 0 0 10px; max-width: 22ch; font-size: 1.75rem; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.tn-real p { margin: 0 0 16px; max-width: 62ch; color: var(--t-ink-2); }
@media (min-width: 900px) { .tn-real { padding: 36px 40px; } .tn-real h2 { font-size: 2.25rem; } }

@media (prefers-reduced-motion: reduce) {
  .tn-mast h1, .tn-msg, .tn-moon { animation: none !important; }
  .tn-stage, .tn-tick-box, body.tn .tn-key { transition: none; }
  body.tn .tn-tick[aria-pressed="true"] .tn-tick-box { transform: none; }
  body.tn .tn-key:active { transform: none; }
}
