/* Grading surfaces — Result / Note / HR (#269, #270).
 *
 * Design note
 * -----------
 * The old page rendered every HR signal as another column in an eight-column
 * table, which buried the one thing the product is actually about: a set of
 * unrelated names and dates landing on the same number. This stylesheet makes
 * that equality the hero — `.gr-chain` sets the matched families as a chain
 * joined by "=" and terminating in the shared value, typeset as a ledger line
 * rather than a table cell. Everything else on the page is deliberately quiet
 * so the chain is the thing you remember.
 *
 * Built on the existing site variables (--panel/--line/--ink/--accent/--muted)
 * and the ps-* scale in player-summary.css, so HR Grading, HR Picks and the
 * player profile stay one visual system.
 */

.gr-root {
  --gr-gutter: 3.25rem;
  --gr-radius: 12px;
  --gr-hairline: 1px solid var(--line);
  --gr-quiet: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

/* ── page header ─────────────────────────────────────────────────────────── */
.gr-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 1.25rem;
}

.gr-title { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }

.gr-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
  max-width: 62ch;
}

/* ── mode switcher: links, not tabs ──────────────────────────────────────── */
.gr-modes { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.gr-modes a { text-decoration: none; }

/* ── slate date control ──────────────────────────────────────────────────── */
.gr-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  background: var(--gr-quiet);
  border: var(--gr-hairline);
  border-radius: var(--gr-radius);
}

.gr-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.gr-field label {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.gr-field select,
.gr-field input {
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.4375rem 0.625rem;
  border: var(--gr-hairline);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.gr-nudge {
  display: flex;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
  align-items: center;
}

.gr-notice {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--color-stat);
  background: var(--gr-quiet);
  border-radius: 0 6px 6px 0;
  margin: 0 0 1rem;
}

/* ── the signature: an equality chain ────────────────────────────────────── */
.gr-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin: 0;
  line-height: 1.5;
}

.gr-term {
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  background: var(--gr-quiet);
  border: var(--gr-hairline);
  overflow-wrap: anywhere;
}

/* The cipher is a qualifier on the term, not a term of its own. */
.gr-cipher {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 0.3125rem;
}

.gr-eq {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.gr-value {
  font-size: 1.0625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0.0625rem 0.5625rem;
  border-radius: 6px;
  color: var(--panel);
  background: var(--accent-dark);
}

/* A structural match has no single shared number; say so rather than faking one. */
.gr-value.gr-structural {
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
  font-weight: 650;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── player opportunity card ─────────────────────────────────────────────── */
.gr-opp {
  display: block;
  padding: 0;
  background: var(--panel);
  border: 1px solid #c99a2e;
  border-radius: var(--gr-radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

/* Top of the board earns a heavier edge; nothing else changes, so the cue
   reads as ranking rather than as decoration. */
.gr-opp.gr-top { border-left: 3px solid var(--accent); }

.gr-opp-rank {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #d9a441;
  padding: 0;
}

.gr-opp.gr-top .gr-opp-rank { color: var(--accent); }

.gr-opp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin: 0;
  padding: 0.875rem 1rem;
  background: #111310;
  color: #fff;
  border-bottom: 4px solid #d9a441;
}

/* Sits at the far end of the card head so every row has the same, findable
   add-to-ticket target regardless of how long the player name runs. */
.gr-ticket-add {
  margin-left: auto;
  flex: 0 0 auto;
  border: 1px solid #2f6feb;
  border-radius: 7px;
  background: #2f6feb;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.gr-ticket-add:hover,
.gr-ticket-add:focus-visible {
  border-color: #2559bd;
  background: #2559bd;
  color: #fff;
}

.gr-opp-name {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 0;
  flex: 1 1 10rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.gr-opp-score {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  font-variant-numeric: tabular-nums;
}

.gr-opp-score b { font-size: 1.125rem; font-weight: 800; color: #d9a441; }
.gr-opp-score span { font-size: 0.75rem; color: #c8c9c3; }

.gr-meter {
  width: 4.5rem;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.gr-meter i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width var(--transition-base, 160ms ease);
}

.gr-opp-body { min-width: 0; padding: 0.875rem 1rem 1rem; }

.gr-opp-why {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.4375rem 0 0;
}

.gr-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1rem;
  margin: 0.625rem 0 0;
  padding-top: 0.5rem;
  border-top: var(--gr-hairline);
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gr-fact b { color: var(--ink); font-weight: 650; }

.gr-flags { display: flex; flex-wrap: wrap; gap: 0.375rem; margin: 0.5rem 0 0; }

.gr-flag {
  font-size: 0.6875rem;
  font-weight: 650;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--color-danger);
  white-space: nowrap;
}

.gr-flag.gr-info { color: var(--color-stat); }

.gr-more {
  margin: 0.625rem 0 0;
  font-size: 0.8125rem;
}

.gr-more > summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--accent-dark);
  padding: 0.125rem 0;
}

.gr-more > summary:focus-visible,
.gr-opp :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.gr-more-body { padding: 0.5rem 0 0; display: grid; gap: 0.625rem; }

.gr-group {
  padding: 0.5rem 0.625rem;
  border-left: 2px solid var(--line);
  background: var(--gr-quiet);
  border-radius: 0 6px 6px 0;
}

.gr-group-stats {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.3125rem 0 0;
  font-variant-numeric: tabular-nums;
}

/* ── plain-language read-out + the ranked reason list ────────────────────── */
.gr-say {
  font-size: 0.875rem;
  line-height: 1.45;
  margin: 0.4375rem 0 0;
  overflow-wrap: anywhere;
}

.gr-reasons {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.gr-reason {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.25rem 0.5rem;
  border-left: 2px solid var(--line);
  border-radius: 4px;
  background: var(--gr-quiet);
  min-width: 0;
}

.gr-reason-top { border-left-color: var(--accent); }

/* The chain is a block element elsewhere; inside a reason row it must not
   claim its own vertical rhythm or every reason costs three lines. */
.gr-reason-chain .gr-chain { margin: 0; gap: 0.1875rem 0.25rem; }
.gr-reason-chain .gr-term { font-size: 0.8125rem; padding: 0.0625rem 0.375rem; }
.gr-reason-chain .gr-value { font-size: 0.875rem; padding: 0.0625rem 0.375rem; }
.gr-reason-chain .gr-eq { font-size: 0.8125rem; }

.gr-reason-rate { text-align: right; font-variant-numeric: tabular-nums; }
.gr-reason-rate b { display: block; font-size: 0.9375rem; font-weight: 800; }
.gr-reason-rate span { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; }

.gr-score-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── today's game card inside a player card ──────────────────────────────── */
/* The game sits directly under the name, before the reasoning: who → which
   game → why. It used to land at the bottom under its own "Today's profile"
   heading, which is what made the row read as scattered fragments. */
.gr-profile { margin: 0.5rem 0 0; }
.gr-profile .ps-loading,
.gr-profile .ps-unavailable { min-height: 0; margin: 0; font-size: 0.75rem; }

/* The card is the heading now. Kept as a class so any page still emitting the
   eyebrow degrades quietly rather than showing an unstyled line. */
.gr-profile-title { display: none; }

/* ── combination ledger ──────────────────────────────────────────────────── */
.gr-ledger { display: grid; gap: 0.5rem; }

.gr-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 8.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  background: var(--panel);
  border: var(--gr-hairline);
  border-radius: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.gr-row:hover { background: var(--gr-quiet); }
.gr-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.gr-row.gr-live { border-left: 3px solid var(--color-success); }

.gr-row-n {
  font-size: 0.8125rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.gr-row-live {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-success);
  margin: 0.375rem 0 0;
}

.gr-row-rate { text-align: right; font-variant-numeric: tabular-nums; }

.gr-row-rate b { display: block; font-size: 1.0625rem; font-weight: 800; }
.gr-row-rate span { font-size: 0.75rem; color: var(--muted); }

.gr-rate-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 0.3125rem;
}

.gr-rate-bar i { display: block; height: 100%; background: var(--color-success); }

/* ── pagination ──────────────────────────────────────────────────────────── */
.gr-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: var(--gr-hairline);
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gr-pager-btns { display: flex; gap: 0.5rem; }

.gr-pager button {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  padding: 0.375rem 0.75rem;
  border: var(--gr-hairline);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.gr-pager button:hover:not(:disabled) { background: var(--gr-quiet); }
.gr-pager button:disabled { opacity: 0.45; cursor: default; }
.gr-pager button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── empty / loading states ──────────────────────────────────────────────── */
.gr-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--gr-radius);
  color: var(--muted);
}

.gr-empty h3 { margin: 0 0 0.375rem; font-size: 1rem; color: var(--ink); font-weight: 650; }
.gr-empty p { margin: 0; font-size: 0.875rem; max-width: 48ch; margin-inline: auto; }

.gr-skel { display: grid; gap: 0.75rem; }

.gr-skel i {
  display: block;
  height: 5.5rem;
  border-radius: var(--gr-radius);
  background: linear-gradient(90deg, var(--gr-quiet) 25%, var(--line) 50%, var(--gr-quiet) 75%);
  background-size: 200% 100%;
  animation: gr-shimmer 1.4s linear infinite;
}

@keyframes gr-shimmer { to { background-position: -200% 0; } }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .gr-opp-rank { font-size: 1.125rem; padding: 0; }
  .gr-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .gr-row-rate { text-align: left; }
  .gr-row-rate b { display: inline; margin-right: 0.375rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gr-meter i { transition: none; }
  .gr-skel i { animation: none; }
}
