/* =========================================================================
   PokerBench design tokens
   ========================================================================= */

:root {
  --ground:       oklch(0.985 0.005 70);
  --surface:      oklch(0.960 0.008 70);
  --ink:          oklch(0.180 0.015 80);
  --ink-muted:    oklch(0.500 0.012 80);
  --ink-faint:    oklch(0.760 0.008 80);
  --ink-hairline: oklch(0.870 0.008 80);

  --accent:       oklch(0.585 0.21 30);
  --accent-soft:  oklch(0.940 0.06 30);

  --gain:         oklch(0.560 0.13 150);
  --gain-soft:    oklch(0.560 0.13 150 / 0.62);
  --loss:         oklch(0.560 0.18 28);
  --loss-soft:    oklch(0.560 0.18 28 / 0.62);

  /* Row-fill bar colors. Soft enough that text reads on top of them. */
  --gain-bar:     oklch(0.560 0.13 150 / 0.16);
  --loss-bar:     oklch(0.560 0.18 28 / 0.16);
  --accent-bar:   oklch(0.585 0.21 30 / 0.18);
  --ink-bar:      oklch(0.180 0.015 80 / 0.09);
  --baseline-bar: oklch(0.180 0.015 80 / 0.06);

  --container-max:  1080px;
  --container-pad:  clamp(20px, 4vw, 40px);

  --row-h:          56px;
  --row-h-compact:  48px;

  --easing:   cubic-bezier(0.22, 1, 0.36, 1);
  --dur:      220ms;
  --dur-slow: 320ms;

  color-scheme: light;
}

/* Register the bar endpoints so width changes tween smoothly.
   inherits: true is required because the bar paint happens on tr::after,
   which needs to read the value set on the parent tr. */
@property --bar-from {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 50%;
}
@property --bar-to {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 50%;
}

/* =========================================================================
   Reset and base
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
}

html {
  font-family: 'Inter var', Inter, -apple-system, BlinkMacSystemFont,
               'Segoe UI', system-ui, sans-serif;
  font-feature-settings: 'tnum' 1, 'ss01' 1, 'cv11' 1, 'cv02' 1;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  line-height: 1.55;
}

body { min-height: 100dvh; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur) var(--easing);
}
a:hover { color: var(--accent); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* =========================================================================
   Layout primitives
   ========================================================================= */

.page {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: clamp(28px, 5vw, 56px) var(--container-pad) 96px;
}

/* =========================================================================
   Header
   ========================================================================= */

.masthead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 24px;
  padding-bottom: 8px;
}

.wordmark {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wordmark .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 999px;
  transform: translateY(-1px);
}

.meta {
  justify-self: end;
  display: flex;
  gap: 18px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.meta .tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.meta .tag-beta {
  border-color: var(--accent);
  color: var(--accent);
}

/* =========================================================================
   Lede
   ========================================================================= */

.lede {
  margin: 32px 0 0;
  font-size: clamp(1.875rem, 1.1rem + 2.6vw, 2.625rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  max-width: 22ch;
}

.lede em {
  font-style: normal;
  color: var(--accent);
}

.sub {
  margin: 18px 0 36px;
  color: var(--ink-muted);
  font-size: 1.0625rem;
  max-width: 60ch;
}

/* =========================================================================
   Heavy rule
   ========================================================================= */

.rule {
  height: 2px;
  background: var(--ink);
  margin: 0;
  border: 0;
}

/* =========================================================================
   Tab bar
   ========================================================================= */

.tabs-row {
  border-bottom: 1px solid var(--ink-hairline);
  display: flex;
  align-items: center;
}

.tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 20px 0 0;
  overflow-x: auto;
  /* overflow-x: auto would normally coerce overflow-y to auto too (per spec),
     which lets the mousewheel scroll the tabs vertically. Pin y-axis to
     visible-but-clip and grow the clip margin so the underline at bottom:-1px
     still paints. */
  overflow-y: clip;
  overflow-clip-margin: 4px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

/* A single sliding underline replaces the per-tab scaleX rule. JS sets
   --ind-x and --ind-w to the active tab's offsetLeft / offsetWidth, and
   the indicator translates between positions with an exponential ease. */
.tabs::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  width: var(--ind-w, 0);
  transform: translateX(var(--ind-x, 0));
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1),
              width     420ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  will-change: transform, width;
}

