/* /table/ — one question for the family table, every evening (UX run-27). A v2 page on the css/toys.css
   tokens (DESIGN.md § 8k): putty surface, physical depth, springy keys, light and dark, Geist + Geist Mono
   like the other family pages. One mint accent, the colour of a kitchen tablecloth: tonight's card lies
   on a gingham cloth drawn in CSS, and mint marks the little ones' question, «Last time» and the names
   in the book. Mint is an object colour and stays the same in dark mode; text on it is ink. «Put it on
   the table» opens the question full screen, printed twice so a phone laid flat between two people
   reads from both sides. The shared header floats fixed over the page; the body clears its height. */
body.tb {
  --t-display: "Geist", ui-sans-serif, system-ui, sans-serif;
  --tb-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --tb-ink: #141414;                 /* text on mint: 8.38:1 */
  --tb-mint-text: #096b47;           /* mint-coloured text on putty and card, light: 5.49 / 6.06:1 */
  --tb-cloth: #e2f2e9;               /* the tablecloth's ground */
  --tb-check: rgba(23, 199, 135, .2);/* its gingham bands */
  --tb-paper: #fbfaf6;               /* the card on the cloth */
  padding-top: var(--header-h);
  font-family: var(--t-display);
  font-variation-settings: normal;
}
@media (prefers-color-scheme: dark) {
  body.tb { --tb-mint-text: #17c787; --tb-cloth: #15201b; --tb-check: rgba(23, 199, 135, .12); --tb-paper: #22221f; }
}
html:has(body.tb) { scroll-padding-top: calc(var(--header-h) + 18px); }
body.tb .t-wrap,
body.tb .container-wide { width: min(100% - 2 * var(--tb-gutter), 1240px); }
.tb-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 table.js has drawn tonight's card, everything under the masthead is laid out but not painted. */
html.tb-wait #tb-cloth,
html.tb-wait #tb-app,
html.tb-wait .tb-real,
html.tb-wait .site-foot { visibility: hidden; animation: tb-show 0s 3s forwards; }
@keyframes tb-show { to { visibility: visible; } }
@media (scripting: none) { #tb-app, #tb-cloth { display: none; } }
.tb-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 ---------- */
.tb-main { padding-bottom: 40px; }
.tb-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 48px; padding-bottom: 40px; }
@media (min-width: 1000px) { .tb-top { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: center; padding-top: 28px; } }
.tb-mast { padding: 36px 0 24px; }
@media (min-width: 1000px) { .tb-mast { padding: 28px 0 8px; } }
.tb-kicker { margin: 0 0 14px; color: var(--t-ink-2); }
.tb-mast h1 {
  margin: 0; max-width: 12ch;
  font-size: 2.5rem; line-height: .94; font-weight: 800; letter-spacing: -.02em; text-wrap: balance;
  animation: tb-rise .7s var(--t-spring) both;
}
.tb-mast h1:focus { outline: none; } /* focused only by script, when the toast that had the keyboard closes */
.tb-lede { margin: 20px 0 0; max-width: 46ch; font-size: 1.125rem; line-height: 1.4; color: var(--t-ink-2); text-wrap: pretty; }
.tb-lede strong { color: var(--t-ink); font-weight: 600; }
@keyframes tb-rise { from { transform: translateY(28px) scale(.97); } }
@media (min-width: 380px) { .tb-mast h1 { font-size: 2.75rem; } }
@media (min-width: 600px) { .tb-mast h1 { font-size: 4.25rem; } .tb-lede { font-size: 1.3125rem; } }
@media (min-width: 1100px) { .tb-mast h1 { font-size: 5rem; } }

/* ---------- Tonight's card on the cloth ---------- */
.tb-cloth {
  position: relative; padding: 22px 14px 16px; border-radius: 34px;
  background-color: var(--tb-cloth);
  background-image:
    repeating-linear-gradient(0deg, var(--tb-check) 0 22px, transparent 22px 44px),
    repeating-linear-gradient(90deg, var(--tb-check) 0 22px, transparent 22px 44px);
  box-shadow: inset 0 0 0 1.5px var(--t-line);
}
@media (min-width: 600px) { .tb-cloth { padding: 40px 36px 22px; } }
.tb-card {
  position: relative; isolation: isolate;
  --tb-card-px: 20px;
  padding: 22px var(--tb-card-px) 20px; border-radius: 22px;
  background: var(--tb-paper); color: var(--t-ink);
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.07), 0 2px 0 rgba(0,0,0,.04), 0 26px 40px -26px rgba(5, 60, 40, .55);
  transform: rotate(-1deg);
  animation: tb-lay .8s var(--t-spring) .08s both;
}
@keyframes tb-lay { from { transform: translateY(40px) rotate(-5deg) scale(.96); } }
@media (min-width: 600px) { .tb-card { --tb-card-px: 32px; padding: 30px var(--tb-card-px) 26px; } }
.tb-card-k { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; padding-bottom: 14px; font: 600 .8125rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--t-ink-2); }
/* The fold of a table tent, drawn: a hairline across the card under the kicker, edge to edge. It hangs from the
   kicker's own bottom, so a kicker that wraps to two lines on a phone pushes the fold down instead of being struck through. */
