/* site.css — The Backgammon Exchange, Journal look (brief §3). Tokens + components. */

:root {
  --paper: #F4F1EA;
  --paper-raised: #FBF9F4;
  --ink: #111111;
  --ink-2: #2B2B28;
  --muted: #4A4A45;
  --faint: #706C63;
  --dotted: #B9B3A5;
  --placeholder: #E2DDD1;
  --accent: #1E4A3F;
  --up: #1E6B52;
  --down: #9A3B24;
  --tape-up: #7FCFA9;
  --tape-down: #F2A48A;
  --tape-gold: #C9B78F;

  --display: 'Playfair Display', Georgia, serif;
  --sans: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --gutter: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--serif);
}
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; }
img { display: block; max-width: 100%; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.up { color: var(--up); }
.down { color: var(--down); }

/* ── Frame ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 0;
}
.masthead-sm { font: 900 30px/1.1 var(--display); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 500 13px/1.6 var(--sans); }
.nav a[aria-current] { font-weight: 700; text-decoration-thickness: 2px; }

.edition-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 12px; padding: 12px 0; font: 500 12px/1.6 var(--sans); color: var(--muted);
}
.edition-bar .nav { font-size: 12px; }
.masthead-lg { text-align: center; border-top: 1px solid var(--ink); padding: 18px 0 10px; }
.masthead-lg a {
  font: 900 64px/1 var(--display); letter-spacing: -.01em; text-decoration: none;
}

.section-line {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
  border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink);
  padding: 7px 0; font: 600 11px/1.5 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}

.site-foot { padding-bottom: 28px; }
.site-foot > div {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--ink); padding-top: 14px;
  font: 400 12px/1.6 var(--sans); color: var(--muted);
}

.page-main { max-width: 1180px; margin: 0 auto; padding: 28px var(--gutter) 56px; }
.page-main.home { padding-top: 24px; }
.page-main.stack { display: flex; flex-direction: column; gap: 28px; }
.loading { font: 400 14px var(--sans); }

/* ── Ticker (Home only) ────────────────────────────────────────────── */

.ticker { background: var(--ink); color: var(--paper); overflow: hidden; margin-top: 10px; }
.ticker:focus-visible { outline: 2px solid var(--tape-gold); outline-offset: -2px; }
.ticker-track {
  display: flex; width: max-content; padding: 9px 0;
  font: 400 13px/1.4 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap;
  animation: ticker 60s linear infinite;
}
.ticker-copy { display: flex; gap: 36px; padding-right: 36px; }
.ticker:hover .ticker-track,
.ticker:focus-within .ticker-track { animation-play-state: paused; }
.tk-up { color: var(--tape-up); }
.tk-down { color: var(--tape-down); }
.tk-gold { color: var(--tape-gold); }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker { overflow-x: auto; }
  .ticker-track { animation: none; }
  .ticker-copy[aria-hidden="true"] { display: none; }
}

/* ── Columns: main (span 2) | side, then full width ────────────────── */

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.col-main {
  grid-column: span 2; min-width: 0; padding: 0 24px 24px 0; border-right: 1px solid var(--ink);
  display: flex; flex-direction: column; gap: 14px;
}
.col-side { min-width: 0; padding: 0 0 24px 24px; display: flex; flex-direction: column; gap: 22px; }
.col-full { grid-column: 1 / -1; min-width: 0; border-top: 3px double var(--ink); padding-top: 14px; }
/* Below three 300px tracks the side column can't sit beside the main one: stack, rule turns horizontal. */
@media (max-width: 947px) {
  .cols > * { grid-column: 1 / -1; }
  .col-main { padding-right: 0; border-right: 0; border-bottom: 1px solid var(--ink); }
  .col-side { padding-left: 0; padding-top: 24px; }
}

/* ── Type ─────────────────────────────────────────────────────────── */