.tab {
  position: relative;
  padding: 14px 0;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-muted);
  white-space: nowrap;
  transition: color var(--dur) var(--easing);
}

.tab[aria-selected='true'] { color: var(--ink); }
.tab:hover:not([aria-selected='true']) { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .tabs::after { transition: none; }
}

.tabs-meta {
  margin-left: auto;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  white-space: nowrap;
  text-transform: uppercase;
}

/* =========================================================================
   Caption above the table
   ========================================================================= */

.caption {
  margin: 24px 0 20px;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  max-width: 70ch;
  min-height: 1.55em;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .caption { transition: opacity 120ms linear; transform: none !important; }
}

/* =========================================================================
   Leaderboard table
   ========================================================================= */

.board {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.board thead th {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: left;
  padding: 0 18px 14px;
  vertical-align: bottom;
  border-bottom: 1px solid var(--ink-faint);
  white-space: nowrap;
  cursor: default;
}

.board thead th .th-sub {
  display: block;
  margin-top: 3px;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--ink-faint);
  font-weight: 400;
}

.board thead th.sortable {
  cursor: pointer;
  transition: color var(--dur) var(--easing);
}
.board thead th.sortable:hover { color: var(--ink); }

.board thead th:first-child { padding-left: 0; }
.board thead th:last-child  { padding-right: 0; }

.board thead th[aria-sort='descending'] .th-title::after,
.board thead th[aria-sort='ascending']  .th-title::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  vertical-align: middle;
}
.board thead th[aria-sort='descending'] .th-title::after {
  border-top: 5px solid var(--ink);
}
.board thead th[aria-sort='ascending'] .th-title::after {
  border-bottom: 5px solid var(--ink);
}

.board th.num,
.board td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board tbody tr {
  position: relative;
  height: var(--row-h);
  --bar-from: 50%;
  --bar-to: 50%;
  --bar-color: var(--ink-bar);
  background-color: transparent;
  transition: background-color 120ms var(--easing);
}

.board tbody tr:hover {
  background-color: oklch(0.18 0.015 80 / 0.025);
}

/* The bar lives inside the active metric cell so it's spatially aligned with
   the value it represents. Cell becomes a positioning context for the zero
   axis and for the bar background. */
.board tbody td.lead {
  position: relative;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: 0 0;
  transition: --bar-from var(--dur-slow) var(--easing),
              --bar-to   var(--dur-slow) var(--easing);
}

/* Give the score column enough room for the pivoted bar to feel substantial. */
.board th[data-col='score'],
.board td[data-col='score'] { min-width: 220px; }
.board th[data-col='vpip'],
.board td[data-col='vpip'],
.board th[data-col='pfr'],
.board td[data-col='pfr'],
.board th[data-col='agg'],
.board td[data-col='agg']   { min-width: 180px; }

/* Pivot mode (Overall): bar pivots on the score cell's center. */
.board[data-bar-mode='pivot'] tbody tr:not(.baseline) td.lead {
  background-image: linear-gradient(
    to right,
    transparent 0%,
    transparent var(--bar-from),
    var(--bar-color) var(--bar-from),
    var(--bar-color) var(--bar-to),
    transparent var(--bar-to),
    transparent 100%
  );
}

/* Fill mode (VPIP / PFR / Aggression): bar fills the lead cell from left. */
.board[data-bar-mode='fill'] tbody tr:not(.baseline) td.lead {
  background-image: linear-gradient(
    to right,
    var(--bar-color) 0%,
    var(--bar-color) var(--bar-to),
    transparent var(--bar-to),
    transparent 100%
  );
}

.board tbody td {
  padding: 0 18px;
  vertical-align: middle;
  border-bottom: 1px solid var(--ink-hairline);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--ink);
}

.board tbody td:first-child { padding-left: 0; }
.board tbody td:last-child  { padding-right: 0; }