.tb-card-k::after { content: ""; position: absolute; left: calc(-1 * var(--tb-card-px)); right: calc(-1 * var(--tb-card-px)); bottom: 0; border-top: 1.5px dashed var(--t-line); pointer-events: none; }
.tb-card-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t-mint); }
#tb-card-kind { color: var(--tb-mint-text); }
.tb-q {
  margin: 26px 0 16px; max-width: 22ch;
  font-size: clamp(1.75rem, 6.4vw, 2.75rem); line-height: 1.02; font-weight: 800; letter-spacing: -.02em; text-wrap: balance;
  overflow-wrap: anywhere;
}
.tb-q:focus { outline: none; }
@media (min-width: 1000px) { .tb-q { font-size: clamp(2.25rem, 3.2vw, 3rem); } }
.tb-small { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; font-size: 1.0625rem; line-height: 1.4; }
.tb-small-k {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px; border-radius: 999px;
  background: var(--t-mint); color: var(--tb-ink); font: 600 .75rem/1.2 var(--t-mono); letter-spacing: .04em; text-transform: uppercase;
}
.tb-last { margin: 18px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--t-surface); box-shadow: inset 4px 0 0 var(--t-mint); }
.tb-last-k { margin: 0 0 6px; font: 600 .75rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tb-mint-text); }
.tb-last ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tb-last li { line-height: 1.4; overflow-wrap: anywhere; }
.tb-last b { font-weight: 700; }
.tb-card-keys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
@media (max-width: 599px) { .tb-card-keys > .tb-key { flex: 1 1 100%; } }
.tb-same { margin: 14px 4px 0; font-size: .875rem; line-height: 1.4; color: var(--t-ink); }

/* ---------- Keys and chips ---------- */
body.tb .tb-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.tb .tb-key:active { transform: translateY(2px) scale(.97); }
body.tb .tb-key:disabled { cursor: default; opacity: .6; }
body.tb .tb-key[hidden] { display: none; }
body.tb .tb-key-ink { background: var(--t-ink); color: var(--t-surface); box-shadow: inset 0 -4px 0 rgba(255,255,255,.14); font-weight: 700; }
body.tb .tb-key-ghost { background: transparent; color: var(--t-ink); box-shadow: inset 0 0 0 2px var(--t-ink); }
body.tb .tb-key-lemon { background: var(--t-lemon); color: var(--tb-ink); font-weight: 800; box-shadow: inset 0 -4px 0 rgba(0,0,0,.16); }
body.tb .tb-key-s { min-height: 44px; padding: 8px 14px; font-size: .875rem; }
body.tb .tb-key[aria-pressed="true"] { background: var(--t-mint); color: var(--tb-ink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.16); }
body.tb .tb-card :focus-visible { outline: 3px solid var(--t-ink); outline-offset: 3px; }

