/* Lapaglia HQ · "Kasboek DNA": Bankflow's design language (tokens, type, ledgers, motion). */
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 400 700; font-display: swap; src: url(/fonts/instrument-sans.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/plex-mono-400.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/plex-mono-500.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/plex-mono-600.woff2) format('woff2'); }

:root, :root[data-theme='light'] {
  --paper: #FBFBF9; --ink: #111111; --ink2: #2B2B29; --mut: #62625E; --faint: #B5B5AF;
  --line: #E4E4E0; --wash: #F3F3F0; --red: #D92D20; --pos: #17803D; --trf: #2F5BD3;
  --posbg: #E6F2EA; --cardedge: transparent;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --paper: #121211; --ink: #F2F0EA; --ink2: #D9D7D0; --mut: #A6A59E; --faint: #55554F;
  --line: #2A2A27; --wash: #1C1C1A; --red: #FF6B5B; --pos: #4CC27F; --trf: #86A4FF;
  --posbg: #16301F; --cardedge: #3A3A35;
  color-scheme: dark;
}
:root {
  --sans: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --tabs-h: 72px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mut { color: var(--mut); }
.small { font-size: 13px; }
.pos { color: var(--pos); }
.neg { color: var(--red); }
.error { color: var(--red); }

/* Theme switch: colours flow over for 300 ms, only while switching. */
.hq-theme-fade, .hq-theme-fade * { transition: background-color .3s, color .3s, border-color .3s !important; }

/* --- chrome ------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 3; background: var(--paper);
  padding-top: env(safe-area-inset-top);
  border-bottom: 2px solid var(--ink);
}
.top-inner { height: 56px; max-width: 680px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand strong { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.brand span { font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { transition: transform .35s var(--ease); }
.icon-btn:active svg { transform: rotate(-30deg); }

.content { max-width: 680px; margin: 0 auto; padding: 20px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 32px); display: flex; flex-direction: column; gap: 32px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabs button {
  appearance: none; border: 0; border-top: 2px solid transparent; margin-top: -1px; background: none;
  color: var(--mut); font-size: 13px; font-weight: 500; cursor: pointer;
}
.tabs button.active { color: var(--ink); font-weight: 600; border-top-color: var(--ink); }

/* --- hero ---------------------------------------------------------------- */
.label { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); }
.hero { display: flex; flex-direction: column; gap: 10px; }
.hero-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 52px; font-weight: 500; line-height: 1; letter-spacing: -.03em; }
.hero-sentence { font-size: 17px; line-height: 1.4; color: var(--ink2); }

/* --- ledgers ------------------------------------------------------------- */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.ledger > li > :last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.section-head h2 { font-size: 18px; font-weight: 600; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.grow1 { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.right { display: flex; flex-direction: column; align-items: flex-end; }

.tile {
  flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600; background: var(--wash); color: var(--ink2);
  outline: 1px solid var(--cardedge);
}
.tile.sm { width: 36px; height: 36px; font-size: 11px; }
.tile.lg { width: 64px; height: 64px; font-size: 16px; }

/* Official team logos: the light version on paper, the dark one in dark mode. */
.logo { flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.logo.sm { width: 36px; height: 36px; }
.logo.lg { width: 72px; height: 72px; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo .logo-dark { display: none; }
:root[data-theme='dark'] .logo .logo-light { display: none; }
:root[data-theme='dark'] .logo .logo-dark { display: block; }

/* --- items --------------------------------------------------------------- */
.feed { display: flex; flex-direction: column; gap: 32px; }
.item { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 80px; }
.item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.item h3 { font-size: 20px; font-weight: 600; line-height: 1.25; }
.item .body { line-height: 1.55; color: var(--ink2); overflow-wrap: anywhere; }
.item .body p { margin: 0 0 10px; }
.item .body p:last-child { margin: 0; }
.item .body strong { color: var(--ink); }
.item-foot { font-family: var(--mono); font-size: 12px; color: var(--mut); border-top: 1px solid var(--line); padding-top: 8px; }
.badge { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; padding: 1px 6px; border: 1px solid currentColor; color: var(--mut); }
.badge.test { color: var(--ink); }
.empty { padding: 20px 0; color: var(--mut); }

.big-change { display: flex; align-items: baseline; justify-content: space-between; }
.big-change .num { font-size: 30px; font-weight: 500; }
.ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ladder > div { display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--mut); }
.ladder .track { height: 6px; background: var(--wash); position: relative; overflow: hidden; }
.ladder .fill { position: absolute; inset: 0; background: var(--ink); }
.ladder .on { color: var(--ink); }

.scorerow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto minmax(0, 1fr) 36px; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.scorerow .score { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; text-align: center; }
.scorerow .score small { display: block; font-size: 10px; color: var(--mut); }
.scorerow .name { font-size: 14px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorerow .name.win { color: var(--ink); font-weight: 600; }
.scorerow .name.home { text-align: right; }

/* --- controls ------------------------------------------------------------ */
.btn {
  min-height: 48px; padding: 0 16px; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--ink); color: var(--paper); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--ink); }
.segmented button { min-height: 44px; border: 0; background: transparent; cursor: pointer; }
.segmented button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mut); }
.field input, .field select { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 16px; }
.field input:focus, .field select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