/* Row-fill bar at the bottom of each row ---------------------------------- */

/* Zero axis: a faint 1px line at the lead cell's center on the Overall tab.
   Sits inside the score cell so it anchors the bar's pivot, not the row. */
.board[data-bar-mode='pivot'] tbody tr:not(.baseline) td.lead::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: oklch(0.18 0.015 80 / 0.22);
  transform: translateX(-0.5px);
  pointer-events: none;
  z-index: 0;
}

/* Leader on non-pivot tabs uses the default cohort ink bar (no red accent).
   Sign coloring is reserved for the Overall tab where it carries meaning. */

/* Score-sign coloring on the Overall tab's bars. */
.board[data-bar-mode='pivot'] tbody tr.pos { --bar-color: var(--gain-bar); }
.board[data-bar-mode='pivot'] tbody tr.neg { --bar-color: var(--loss-bar); }

/* Baseline always wins back the faded ink, even on pivot mode. */
.board[data-bar-mode='pivot'] tbody tr.baseline,
.board tbody tr.baseline { --bar-color: var(--baseline-bar); }

/* Score cell text color follows the sign. Placed after the leader rule so
   it overrides the lead-accent on the Overall tab without needing !important. */
.board tbody tr.pos td[data-col='score'] { color: var(--gain); }
.board tbody tr.neg td[data-col='score'] { color: var(--loss); }
.board tbody tr.baseline td[data-col='score'] { color: var(--loss-soft); }

@media (prefers-reduced-motion: reduce) {
  .board tbody tr { transition: background-color 120ms var(--easing); }
}

/* Rank column ------------------------------------------------------------- */