.tb-app { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; }
.tb-h2 { margin: 0 0 8px; font-size: 1.75rem; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
@media (min-width: 900px) { .tb-h2 { font-size: 2.25rem; } }
.tb-sub { margin: 0 0 18px; max-width: 64ch; color: var(--t-ink-2); }

/* ---------- What they said tonight ---------- */
.tb-keep { padding: 22px 18px; border-radius: var(--t-r-l); background: var(--t-card); box-shadow: inset 0 0 0 1.5px var(--t-line); }
.tb-keep:focus { outline: none; }
@media (min-width: 600px) { .tb-keep { padding: 28px 30px; } }
.tb-keep-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; }
.tb-keep-state { margin: 0; font: 600 .875rem/1.3 var(--t-mono); color: var(--tb-mint-text); }
.tb-names { display: grid; gap: 10px; margin: 0 0 20px; }
.tb-names-label { margin: 0; font-weight: 700; }
.tb-name-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tb-name-list:empty { display: none; }
.tb-name {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 0 0 14px; border-radius: var(--t-r-btn, 10px);
  background: var(--t-surface); box-shadow: inset 0 0 0 1.5px var(--t-line); font-weight: 600;
}
body.tb .tb-name-x { min-width: 44px; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--t-r-btn, 10px); background: transparent; color: var(--t-ink-2); cursor: pointer; font: 600 .8125rem/1 var(--t-display); }
body.tb .tb-name-x:focus-visible, body.tb .tb-suggest:focus-visible { outline: 3px solid var(--t-ink); outline-offset: 1px; }
.tb-name-form { display: flex; gap: 8px; max-width: 420px; }
.tb-name-form input, .tb-field select, .tb-said textarea {
  min-height: 48px; min-width: 0; width: 100%; padding: 10px 14px; border: 0; border-radius: var(--t-r-s);
  background: var(--t-surface); color: var(--t-ink); font: 500 1rem/1.35 var(--t-display);
  box-shadow: inset 0 0 0 1.5px var(--t-line);
}
.tb-name-form input::placeholder, .tb-said textarea::placeholder { color: var(--t-ink-2); opacity: 1; }
.tb-name-form input:focus-visible, .tb-field select:focus-visible, .tb-said textarea:focus-visible { outline: 3px solid var(--t-ink); outline-offset: 1px; }
.tb-name-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9375rem; color: var(--t-ink-2); }
.tb-name-hint[hidden] { display: none; }
body.tb .tb-suggest {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border: 0; border-radius: var(--t-r-btn, 10px); cursor: pointer;
  background: transparent; color: var(--t-ink); font: 600 .9375rem/1.2 var(--t-display); box-shadow: inset 0 0 0 1.5px var(--t-line);
}
body.tb .tb-suggest::before { content: "+"; margin-right: 6px; color: var(--tb-mint-text); font-weight: 800; }
.tb-said { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 800px) { .tb-said { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tb-said:empty { display: none; }
.tb-said label { display: grid; gap: 6px; }
.tb-said-who { font-weight: 700; color: var(--tb-mint-text); overflow-wrap: anywhere; }
.tb-said textarea { min-height: 76px; resize: vertical; }
.tb-said-keys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
@media (max-width: 599px) { .tb-said-keys > .tb-key { flex: 1 1 100%; } }
.tb-said-away { grid-column: 1 / -1; margin: 0; color: var(--t-ink-2); overflow-wrap: anywhere; }
.tb-said-empty { margin: 0; padding: 16px; border-radius: var(--t-r-m); background: var(--t-surface); color: var(--t-ink-2); }

/* ---------- The table book ---------- */
.tb-book:focus { outline: none; }
.tb-book-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; }
.tb-book-count { margin: 0; font: 600 .9375rem/1.3 var(--t-mono); font-variant-numeric: tabular-nums; }
.tb-months { display: grid; gap: 28px; }
.tb-month h3 { margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1.5px solid var(--t-line); font: 600 .75rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--t-ink-2); }
.tb-nights { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 700px) { .tb-nights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .tb-nights { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tb-night { display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; padding: 16px; border-radius: var(--t-r-m); background: var(--t-card); box-shadow: inset 0 0 0 1.5px var(--t-line); }
.tb-night.is-tonight { box-shadow: inset 0 0 0 3px var(--t-mint); }
.tb-night-day { margin: 0; font: 600 .75rem/1.3 var(--t-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--t-ink-2); }
.tb-night-q { margin: 0; font-size: 1.0625rem; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.tb-night ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tb-night li { line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; }
.tb-night li b { color: var(--tb-mint-text); font-weight: 700; }
.tb-night-none { margin: 0; color: var(--t-ink-2); font-size: .9375rem; }
body.tb .tb-night-x { justify-self: start; min-height: 44px; padding: 8px 12px; font-size: .8125rem; font-weight: 500; }
.tb-empty { margin: 0; padding: 18px; border-radius: var(--t-r-m); background: var(--t-surface-2); color: var(--t-ink-2); }
.tb-book-keys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.tb-book-keys:not(:has(.tb-key:not([hidden]))) { display: none; }
@media (max-width: 599px) { .tb-book-keys > .tb-key { flex: 1 1 100%; } }

/* ---------- Reminder, how it works, keep ---------- */
.tb-remind-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.tb-field { display: grid; flex: 0 1 12em; gap: 6px; font-size: .875rem; font-weight: 600; color: var(--t-ink-2); }
.tb-fine { margin: 10px 0 0; font-size: .875rem; color: var(--t-ink-2); }
.tb-plain-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 32px; max-width: 1000px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 800px) { .tb-plain-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tb-plain-list li { padding-left: 16px; border-left: 3px solid var(--t-mint); color: var(--t-ink-2); line-height: 1.45; }
.tb-plain-list strong { display: block; color: var(--t-ink); }
.tb-keepnote { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-top: 18px; border-top: 1.5px solid var(--t-line); }
.tb-note { flex: 1 1 22em; margin: 0; font-size: .9375rem; color: var(--t-ink-2); }

/* ---------- On the table: the question full screen, printed twice ---------- */
.tb-table {
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0;
  background: #0f1312; color: #f2f0ea;
}
.tb-table::backdrop { background: #0f1312; }
.tb-table[open] { animation: tb-table-in .35s var(--t-out) both; }
@keyframes tb-table-in { from { transform: translateY(24px) scale(.98); } }
.tb-table-in {
  display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; height: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.tb-table-copy {
  display: grid; place-items: center; margin: 0; overflow: auto; text-align: center;
  font-size: clamp(1.625rem, 6.5vw, 4rem); line-height: 1.08; font-weight: 800; letter-spacing: -.015em; text-wrap: balance;
}
.tb-table-copy span { max-width: 20ch; overflow-wrap: anywhere; }
.tb-table-far { transform: rotate(180deg); color: #cfd6d2; }
.tb-table.is-small .tb-table-copy { font-size: clamp(2rem, 8vw, 4.75rem); }
.tb-table-mid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 0; border-top: 1.5px dashed rgba(242,240,234,.3); border-bottom: 1.5px dashed rgba(242,240,234,.3); }
.tb-table-k { margin: 0; font: 600 .8125rem/1.3 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--t-mint); }
.tb-table-keys { display: flex; flex-wrap: wrap; gap: 8px; }
body.tb .tb-table .tb-key:not(.tb-key-lemon):not([aria-pressed="true"]) { background: transparent; color: #f2f0ea; box-shadow: inset 0 0 0 1.5px rgba(242,240,234,.6); }
body.tb .tb-table :focus-visible { outline: 3px solid var(--t-lemon); outline-offset: 2px; }
/* In landscape on a phone the two copies sit side by side, each facing its own side of the table. */
@media (orientation: landscape) and (max-height: 520px) {
  .tb-table-in { grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tb-table-mid { grid-column: 1 / -1; grid-row: 2; }
  .tb-table-copy { font-size: clamp(1.25rem, 4.2vw, 2.5rem); }
}

/* ---------- Status (one toast at the bottom, as on /dinners/) ---------- */
.tb-status {
  position: fixed; z-index: 10000; left: 0; right: 0;
  bottom: calc(16px + var(--tb-toast-lift, 0px) + env(safe-area-inset-bottom, 0px));
  width: min(100% - 2 * var(--tb-gutter), 560px); margin: 0 auto; pointer-events: none;
}
.tb-toast {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px;
  padding: 8px 8px 8px 18px; border-radius: var(--t-r-m);
  background: var(--t-ink); color: var(--t-surface); pointer-events: auto;
  box-shadow: inset 0 -4px 0 rgba(255,255,255,.12), 0 22px 44px -16px rgba(0,0,0,.55);
  animation: tb-toast-in var(--t-base) var(--t-spring);
}
@keyframes tb-toast-in { from { transform: translateY(18px) scale(.97); } }
.tb-toast-keys { display: flex; flex: none; gap: 6px; margin-left: auto; }
.tb-toast-t { flex: 1 1 12em; min-width: 0; padding: 6px 0; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
body.tb .tb-toast-a, body.tb .tb-toast-x {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px;
  border: 0; border-radius: var(--t-r-btn, 10px); cursor: pointer; text-decoration: none;
  font: 700 .9375rem/1.2 var(--t-display);
}
body.tb .tb-toast-a { background: var(--t-surface); color: var(--t-ink); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
body.tb .tb-toast-x { background: transparent; color: var(--t-surface); font-weight: 600; box-shadow: inset 0 0 0 1.5px currentColor; }
body.tb .tb-toast :focus-visible { outline: 3px solid var(--t-lemon); outline-offset: 2px; }
body.tb .tb-toast-a:active, body.tb .tb-toast-x:active { transform: translateY(2px) scale(.97); }

.tb-real { margin-top: 48px; padding: 26px 22px; border-radius: var(--t-r-l); background: var(--t-surface-2); }
.tb-real .t-label { margin: 0 0 10px; color: var(--t-ink-2); }
.tb-real h2 { margin: 0 0 10px; max-width: 24ch; font-size: 1.75rem; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.tb-real p { margin: 0 0 16px; max-width: 62ch; color: var(--t-ink-2); }
@media (min-width: 900px) { .tb-real { padding: 36px 40px; } .tb-real h2 { font-size: 2.25rem; } }

@media (prefers-reduced-motion: reduce) {
  .tb-mast h1, .tb-card, .tb-toast, .tb-table[open] { animation: none !important; }
  body.tb .tb-key:active, body.tb .tb-toast-a:active, body.tb .tb-toast-x:active { transform: none; }
}

/* ---------- Print: the table book only ---------- */
@media print {
  body.tb { padding: 0; background: #fff; color: #000; }
  body.tb .site-head, body.tb .site-foot, .tb-top, .tb-keep, .tb-remind, .tb-plain, .tb-keepnote, .tb-real, .tb-status,
  .tb-book-keys, .tb-night-x, .tb-book-sub, #sosw-consent-banner, .app-bar { display: none !important; }
  .tb-book-head h2 { font-size: 24pt; }
  .tb-night { break-inside: avoid; box-shadow: none; border: 1px solid #999; background: #fff; }
  .tb-nights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-night li b { color: #000; }
}
