/* ═══════════════════════════════════════════════════════════════════════════
   GRAND ATLANTIC — Table Day (/day/)
   The lobby's world (obsidian, crest gold, Playfair / Cinzel / Jost) with IBM
   Plex Mono for every number. One authored motion: the pass PRINTS on Deal
   and the first stub TEARS. Everything else ≤250ms ease-out from a visible
   state; :active scale(.97) on every pressable; transform/opacity only.
   Sections: 1 tokens · 2 shell · 3 boarding pass · 4 brief · 5 controls ·
             6 debrief · 7 motion · 8 responsive + a11y branches
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1 · tokens ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #0a0908;
  --panel: #14100d;
  --panel-2: #1b1610;
  --ink: #f4ead2;
  --ink-2: #cdb787;          /* secondary, tinted from the gold — never gray */
  --muted: #a89877;
  --gold: #e2b755;
  --gold-hi: #f7df9a;
  --gold-dim: #8a6d33;       /* hairlines and perforations only — 3.9:1, never text */
  --gold-low: #a3843f;       /* struck / abandoned stub text — 5.6:1 on the panel */
  --gold-ink: #1a1408;       /* text on a gold surface */
  --line: rgba(226, 183, 85, .20);
  --line-strong: rgba(226, 183, 85, .42);
  --up: #7fd8a5;             /* stamped net, up   — 9.1:1 on obsidian */
  --down: #ff8a97;           /* stamped net, down — 7.4:1 on obsidian */
  --display: 'Playfair Display', 'Cinzel', 'Didot', 'Hoefler Text', Garamond, Georgia, 'Times New Roman', serif;
  --disp: 'Cinzel', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --body: 'Jost', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --press: 120ms;
  --quick: 200ms;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 400 15px/1.5 var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 420px at 50% -160px, rgba(226, 183, 85, .11), transparent 60%),
    var(--bg);
}
::selection { background: rgba(226, 183, 85, .35); color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
b, strong { font-weight: 600; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ── 2 · shell ──────────────────────────────────────────────────────────── */
.day {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
}
/* top row: the way out (left) sits clear of the fixed profile pill (right) */
.day-top {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 44px; padding-right: 150px;
}
.lobby-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 4px;
  color: var(--ink-2); text-decoration: none;
  font: 500 11.5px/1 var(--disp); letter-spacing: .14em; text-transform: uppercase;
  transition: color 150ms ease;
}
.lobby-link .ga-ico { font-size: 14px; color: var(--gold); }

.view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.view[hidden] { display: none; }

/* ── 3 · the boarding pass ──────────────────────────────────────────────── */
.pass { margin: 6px 0 0; }
.strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 28px -14px rgba(0, 0, 0, .8);
  overflow: visible;
}
.stub {
  position: relative;
  min-width: 0; min-height: 64px;
  padding: 11px 6px 9px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  text-align: center;
  color: var(--muted);
  border-radius: 0;
}
.stub:first-child { border-radius: 11px 0 0 11px; }
.stub:last-child { border-radius: 0 11px 11px 0; }
/* the perforation: a dashed hairline between stubs, with a notch top and bottom */
.stub + .stub::before {
  content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 0;
  border-left: 1px dashed var(--gold-dim);
}
.stub + .stub::after {
  content: ""; position: absolute; left: -6px; top: -1px; bottom: -1px; width: 11px;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0, var(--bg) 4.5px, transparent 5.2px),
    radial-gradient(circle at 50% 100%, var(--bg) 4.5px, transparent 5.2px);
}
.stub-name {
  font: 700 clamp(8.5px, 2.35vw, 10.5px)/1 var(--disp);
  letter-spacing: .06em; white-space: nowrap; max-width: 100%;
}
.stub-num {
  font: 500 clamp(10px, 2.7vw, 12px)/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; max-width: 100%;
  color: var(--ink-2);
}
.stub-note {
  font: 400 9.5px/1 var(--body); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
/* pending · current · done · skipped · cant-afford · abandoned */
.stub.is-pending { color: var(--muted); }
.stub.is-pending .stub-num { color: var(--muted); }
.stub.is-current {
  color: var(--gold-ink); background: var(--gold);
  border-radius: 4px;
  transform: translateY(5px) rotate(-1.2deg);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .9);
  z-index: 1;
}
.stub.is-current .stub-num, .stub.is-current .stub-note { color: var(--gold-ink); }
.stub.is-current::before, .stub.is-current + .stub::before { border-left-style: solid; border-left-color: var(--gold-dim); }
.stub.is-done { color: var(--ink-2); }
.stub.is-done .stub-num { color: var(--ink); }
.stub.is-done .stub-num.up { color: var(--up); }
.stub.is-done .stub-num.down { color: var(--down); }
.stub .stamp {
  display: inline-block; padding: 2px 5px;
  border: 1px solid currentColor; border-radius: 3px;
  transform: rotate(-4deg);
  font: 600 clamp(9.5px, 2.6vw, 11.5px)/1.1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stub.is-struck { color: var(--gold-low); }
.stub.is-struck .stub-name, .stub.is-struck .stub-num { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--gold-low); }
.pass.is-abandoned .stub { color: var(--gold-low); }
.pass.is-abandoned .stub .stub-num, .pass.is-abandoned .stub .stub-note { color: var(--gold-low); }