.board td.rank,
.board th.rank {
  width: 56px;
  padding-left: 0;
  padding-right: 0;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

.board tr.is-leader td.rank {
  color: var(--accent);
  font-weight: 600;
}

/* On the Overall tab the leader is identified by sign (winner). Match the
   rank color to the sign so it doesn't read as a loser. */
.board[data-bar-mode='pivot'] tr.is-leader.pos td.rank { color: var(--gain); }
.board[data-bar-mode='pivot'] tr.is-leader.neg td.rank { color: var(--loss); }

/* Model column ------------------------------------------------------------ */

.board td.model {
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}

.board td.model .org-prefix {
  color: var(--ink-muted);
  font-weight: 400;
}

.board td.model .baseline-tag {
  display: inline-block;
  margin-left: 12px;
  padding: 2px 7px;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  vertical-align: 1px;
}

/* Numeric columns --------------------------------------------------------- */

.board td.metric {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.005em;
}

.board td.supp {
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

.board td.hands {
  color: var(--ink-faint);
}

.board tr.is-leader td.lead {
  color: var(--accent);
}

.board td .unit {
  color: var(--ink-muted);
  font-weight: 400;
  margin-left: 2px;
  font-size: 0.875rem;
}

.board tr.is-leader td.lead .unit {
  color: oklch(0.585 0.21 30 / 0.6);
}

/* Show/hide columns per active tab ---------------------------------------- */

.board th[data-col],
.board td[data-col] { display: none; }

.board[data-tab='overall'] [data-col='score'],
.board[data-tab='overall'] [data-col='hands'],
.board[data-tab='vpip']    [data-col='vpip'],
.board[data-tab='vpip']    [data-col='hands'],
.board[data-tab='pfr']     [data-col='pfr'],
.board[data-tab='pfr']     [data-col='hands'],
.board[data-tab='agg']     [data-col='agg'],
.board[data-tab='agg']     [data-col='hands']       { display: table-cell; }

/* Baseline row: only ever shown on the Overall tab. */
.board:not([data-tab='overall']) tbody tr.baseline { display: none; }

/* Baseline visual treatment ---------------------------------------------- */

/* The baseline row is presented as a floor line, not a ranked competitor.
   It sits below the cohort with a clear separator, gets no bar, and uses
   muted text throughout. */
.board tbody tr.baseline td {
  color: var(--ink-muted);
  font-weight: 400;
  padding-top: 18px;
  padding-bottom: 18px;
  border-top: 1px dashed var(--ink-faint);
  background: transparent;
}

.board tbody tr.baseline td.metric,
.board tbody tr.baseline td.supp,
.board tbody tr.baseline td.hands {
  color: var(--ink-muted);
  font-weight: 400;
}

.board tbody tr.baseline td.rank {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 0;
}

/* Score on the baseline still picks up the loss color (softer variant)
   so the negative reads, but without the bar competing for attention. */
.board tbody tr.baseline td[data-col='score'] { color: var(--loss-soft); }

.board tbody tr.baseline:hover {
  background-color: oklch(0.18 0.015 80 / 0.02);
}

/* Cell content cross-fade during tab switches ----------------------------- */

.board[data-fading] tbody td.metric,
.board[data-fading] tbody td.hands {
  opacity: 0;
  transition: opacity 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .board[data-fading] tbody td.metric,
  .board[data-fading] tbody td.hands { transition: none; }
}

/* =========================================================================
   Methodology
   ========================================================================= */

.method {
  margin-top: 80px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px 56px;
  padding-top: 36px;
  border-top: 1px solid var(--ink-hairline);
}

.method h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.method dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 56px;
  margin: 0;
}

.method dl > div { min-width: 0; }

.method dt {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 6px;
}

.method dd {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.method dd b {
  color: var(--ink);
  font-weight: 500;
}

.method dd i {
  font-style: italic;
  color: var(--ink);
}

.method-note {
  grid-column: 2;
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px dashed var(--ink-hairline);
  color: var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 64ch;
}

.method-note b {
  color: var(--ink);
  font-weight: 500;
}

/* =========================================================================
   Footer
   ========================================================================= */

.foot {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--ink-hairline);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.foot nav a { margin-left: 20px; }
.foot nav a:first-child { margin-left: 0; }

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 880px) {
  .board tbody td   { padding: 0 12px; }
  .board thead th   { padding: 0 12px 12px; }

  /* Drop the third supporting column on narrower screens so the primary
     metric and one count remain readable. */
  .board[data-tab='overall'] [data-col='winrate'],
  .board[data-tab='vpip']    [data-col='preflopopps'],
  .board[data-tab='pfr']     [data-col='preflopopps'],
  .board[data-tab='agg']     [data-col='calls']     { display: none; }
}

@media (max-width: 720px) {
  .masthead { grid-template-columns: 1fr auto; }
  .meta { font-size: 0.75rem; gap: 10px; }
  .meta .meta-version { display: none; }

  .sub  { font-size: 1rem; }
  .tabs { gap: 18px; }
  .tabs-meta { display: none; }

  .board tbody tr   { height: var(--row-h-compact); }
  .board tbody td   { padding: 0 10px; font-size: 0.875rem; }
  .board thead th   { padding: 0 10px 12px; font-size: 0.6875rem; }
  .board td.rank,
  .board th.rank    { width: 34px; }
  .board td.model   { white-space: normal; }
  .board td .baseline-tag { margin-left: 6px; padding: 1px 5px; font-size: 0.5625rem; }
  .board td.metric  { font-size: 0.9375rem; }

  /* Tighten metric column min-widths so the cohort still fits on phones. */
  .board th[data-col='score'],
  .board td[data-col='score'] { min-width: 130px; }
  .board th[data-col='vpip'],
  .board td[data-col='vpip'],
  .board th[data-col='pfr'],
  .board td[data-col='pfr'],
  .board th[data-col='agg'],
  .board td[data-col='agg']   { min-width: 110px; }

  /* Hide every supporting column on phones; show only rank + model + primary
     metric for each tab. */
  .board [data-col='hands'],
  .board [data-col='elo'],
  .board [data-col='voluntary'],
  .board [data-col='raisedpf'],
  .board [data-col='preflopopps'],
  .board [data-col='betsraises'],
  .board [data-col='calls'],
  .board[data-tab='overall'] [data-col='winrate']  { display: none !important; }

  .method { grid-template-columns: 1fr; gap: 16px; padding-top: 24px; }
  .method dl { grid-template-columns: 1fr; gap: 20px; }
  .method-note { grid-column: 1; }
}