/* --- audio --------------------------------------------------------------- */
.player { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); }
.player .play { width: 44px; height: 44px; flex: none; border: 0; background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.player .wave { flex: 1; display: flex; align-items: flex-end; gap: 3px; height: 28px; cursor: pointer; }
.player .wave span { flex: 1; max-width: 4px; background: var(--faint); transform-origin: bottom; animation: hq-bar .6s var(--ease) both; }
.player .wave span.done { background: var(--ink); }
.player .time { font-family: var(--mono); font-size: 13px; color: var(--mut); min-width: 40px; text-align: right; }

/* --- next game / dark block ---------------------------------------------- */
.block-ink { padding: 16px; background: var(--ink); color: var(--paper); display: flex; flex-direction: column; gap: 8px; }
.block-ink .label { color: var(--paper); opacity: .7; }

/* --- segmented budget bars ----------------------------------------------- */
.cells { display: flex; gap: 3px; }
.cells span { flex: 1; height: 8px; background: var(--wash); transform-origin: left; animation: hq-grow .8s var(--ease) both; }
.cells span.used { background: var(--ink); }
.dot { width: 8px; height: 8px; flex: none; background: var(--pos); }
.dot.failed { background: var(--red); }
.dot.idle { background: var(--faint); }

/* --- auth ---------------------------------------------------------------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 56px) 16px 32px; display: flex; flex-direction: column; gap: 20px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }

/* --- toast --------------------------------------------------------------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); z-index: 5;
  max-width: 648px; margin: 0 auto; padding: 14px 16px; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; animation: hq-toast .35s var(--ease) both;
}
.toast > span { display: flex; align-items: center; gap: 10px; }
.toast .check { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hq-draw .4s ease-out .2s forwards; }
.toast button { border: 0; background: transparent; color: var(--paper); font-weight: 600; text-decoration: underline; min-height: 44px; cursor: pointer; }

/* --- misc ---------------------------------------------------------------- */
details > summary { cursor: pointer; list-style: none; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
details > summary::-webkit-details-marker { display: none; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 var(--mono); max-height: 240px; overflow: auto; color: var(--mut); }
.notice { padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* --- motion (all off under reduced motion) ------------------------------- */
@keyframes hq-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes hq-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes hq-bar { from { transform: scaleY(.15); } to { transform: scaleY(1); } }
@keyframes hq-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hq-pop { 0% { transform: scale(0); } 70% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes hq-toast { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.rise { animation: hq-rise .48s var(--ease) both; }
.grow { transform-origin: left center; animation: hq-grow .8s var(--ease) .3s both; }
.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hq-draw 1.4s ease-out .2s forwards; }
.pop { transform-box: fill-box; transform-origin: center; animation: hq-pop .4s ease-out 1.5s both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .draw, .toast .check { stroke-dashoffset: 0; }
}
