/* Judge Trends styles. Colours are tokens on :root, with a matching dark theme. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.12);
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #e6effb;
  --focus: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --highlight: #fff6db;
  --caution-bg: #fdf1e8;
  --caution-ink: #8a3a12;
  --error-bg: #fbeaea;
  --error-ink: #8f1f1f;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a199;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #5598e7;
    --accent-ink: #0b0b0b;
    --accent-soft: #1c2a3d;
    --focus: #86b6ef;
    --series-1: #3987e5;
    --series-2: #d95926;
    --highlight: #33301f;
    --caution-bg: #3a2414;
    --caution-ink: #f5c3a3;
    --error-bg: #3d1a1a;
    --error-ink: #f6b4b4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #a3a199;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #5598e7;
  --accent-ink: #0b0b0b;
  --accent-soft: #1c2a3d;
  --focus: #86b6ef;
  --series-1: #3987e5;
  --series-2: #d95926;
  --highlight: #33301f;
  --caution-bg: #3a2414;
  --caution-ink: #f5c3a3;
  --error-bg: #3d1a1a;
  --error-ink: #f6b4b4;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 17px/1.5 var(--font);
}
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Header & footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 20px 0 16px; margin-bottom: 24px; }
.site-header h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.tagline { margin: 4px 0 0; color: var(--ink-2); }
.site-footer { color: var(--muted); font-size: 0.85rem; padding: 32px 0 40px; }
.site-footer p { margin: 4px 0; }

/* Steps */
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.step h2 { margin: 0 0 12px; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.step-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 0.95rem; flex: none; }
label { font-weight: 600; }
.hint { margin: 2px 0 10px; color: var(--ink-2); font-size: 0.92rem; }
.input-row { display: flex; gap: 8px; flex-wrap: wrap; }
input[type="url"], select {
  flex: 1 1 260px; min-width: 0; min-height: 48px; padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--page);
  border: 1px solid var(--axis); border-radius: 8px;
}
select { width: 100%; max-width: 520px; }

.btn { font: inherit; font-weight: 600; min-height: 48px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--axis); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-large { font-size: 1.05rem; padding: 12px 24px; margin-top: 8px; }
.btn-link { background: none; border: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 4px; min-height: 32px; }

.comp-list { list-style: none; padding: 0; margin: 12px 0 0; }
.comp-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; margin-top: 8px; }
.comp-list .comp-name { font-weight: 600; }
.comp-list .comp-meta { color: var(--ink-2); font-size: 0.88rem; }

.scope-choice { border: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.radio { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; cursor: pointer; }
.radio input, .check input { width: 20px; height: 20px; accent-color: var(--accent); }
.scope-picker { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.scope-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.scope-comp { margin: 12px 0 4px; font-weight: 700; }
.scope-event { padding: 8px 0; border-bottom: 1px solid var(--border); }
.scope-event-name { font-weight: 600; margin-bottom: 2px; }
.scope-segs { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 400; cursor: pointer; }
.check.is-disabled { color: var(--muted); cursor: not-allowed; }
.scope-summary { color: var(--ink-2); margin: 8px 0 0; }

/* Status & alerts */
.status { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--ink-2); }
.status progress { width: 200px; height: 10px; accent-color: var(--accent); }
.alert { background: var(--error-bg); color: var(--error-ink); padding: 12px 16px; border-radius: 8px; margin: 16px 0; }

/* Report */
.report { margin-top: 24px; }
.report-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.eyebrow { margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; font-weight: 700; }
.report-header h2 { margin: 2px 0 6px; font-size: 1.6rem; }
.report-meta { margin: 0; color: var(--ink-2); white-space: pre-line; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.how-to-read { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 20px; margin: 16px 0; }
.how-to-read h3 { margin: 0 0 6px; font-size: 1.05rem; }
.how-to-read ul { margin: 0; padding-left: 20px; }
.how-to-read li { margin: 4px 0; }
.toc ol { margin: 0 0 8px; padding-left: 22px; columns: 2 240px; }
.toc li { margin: 2px 0; }

.report-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.report-section h3 { margin: 0 0 4px; font-size: 1.3rem; }
.report-section .intro { margin: 0 0 16px; color: var(--ink-2); max-width: 72ch; }
.report-section h4 { margin: 0 0 8px; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.stat-label { color: var(--ink-2); font-size: 0.88rem; font-weight: 600; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.stat-detail { color: var(--ink-2); font-size: 0.85rem; }
.stat.is-small .stat-value { color: var(--muted); }
.tag-small { display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--caution-ink); background: var(--caution-bg); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.stat .tag-small { margin: 6px 0 0; }

.table-block { margin: 8px 0 18px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.data th { color: var(--ink-2); font-weight: 600; border-bottom-color: var(--axis); white-space: nowrap; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.is-small td { color: var(--muted); }
table.data tr.is-highlight td { background: var(--highlight); }
.empty { color: var(--ink-2); font-style: italic; margin: 4px 0; }
.note { margin: 8px 0 16px; padding: 10px 14px; border-radius: 8px; font-size: 0.92rem; }
.note-info { background: var(--surface-2); color: var(--ink-2); }
.note-caution { background: var(--caution-bg); color: var(--caution-ink); }

/* Charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 16px; margin-bottom: 16px; }
.chart-card { margin: 0; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 14px; min-width: 0; }
.chart-head h4 { margin: 0; }
.chart-sub { margin: 2px 0 6px; color: var(--ink-2); font-size: 0.85rem; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.s1, .bar.s1 { fill: var(--series-1); background: var(--series-1); }
.swatch.s2, .bar.s2 { fill: var(--series-2); background: var(--series-2); }
.chart-frame { position: relative; width: 100%; }
.chart-svg svg { display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .axis-label { fill: var(--ink-2); font-size: 12px; }
.chart-svg .hit { fill: transparent; cursor: default; outline: none; }
.chart-svg .bin.active .bar { filter: brightness(1.15); }
.chart-svg .bin.active .hit { fill: var(--ink); fill-opacity: 0.05; }
.tooltip { position: absolute; z-index: 2; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); font-size: 0.82rem; white-space: nowrap; }
.tt-title { color: var(--ink-2); margin-bottom: 2px; }
.tt-row { display: flex; align-items: center; gap: 6px; }
.tt-key { width: 12px; height: 2px; display: inline-block; }
.tt-key.s1 { background: var(--series-1); }
.tt-key.s2 { background: var(--series-2); }
.tt-label { color: var(--ink-2); }
.table-view { margin-top: 6px; font-size: 0.88rem; }
.table-view summary { cursor: pointer; color: var(--accent); min-height: 32px; display: flex; align-items: center; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .step, .report-section, .report-header { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
  .input-row .btn { flex: 1 1 100%; }
}

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .step, .status, .alert, .report-actions, .toc, .table-view { display: none !important; }
  .report { margin: 0; }
  .report-section, .report-header, .how-to-read { border: none; padding: 0; margin: 0 0 14pt; background: #fff; }
  .report-section { break-before: auto; }
  .chart-card, .table-block, .stats { break-inside: avoid; }
  .chart-card, .stat { background: #fff; }
}