.kicker { font: 700 11px/1.4 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.headline { font: 700 44px/1.08 var(--display); }
.page-title { font: 700 46px/1.08 var(--display); }
.deck { font: 400 18px/1.45 var(--sans); color: var(--ink-2); }
.story { font-size: 17px; line-height: 1.6; columns: 2 260px; column-gap: 24px; white-space: pre-line; }
.intro { font: 400 16px/1.5 var(--sans); color: var(--ink-2); margin-top: 8px; }
.note { font: 400 12px/1.5 var(--sans); color: var(--muted); }
.more { font: 600 12px/1.5 var(--sans); }
.more-inline { font-weight: 600; }
.prose { font-size: 17px; line-height: 1.65; columns: 2 260px; column-gap: 28px; }
.prose p { margin: 0 0 14px; }
.prose p:last-child { margin-bottom: 0; }
.box-text { font-size: 15px; line-height: 1.55; }
.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; }

.sec-head {
  margin-bottom: 6px; padding-bottom: 6px; border-bottom: 2px solid var(--ink);
  font: 700 13px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}
.sec-head.plain { border-bottom: 0; padding-bottom: 0; }
.side-box { border-top: 1px solid var(--ink); padding-top: 14px; }
.head-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.head-row .sec-head { border: 0; margin: 0; padding: 0; }
.title-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; }

/* ── Tables ───────────────────────────────────────────────────────── */

