/* ============================================================
   Stats page — click a row to open the season card in a popup. The card
   keeps the SAA cards' accent left bar; its body is a season-by-season
   table. The card uses the light "ledger" palette (--saa-*), which is
   scoped to .saa-embed, so the modal re-declares those tokens.
   ============================================================ */

.saa-embed .stats-row { cursor: pointer; }
.saa-embed .stats-row:hover td { background: var(--saa-surface-2); }
.saa-embed .stats-row:hover td.name { color: var(--saa-accent); }
.saa-embed .stats-row:focus-visible { outline: 2px solid var(--saa-accent); outline-offset: -2px; }

/* ---------- the popup ---------- */
.stats-modal {
  /* the ledger tokens live on .saa-embed; the dialog renders in the top
     layer, outside it, so bring them along */
  --saa-surface: #ffffff;
  --saa-surface-2: #e6ebdd;
  --saa-card: #f8fdec;
  --saa-line: #d1d8c6;
  --saa-ink: #16211d;
  --saa-ink-dim: #5c6d61;
  --saa-accent: #a8660a;

  padding: 0;
  border: 1px solid var(--brass-dk);          /* thin goldish-brown, all four sides */
  border-top-width: 4px;                       /* heavier rule across the top */
  border-radius: 4px;
  background: var(--saa-card);
  color: var(--saa-ink);
  width: min(1080px, calc(100vw - 2.5rem));
  max-height: calc(100vh - 3rem);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.stats-modal::backdrop { background: rgba(7,16,13,0.62); }
.stats-modal__close {
  position: absolute;
  top: 0.55rem;
  right: 0.75rem;
  z-index: 2;
  background: none;
  border: none;
  color: var(--paper-dim);          /* sits on the dark header band */
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.stats-modal__close:hover { color: var(--brass-lt); }
.stats-modal__body {
  max-height: calc(100vh - 3rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.stats-modal .stats-card {
  box-sizing: border-box;
  padding: 1.2rem 1.4rem 1.4rem;
  font-family: var(--font-body);
  white-space: normal;
}
.stats-modal .stats-card__head {
  /* dark green band, same as the site header the wordmark sits on --
     bleeds out over the card's top + side padding */
  position: relative;
  background: var(--bg);
  border-bottom: 1px solid var(--green-line);
  margin: -1.2rem -1.4rem 1.1rem;
  padding: 0.9rem 1.4rem 0.95rem;
}
.stats-modal .stats-card__title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15rem 0.9rem;
  padding-right: 6.5rem;           /* clear the pid + close button on the right */
}
.stats-modal .stats-card__pid {
  /* pinned to the right, box-matched to the close button so the two
     line up on a shared vertical centre */
  position: absolute;
  top: 0.55rem;
  right: 2.5rem;
  height: 30px;                     /* == close button: 22px glyph + 2*4px padding */
  display: flex;
  align-items: center;
  line-height: 1;
  font-family: var(--font-mono);
  font-size: 0.78rem;               /* same as the season table */
  color: var(--brass-lt);
}
.stats-modal .stats-card__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brass-lt);          /* the wordmark's "darker yellow" */
}
.stats-modal .stats-card__bio {
  margin-top: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;              /* same as the season table */
  line-height: 1.75;
  color: var(--brass-lt);
}
.stats-modal .stats-card__sub {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--saa-ink-dim);
  padding: 0 1.4rem;
}

.stats-modal .stats-card__wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.stats-modal table.stats-seasons {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  width: 100%;
}
.stats-modal .stats-seasons th {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--saa-ink-dim);
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--saa-line);
  white-space: nowrap;
}
.stats-modal .stats-seasons th:first-child,
.stats-modal .stats-seasons td:first-child,
.stats-modal .stats-seasons th:nth-child(2),
.stats-modal .stats-seasons td:nth-child(2) { text-align: left; }
.stats-modal .stats-seasons td {
  text-align: right;
  padding: 0.28rem 0.5rem;
  border-bottom: 1px solid var(--saa-line);
  white-space: nowrap;
}
.stats-modal .stats-seasons tbody tr:last-child td { border-bottom: none; }
.stats-modal .stats-seasons tr.is-total td {
  border-top: 2px solid var(--saa-line);
  font-weight: 600;
  color: var(--saa-ink);
}
.stats-modal .stats-seasons tr.is-total td:first-child { font-family: var(--font-display); }

@media (max-width: 640px) {
  .stats-modal { width: calc(100vw - 1.5rem); }
  .stats-modal .stats-card { padding: 1rem 1rem 1.2rem; }
}