/* under the strip: serial + dealt-at, the pass's own small print */
.pass-meta {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 9px 2px 0;
  font: 500 11px/1.3 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.pass-meta .serial { letter-spacing: .08em; }
.pass-meta .stampline { color: var(--muted); text-align: right; }

/* the big diagonal stamp across an abandoned pass */
.pass-stamp {
  margin: 12px auto 0; width: max-content;
  padding: 6px 14px;
  border: 2px solid var(--down); border-radius: 6px;
  color: var(--down);
  font: 700 13px/1 var(--disp); letter-spacing: .28em; text-transform: uppercase;
  transform: rotate(-6deg);
}

/* ── 4 · the brief / the deal card ──────────────────────────────────────── */
.card {
  margin: 14px 0 0;
  padding: 16px 16px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel);
}
.card h1, .card h2 {
  margin: 0;
  font: 700 clamp(24px, 6.6vw, 30px)/1.08 var(--display);
  letter-spacing: -.01em; color: var(--gold-hi);
  text-wrap: balance;
}
.card h2, .card h1.debrief-h { font-size: clamp(21px, 5.6vw, 26px); }
.why { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.4; text-wrap: pretty; }

.ledger { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
.ledger li {
  display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start;
  padding: 4px 0;
  font: 500 12.5px/1.45 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ledger .ga-ico { font-size: 15px; color: var(--gold); margin-top: 2px; }
.ledger .warn { color: var(--down); }

.notice { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.notice h3, .reps h3 {
  margin: 0 0 3px;
  font: 700 11px/1.2 var(--disp); letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
}
.notice p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink); text-wrap: pretty; }

.reps { margin: 12px 0 0; }
.reps ul { list-style: none; margin: 0; padding: 0; }
.reps li {
  display: grid; grid-template-columns: 16px 1fr; gap: 9px; align-items: start;
  padding: 3px 0;
  font-size: 13px; line-height: 1.4; color: var(--ink);
}
.reps li::before {
  content: ""; width: 12px; height: 12px; margin-top: 4px;
  border: 1.5px solid var(--gold-dim); border-radius: 3px;
}
.reps li.is-done::before { background: var(--gold); border-color: var(--gold); }
.reps .rep-n { color: var(--ink-2); font: 500 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; }

/* the deal card: mode chips + refresher of what a day is */
.modes { display: flex; gap: 8px; margin: 12px 0 0; }
.mode {
  flex: 1 1 0; min-height: 44px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: transparent; color: var(--ink-2);
  font: 500 13px/1.2 var(--body);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform var(--press) ease-out;
}
.mode[aria-checked="true"] { background: rgba(226, 183, 85, .14); border-color: var(--gold); color: var(--gold-hi); }
.mode:active { transform: scale(.97); }
.deal-lines { margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); }
.deal-lines p { margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: var(--ink); text-wrap: pretty; }
.deal-lines p:last-child { margin-bottom: 0; }
.deal-lines .n { font: 500 12.5px/1 var(--mono); color: var(--gold-hi); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── 5 · controls ───────────────────────────────────────────────────────── */
.actions { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.btn {
  appearance: none; -webkit-appearance: none;
  width: 100%; min-height: 52px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  font: 600 13px/1 var(--body); letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold-ink);
  background: linear-gradient(180deg, #f7df9a, #e2b755 55%, #cca23f);
  cursor: pointer;
  transition: transform var(--press) ease-out, box-shadow var(--quick) var(--ease-out), border-color 150ms ease, color 150ms ease;
  box-shadow: 0 8px 22px -10px rgba(226, 183, 85, .55);
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; cursor: default; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--gold); border-color: var(--line-strong);
  box-shadow: none; min-height: 48px;
}
.btn-text {
  background: transparent; color: var(--ink-2); box-shadow: none; border: 0;
  min-height: 44px; letter-spacing: .12em; font-size: 12px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row .btn { letter-spacing: .08em; font-size: 12px; padding: 0 10px; }
@media (hover: hover) and (pointer: fine) {
  .btn:not(.btn-text):not([disabled]):hover { box-shadow: 0 10px 26px -10px rgba(226, 183, 85, .75); }
  .btn-ghost:hover { border-color: var(--gold); }
  .btn-text:hover { color: var(--gold-hi); }
  .lobby-link:hover { color: var(--gold-hi); }
  .mode:not([aria-checked="true"]):hover { border-color: var(--gold); color: var(--gold-hi); }
}

/* ── 6 · the debrief ────────────────────────────────────────────────────── */
.verdict { list-style: none; margin: 10px 0 0; padding: 0; }
.verdict li {
  position: relative; padding: 4px 0 4px 16px;
  font-size: 13.5px; line-height: 1.45; color: var(--ink); text-wrap: pretty;
}
.verdict li::before { content: ""; position: absolute; left: 0; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.score { font: 500 12px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; margin-left: 10px; white-space: nowrap; }
.paid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line);
}
.paid > div { min-width: 0; }
.paid em {
  display: block; font: 700 10.5px/1.2 var(--disp); letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); font-style: normal;
}
.paid b {
  display: block; margin-top: 3px;
  font: 600 clamp(20px, 5.6vw, 24px)/1.1 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.paid b.up { color: var(--up); }
.paid b.down { color: var(--down); }
.paid small { display: block; margin-top: 3px; font: 400 11px/1.3 var(--body); color: var(--muted); }
.reach { margin: 10px 0 0; font: 400 12.5px/1.45 var(--body); color: var(--ink-2); text-wrap: pretty; }
.reach .n { font: 500 12px/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }

.live-note { margin: 8px 2px 0; font: 400 11.5px/1.4 var(--body); color: var(--muted); }
.live-note[hidden] { display: none; }

/* ── 7 · motion ─────────────────────────────────────────────────────────── */
/* THE authored moment: the pass prints left→right (40ms stagger, ≤320ms in
   all), then the first stub tears along its perforation (180ms). */
@keyframes stubPrint {
  from { opacity: 0; transform: translateX(-22px); }
  to   { opacity: 1; transform: translateX(0); }
}
.strip.is-printing .stub {
  animation: stubPrint 160ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.stub { transition: transform 180ms var(--ease-out), background-color 180ms ease, color 180ms ease, box-shadow 180ms ease; }
/* the stamp lands: from a visible, slightly larger state, 200ms ease-out */
.stamp.is-landing { animation: stampLand 200ms var(--ease-out) both; }
@keyframes stampLand {
  from { opacity: .6; transform: rotate(-4deg) scale(1.08); }
  to   { opacity: 1; transform: rotate(-4deg) scale(1); }
}
/* a view swap is a crossfade from the previous frame, never a slide */
.view.is-entering { animation: viewIn 180ms var(--ease-out) both; }
@keyframes viewIn { from { opacity: .4; } to { opacity: 1; } }

/* ── 8 · responsive + accessibility branches ───────────────────────────── */
@media (max-width: 440px) {
  .ledger li { font-size: 12px; gap: 9px; }
}
@media (max-width: 400px) {
  .day { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px 13px 12px; }
  .stub { padding: 10px 4px 8px; }
}
@media (max-height: 700px) {
  .day { padding-top: 6px; }
  .day-top { min-height: 40px; }
  .pass { margin-top: 4px; }
  .stub { min-height: 56px; padding: 8px 5px 7px; gap: 4px; }
  .pass-meta { margin-top: 5px; }
  .card { margin-top: 8px; padding: 13px 14px 12px; }
  .card h1 { font-size: clamp(22px, 6vw, 26px); }
  .why { margin-top: 4px; font-size: 13px; }
  .ledger { margin-top: 9px; padding-top: 7px; }
  .ledger li { padding: 3px 0; line-height: 1.4; }
  .notice { margin-top: 9px; padding: 8px 11px; }
  .reps { margin-top: 9px; }
  .reps li { padding: 2px 0; }
  .reps li, .notice p { font-size: 12.5px; }
  .actions { padding-top: 6px; gap: 4px; }
  .verdict { margin-top: 6px; }
  .verdict li { padding: 2px 0 2px 16px; font-size: 13px; }
  .paid { margin-top: 8px; padding-top: 7px; }
  .paid b { font-size: 20px; }
  .reach { margin-top: 8px; font-size: 12px; }
}
@media (min-width: 720px) {
  .day { max-width: 600px; padding-top: 18px; min-height: 0; }
  .day-top { padding-right: 190px; }
  .actions { margin-top: 0; padding-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes stubPrint { from { opacity: 0; } to { opacity: 1; } }
  @keyframes stampLand { from { opacity: .6; } to { opacity: 1; } }
  .strip.is-printing .stub { animation-duration: 160ms; animation-delay: 0ms; }
  .stub { transition: background-color 180ms ease, color 180ms ease; }
  .stub.is-current { transform: none; }
  .btn:active, .mode:active { transform: none; }
  .view.is-entering { animation: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .mode[aria-checked="true"] { background: #2a2110; }
  .strip { box-shadow: none; }
}
@media (prefers-contrast: more) {
  .card, .strip { border-color: var(--gold); }
  .stub + .stub::before { border-left-color: var(--gold); }
  .stub.is-pending, .stub-note { color: var(--ink-2); }
}

/* The shared achievement toast rises from the bottom edge — exactly where
   this page keeps its primary actions (52 + 6 + 40/44 px + the safe area). It
   keeps its own entrance and exit; only its resting height moves up, so it
   lands over the situational card at the foot of the debrief and never over
   the strip, the verdict, or a control. achievements.css is injected after
   this sheet, so the override carries the extra specificity. */
body > .ga-ach-toast { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }
