/*
 * rr-results.css — styling for the self-hosted results page.
 * All colors and metrics are custom properties so the page can be retuned to
 * match ntfxc.com later without touching any logic.
 */

.rr-root {
  --rr-bg: #ffffff;
  --rr-surface: #f7f8fa;
  --rr-border: #dfe3e8;
  --rr-text: #1c2024;
  --rr-muted: #646c76;
  --rr-accent: #16507d;
  --rr-accent-soft: #e8f0f7;
  --rr-win: #12694a;
  --rr-win-soft: #e6f4ee;
  --rr-radius: 10px;
  --rr-gap: 16px;

  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  color: var(--rr-text);
  background: var(--rr-bg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.rr-root *, .rr-root *::before, .rr-root *::after { box-sizing: border-box; }

/* ---------- header ---------- */

.rr-header {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 32px;
  flex-wrap: wrap;
}

.rr-header-main { flex: 1 1 320px; min-width: 0; }

.rr-h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.rr-meta { margin: 0; color: var(--rr-muted); font-size: 14px; }
.rr-dot { margin: 0 8px; }

/* ---------- race director ---------- */

.rr-organizer { flex: 0 1 auto; text-align: right; }

.rr-org-label {
  margin: 0 0 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--rr-muted);
}

.rr-org-body {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.rr-org-logo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

.rr-org-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-size: 13px;
}

.rr-org-name { font-weight: 600; }

.rr-org-link {
  color: var(--rr-accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.rr-org-link:hover { text-decoration: underline; }

/* ---------- race tabs ---------- */

.rr-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--rr-border);
  padding-bottom: 0;
}

.rr-tab {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 550;
  color: var(--rr-muted);
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.rr-tab:hover { color: var(--rr-text); }

.rr-tab-on {
  color: var(--rr-accent);
  border-bottom-color: var(--rr-accent);
}

/* ---------- sections ---------- */

.rr-section { margin-bottom: 36px; }

.rr-h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.rr-sub {
  margin: 0 0 16px;
  color: var(--rr-muted);
  font-size: 13.5px;
  max-width: 68ch;
}

/* ---------- dual score cards ---------- */

.rr-cards {
  display: grid;
  gap: var(--rr-gap);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.rr-card {
  border: 1px solid var(--rr-border);
  border-radius: var(--rr-radius);
  background: var(--rr-surface);
  padding: 16px;
  /* A two-team meet has a single card. Without a cap it stretches the full
     page width and the two scores end up a screen apart. Three cards sit
     around 336px wide, so this never binds on a larger meet. */
  max-width: 420px;
}

.rr-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rr-side { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.rr-side:last-child { text-align: right; align-items: flex-end; }

.rr-team {
  font-size: 13px;
  font-weight: 550;
  color: var(--rr-muted);
  overflow-wrap: anywhere;
}

.rr-score { font-size: 30px; font-weight: 680; line-height: 1; font-variant-numeric: tabular-nums; }

.rr-win .rr-team { color: var(--rr-win); }
.rr-win .rr-score { color: var(--rr-win); }

.rr-side-out .rr-team, .rr-side-out .rr-score { color: var(--rr-muted); opacity: 0.7; }

.rr-vs { color: var(--rr-muted); font-size: 14px; padding: 0 4px; }

.rr-outcome {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 550;
  color: var(--rr-win);
}

.rr-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--rr-muted);
}

.rr-places { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.rr-place-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}

.rr-place-team {
  color: var(--rr-muted);
  min-width: 8.5em;
  flex-shrink: 0;
  overflow-wrap: anywhere;
}

.rr-place-list { display: flex; flex-wrap: wrap; gap: 4px; }

.rr-chip {
  color: var(--rr-muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.rr-chip-scoring {
  color: var(--rr-text);
  font-weight: 600;
  background: var(--rr-accent-soft);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Ghost runners score, so they read like scoring chips, but dashed and
   italic to show no one actually ran that place. */
.rr-chip-ghost {
  color: var(--rr-muted);
  font-weight: 600;
  font-style: italic;
  background: transparent;
  border: 1px dashed var(--rr-border);
  border-radius: 4px;
  padding: 0 4px;
}

/* ---------- expandable head-to-head detail ---------- */

.rr-detail { margin-top: 14px; }

.rr-detail > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--rr-accent);
  font-weight: 550;
  padding: 4px 0;
}

.rr-mini { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.rr-mini td { padding: 4px 8px; border-bottom: 1px solid var(--rr-border); }
.rr-mini tr:last-child td { border-bottom: 0; }

.rr-scoring-row { background: var(--rr-win-soft); }
.rr-scoring-row td:first-child { font-weight: 650; }

.rr-legend { margin: 8px 0 0; font-size: 12px; color: var(--rr-muted); }

/* ---------- tables ---------- */

/* Wide content scrolls inside its own box; the page never scrolls sideways. */
.rr-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.rr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rr-table th, .rr-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--rr-border);
  white-space: nowrap;
}

.rr-table th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rr-muted);
  font-weight: 600;
  background: var(--rr-bg);
}

/* No sticky header here: the wrapper below needs overflow-x for narrow
   screens, and setting one overflow axis forces the other to `auto`, which
   makes the wrapper the scroll container. `position: sticky` would then pin to
   that box instead of the viewport and scroll out of sight — measured, not
   assumed. Horizontal scrolling on phones is worth more than a sticky header. */

/* Tabular figures so digits line up column to column. Alignment stays left:
   with a full-width table the columns stretch, and right-aligned values drift
   far from their headers. */
.rr-num { font-variant-numeric: tabular-nums; }
.rr-muted { color: var(--rr-muted); }

/* Keep the short columns short so Name and Team take the slack. */
.rr-results th:nth-child(1), .rr-results td:nth-child(1) { width: 4.5em; }
.rr-results th:nth-child(3), .rr-results td:nth-child(3) { width: 4.5em; }
.rr-results th:nth-child(5), .rr-results td:nth-child(5) { width: 6em; }
.rr-results th:nth-child(6), .rr-results td:nth-child(6) { width: 5em; }

.rr-results tbody tr:hover { background: var(--rr-surface); }

.rr-dnf td { color: var(--rr-muted); font-style: italic; }

.rr-empty { text-align: center; color: var(--rr-muted); padding: 24px 10px; font-style: italic; }

.rr-sort {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-weight: inherit;
  padding: 0;
  cursor: pointer;
}

.rr-sort:hover { color: var(--rr-text); }
.rr-sorted { color: var(--rr-accent); }
.rr-arrow { font-size: 9px; }

/* ---------- controls ---------- */

.rr-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.rr-input, .rr-select {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--rr-border);
  border-radius: 7px;
  background: var(--rr-bg);
  color: var(--rr-text);
}

.rr-input { flex: 1 1 240px; min-width: 0; }

.rr-input:focus, .rr-select:focus, .rr-sort:focus-visible, .rr-tab:focus-visible {
  outline: 2px solid var(--rr-accent);
  outline-offset: 1px;
}

.rr-count { margin: 10px 0 0; font-size: 13px; color: var(--rr-muted); }

/* ---------- footer / status ---------- */

.rr-footer {
  margin-top: 32px;
  padding-top: 14px;
  border-top: 1px solid var(--rr-border);
}

.rr-stamp { margin: 0; font-size: 13px; color: var(--rr-muted); }

.rr-status {
  padding: 14px 16px;
  border: 1px solid var(--rr-border);
  border-radius: var(--rr-radius);
  background: var(--rr-surface);
  color: var(--rr-muted);
  font-size: 14px;
}

.rr-error { border-color: #e6c3c3; background: #fdf3f3; color: #7c2626; }
.rr-error a { color: inherit; }

.rr-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--rr-win);
}

.rr-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .rr-root { padding: 16px 12px 40px; }
  .rr-h1 { font-size: 21px; }
  /* Stack the race director under the title rather than squeezing it beside. */
  .rr-organizer { text-align: left; }
  .rr-org-body { justify-content: flex-start; }
  .rr-org-logo { height: 44px; }
  .rr-score { font-size: 25px; }
  .rr-place-team { min-width: 0; }
  .rr-place-row { flex-direction: column; gap: 2px; }
}

/* ---------- age group subsections ---------- */

.rr-h3 {
  margin: 22px 0 6px;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--rr-accent);
}

.rr-section .rr-h3:first-of-type { margin-top: 12px; }

/* A cell allowed to wrap inside a pinned column width, so a long name cannot
   widen the column and knock stacked tables out of alignment. */
.rr-table td.rr-wrap { white-space: normal; overflow-wrap: anywhere; }

/* ---------- team colour swatch (intrasquad) ---------- */

.rr-team-cell { display: inline-flex; align-items: center; gap: 7px; }

.rr-team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  /* A ring so a white or very pale team is still visible on the page. */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* Three columns do not need the full page width to be readable. */
.rr-table.rr-standings { max-width: 420px; }