table { border-collapse: collapse; width: 100%; }
th {
  font: 600 10px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ink); white-space: nowrap; vertical-align: bottom;
}
td { padding: 8px; border-bottom: 1px dotted var(--dotted); font-size: 14px; line-height: 1.4; vertical-align: baseline; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.empty { font-family: var(--sans); font-size: 13px; }
tfoot td { border-bottom: 0; font: 400 12px/1.5 var(--sans); color: var(--muted); }
.compact th { padding: 5px 6px; }
.compact td { padding: 6px; font-size: 13px; }
.scroll { overflow-x: auto; }
.rule-top { border-top: 2px solid var(--ink); }
tr.lead td.name, .directory td.name { font-weight: 600; }
td.r, th.go, td.go { text-align: right; }

/* ── Controls ─────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font: 600 10px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
select {
  font: 500 14px/1.3 var(--sans); color: var(--ink); background: var(--paper-raised);
  border: 1px solid var(--ink); border-radius: 0; padding: 10px 12px; min-height: 44px; max-width: 100%;
}
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--ink); text-decoration: none; font: 600 13px/1.2 var(--sans);
}
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.dark:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btns { display: flex; flex-wrap: wrap; gap: 12px; }

/* ── Home ─────────────────────────────────────────────────────────── */

.thumb {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9;
  background: var(--placeholder); border: 1px solid var(--ink); overflow: hidden;
  font: 500 13px/1.4 var(--sans); color: var(--muted); text-decoration: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.caption { font: 400 12px/1.5 var(--sans); color: var(--muted); }
.next-date { font: 400 26px/1.25 var(--display); }
.next-line { font: 400 14px/1.5 var(--sans); color: var(--ink-2); margin-top: 4px; }
.notebook { margin: 0; padding: 0 0 0 16px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.45; }

/* ── Night ────────────────────────────────────────────────────────── */

.boxscores { border-top: 1px solid var(--ink); overflow: hidden; }
.boxscores-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); margin-left: -17px; }
.boxscore {
  padding: 14px 16px; border-left: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.boxscore-label { font: 400 11px/1.4 var(--mono); color: var(--muted); }
.boxscore table { table-layout: fixed; } /* same column positions in every card */
.boxscore td { border-bottom: 0; }
.boxscore tr:first-child td { border-bottom: 1px solid var(--dotted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.boxscore tr.won td { font-weight: 600; }
.boxscore td.score { font-size: 18px; width: 3em; }
.boxscore td.pr { color: var(--muted); width: 7em; }
.links { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 600 13px/1.5 var(--sans); }
.links .muted { font-weight: 400; }

/* ── Leaderboard explainers ───────────────────────────────────────── */

.explainers {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  border-top: 3px double var(--ink); padding-top: 16px;
}
.explainers > div { padding: 0 20px; }
.explainers > div:first-child { padding-left: 0; }
.explainers > div:last-child { padding-right: 0; }
.explainers > div + div { border-left: 1px solid var(--ink); }
.explainers h2 { font: 700 12px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.explainers p { font-size: 15px; line-height: 1.55; }
@media (max-width: 827px) {
  .explainers { grid-template-columns: minmax(0, 1fr); }
  .explainers > div { padding: 0; }
  .explainers > div + div { border-left: 0; border-top: 1px solid var(--ink); padding-top: 14px; margin-top: 14px; }
}

/* ── Calendar ─────────────────────────────────────────────────────── */

.draw td { font-size: 15px; }

/* ── Archive ──────────────────────────────────────────────────────── */

.issue {
  display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 8px 24px; align-items: baseline;
  padding: 18px 0; border-top: 1px solid var(--ink);
}
.issue:first-of-type { border-top: 2px solid var(--ink); }
.issue-date { font: 400 12px/1.5 var(--mono); color: var(--muted); text-transform: uppercase; }
.issue h2 { font: 700 26px/1.15 var(--display); }
.issue-head { text-decoration: none; }
.issue-deck { font: 400 15px/1.45 var(--sans); color: var(--ink-2); margin-top: 6px; }
.issue-links { font: 600 12px/1.5 var(--sans); white-space: nowrap; }
.issue-links .muted { font-weight: 400; }
@media (max-width: 639px) {
  .issue { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}

/* ── Players ──────────────────────────────────────────────────────── */

th[aria-sort] { padding: 0; }
.sort {
  display: flex; align-items: flex-end; width: 100%; min-height: 44px; padding: 6px 8px;
  background: none; border: 0; border-radius: 0; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; text-align: inherit;
}
th.num .sort { justify-content: flex-end; }
.sort:hover { color: var(--accent); }
.sort-mark { display: inline-block; width: 1em; text-align: center; }

/* ── Player ───────────────────────────────────────────────────────── */

.profile {
  display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; justify-content: space-between;
  border-bottom: 1px solid var(--ink); padding-bottom: 20px;
}
.profile-id { display: flex; gap: 20px; align-items: center; min-width: 0; }
.monogram {
  flex: none; width: 96px; height: 96px; border: 1px solid var(--ink); background: var(--placeholder);
  display: flex; align-items: center; justify-content: center; font: 700 48px/1 var(--display);
}
.monogram img { width: 100%; height: 100%; object-fit: cover; }
.profile-line { font: 400 15px/1.5 var(--sans); color: var(--ink-2); margin-top: 8px; }
.profile-rating { text-align: right; }
.profile-rating .label { font: 600 10px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.profile-rating .big { font: 500 40px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.profile-rating .chg { font: 400 14px/1.4 var(--mono); }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.pair > div { min-width: 0; }
.pair > div:first-child { padding-right: 24px; }
.pair > div + div { padding-left: 24px; border-left: 1px solid var(--ink); }
@media (max-width: 647px) {
  .pair > div:first-child { padding-right: 0; }
  .pair > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--ink); margin-top: 20px; padding-top: 20px; }
}
.kv th { font: 400 14px/1.4 var(--serif); letter-spacing: 0; text-transform: none; color: var(--ink); border-bottom: 1px dotted var(--dotted); padding: 8px; white-space: normal; vertical-align: baseline; }
.chart { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.chart svg { display: block; width: 100%; height: 200px; }
.chart text { font: 400 11px var(--mono); fill: var(--muted); }

/* ── Small screens ────────────────────────────────────────────────── */

@media (max-width: 639px) {
  :root { --gutter: 16px; }
  .masthead-lg a { font-size: 40px; }
  .headline, .page-title { font-size: 32px; }
  .profile-rating { text-align: left; }
}
