/* The arena progress chart and leaderboard (ArenaChart, static/js/arena-chart.js),
 * on the public arena page and in the app's arena console. See
 * docs/plans/active/blogs_and_arenas_plan.md §5.
 *
 * Self-contained: the app page doesn't load public.css, so the badges and the
 * empty states here don't borrow from it. Tokens only — every colour is a
 * var(--…), so the chart follows the page's theme and mode; the SVG takes its
 * colours from these classes rather than from attributes for the same reason.
 *
 * --ac-surface is what the chart sits on. Point rings, label halos and the
 * leaderboard's scroll shadows are cut out of it, so a caller that puts the
 * chart on another surface sets it to match — on the component itself, which
 * declares the default: `.my-panel .ac-chart { --ac-surface: var(--surface-2); }`.
 */

.ac-chart, .ac-board {
    --ac-surface: var(--surface-1);
    font-family: var(--font-ui);
    color: var(--text-2);
    min-width: 0;
}

/* ── Title row: what the y axis measures, and the legend ── */
.ac-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 0.5rem 1.5rem; margin-bottom: 0.75rem;
}
.ac-ytitle {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem;
    font-size: 0.92rem; font-weight: 600; color: var(--text-strong); min-width: 0;
}
.ac-ytitle .ac-symbol { font-size: 1.08em; font-weight: 400; }
.ac-ytitle-unit { font-weight: 400; color: var(--text-3); }
.ac-ytitle-side { font-weight: 500; color: var(--text-3); }
.ac-direction {
    display: inline-flex; align-items: center; gap: 0.2rem; align-self: center;
    padding: 0.08rem 0.5rem 0.08rem 0.35rem; border-radius: var(--radius-pill);
    background: var(--surface-3); color: var(--text-3);
    font-size: 0.72rem; font-weight: 500;
}
.ac-direction .ac-icon { width: 12px; height: 12px; }
.ac-symbol-text { font-family: var(--font-mono); font-size: 0.9em; }

.ac-legend {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 1rem;
    font-size: 0.76rem; color: var(--text-3);
}
.ac-legend li { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.ac-key { position: relative; display: inline-block; flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; }
.ac-key-record { width: 18px; height: 10px; border-radius: 0; }
.ac-key-record::before {
    content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 2px;
    border-radius: 1px; background: var(--accent);
}
.ac-key-record::after {
    content: ''; position: absolute; left: 5px; top: 1px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 1.5px var(--ac-surface), 0 0 0 3.5px var(--accent-wash-3);
}
.ac-key-verified { background: var(--accent); }
.ac-key-accepted { border: 2px solid var(--accent); background: var(--ac-surface); }
.ac-key-disputed { width: 8px; height: 8px; margin: 0 1px; border-radius: 1px; transform: rotate(45deg); background: var(--warning-text); }
.ac-key-pending { border: 1.5px dashed var(--text-5); background: var(--ac-surface); }
.ac-key-baseline, .ac-key-target { width: 18px; height: 0; border-radius: 0; border-top: 2px dashed var(--text-5); }
.ac-key-target { border-top-color: var(--success); }
/* Two-sided: each bound's record line with its triangle; the gap as the band
   between the two lines; the statuses as neutral triangles, since a status
   reads the same on either side. */
.ac-key-record-lower, .ac-key-record-upper { width: 20px; height: 12px; border-radius: 0; }
.ac-key-record-lower::before, .ac-key-record-upper::before {
    content: ''; position: absolute; left: 0; right: 0; top: 5px; height: 2px;
    border-radius: 1px; background: var(--ac-side);
}
.ac-key-band {
    width: 18px; height: 10px; border-radius: 0; box-sizing: border-box; background: var(--accent-wash-2);
    border-top: 2px solid var(--accent2); border-bottom: 2px solid var(--accent);
}
.ac-key-mark { width: 12px; height: 12px; border-radius: 0; --ac-side: var(--text-3); }
.ac-key .ac-mark { width: 14px; height: 14px; margin: -7px 0 0 -7px; transition: none; }
/* Marks on both sides: a ▲ and a ▼ side by side. */
.ac-key-mark-pair { width: 17px; }
.ac-key .ac-mark-pair { width: 17.5px; margin-left: -8.75px; }

/* ── The picture ── */
.ac-plot { position: relative; }
.ac-svg { display: block; overflow: visible; }
.ac-svg text {
    font-family: var(--font-ui); font-size: 11px; fill: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.ac-grid line { stroke: var(--border-2); stroke-width: 1; shape-rendering: crispEdges; }
.ac-grid line.is-minor { stroke: var(--border-1); }
.ac-grid line.is-zero { stroke: var(--border-4); }
.ac-axis-line, .ac-xtick-mark { stroke: var(--border-5); stroke-width: 1; shape-rendering: crispEdges; }

.ac-step { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ac-wash-from { stop-color: var(--accent); stop-opacity: 0.16; }
.ac-wash-to { stop-color: var(--accent); stop-opacity: 0.015; }
/* A two-sided parameter: the lower bound in the accent, the upper bound in
   the second accent; between them, the gap still open — tinted where the
   bounds cross. */
.ac-step-upper { stroke: var(--accent2); }
.ac-wash-upper .ac-wash-from, .ac-wash-upper .ac-wash-to { stop-color: var(--accent2); }
.ac-band { fill: var(--accent-wash-2); }
.ac-band-crossed { fill: var(--warning-wash); }

.ac-ref line { stroke-width: 1.25; stroke-dasharray: 5 4; }
.ac-ref-baseline line { stroke: var(--text-5); }
.ac-ref-target line { stroke: var(--success); }
/* A halo of the surface keeps a label legible where it crosses the grid. */
.ac-svg .ac-ref-label, .ac-svg .ac-end-label {
    font-weight: 600; paint-order: stroke; stroke: var(--ac-surface); stroke-width: 4px; stroke-linejoin: round;
}
.ac-svg .ac-ref-baseline .ac-ref-label { fill: var(--text-3); }
.ac-svg .ac-ref-target .ac-ref-label { fill: var(--success-deep); }
.ac-svg .ac-end-label { font-weight: 650; fill: var(--text-strong); }

/* ── Points: a 24px button each (the hit target), the mark drawn in ::before ── */
.ac-points { position: absolute; inset: 0; pointer-events: none; }
.ac-point {
    position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; padding: 0;
    border: 0; border-radius: 50%; background: none; cursor: pointer; pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
.ac-point.is-static { cursor: default; }
.ac-point::before {
    content: ''; position: absolute; left: 50%; top: 50%; box-sizing: border-box;
    width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
    box-shadow: 0 0 0 2px var(--ac-surface);
    transition: transform 0.12s ease;
}
.ac-st-verified::before { background: var(--accent); }
.ac-st-accepted::before { background: var(--ac-surface); border: 2px solid var(--accent); }
.ac-st-disputed::before {
    width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 1px;
    background: var(--warning-text); transform: rotate(45deg);
}
.ac-st-pending::before { background: var(--ac-surface); border: 1.5px dashed var(--text-5); }
.ac-point.is-record { z-index: 1; }
.ac-point.is-record::before {
    width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
    box-shadow: 0 0 0 2px var(--ac-surface), 0 0 0 4.5px var(--accent-wash-3);
}
.ac-point:hover, .ac-point.is-active { z-index: 2; }
/* Many points for the width: smaller marks, so they stay apart. */
.ac-dense .ac-point::before { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; box-shadow: 0 0 0 1.5px var(--ac-surface); }
.ac-dense .ac-st-accepted::before, .ac-dense .ac-st-pending::before { border-width: 1.5px; }
.ac-dense .ac-st-disputed::before { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
.ac-dense .ac-point.is-record::before {
    width: 10px; height: 10px; margin: -5px 0 0 -5px;
    box-shadow: 0 0 0 1.5px var(--ac-surface), 0 0 0 3.5px var(--accent-wash-3);
}
.ac-point:hover::before, .ac-point.is-active::before { transform: scale(1.3); }
.ac-st-disputed:hover::before, .ac-st-disputed.is-active::before { transform: rotate(45deg) scale(1.3); }

/* A bound's mark: a triangle (an inline SVG) instead of the dot — ▲ a lower
   bound, ▼ an upper one — in its side's colour, with the dot's status
   encodings: verified filled, accepted a ring, disputed amber, pending
   dashed; a record larger and haloed. */
.ac-side-lower { --ac-side: var(--accent); --ac-side-halo: var(--accent-wash-3); }
.ac-side-upper { --ac-side: var(--accent2); --ac-side-halo: var(--accent2-wash-3); }
.ac-point.ac-side-lower::before, .ac-point.ac-side-upper::before { content: none; }
.ac-mark {
    position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
    overflow: visible; pointer-events: none; transition: transform 0.12s ease;
}
/* The stroke drawn under the fill leaves a ring of the surface around the
   mark, as the dot's box-shadow does. */
.ac-mark-shape {
    fill: var(--ac-side); stroke: var(--ac-surface); stroke-width: 3;
    stroke-linejoin: round; paint-order: stroke;
}
.ac-mark-halo { fill: var(--ac-side-halo); stroke: var(--ac-side-halo); stroke-width: 9; stroke-linejoin: round; }
.ac-st-accepted .ac-mark-shape { fill: var(--ac-surface); stroke: var(--ac-side); stroke-width: 1.75; paint-order: normal; }
.ac-st-disputed .ac-mark-shape { fill: var(--warning-text); }
.ac-st-pending .ac-mark-shape {
    fill: var(--ac-surface); stroke: var(--text-5); stroke-width: 1.5; stroke-dasharray: 2.5 2; paint-order: normal;
}
.ac-point:hover .ac-mark, .ac-point.is-active .ac-mark { transform: scale(1.3); }
.ac-dense .ac-mark { transform: scale(0.75); }
.ac-dense .ac-point:hover .ac-mark, .ac-dense .ac-point.is-active .ac-mark { transform: scale(1); }
.ac-point:focus { outline: none; }
.ac-point:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

/* ── Tooltip ── */
.ac-tip {
    position: absolute; z-index: 5; pointer-events: none;
    box-sizing: border-box; width: max-content; min-width: 11rem; max-width: min(19rem, calc(100% - 8px));
    padding: 0.6rem 0.75rem 0.65rem; border-radius: var(--radius-lg);
    background: var(--surface-1); border: 1px solid var(--border-3);
    box-shadow: 0 8px 28px var(--shadow-2), 0 1px 3px var(--tint-3);
    font-size: 0.8rem; line-height: 1.4; color: var(--text-2);
}
.ac-tip[hidden] { display: none; }
.ac-tip-side {
    display: block; margin-bottom: 0.15rem;
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3);
}
.ac-tip-value {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.1rem 0.35rem;
    font-size: 1.06rem; font-weight: 650; color: var(--text-strong); font-variant-numeric: tabular-nums;
}
.ac-tip-value .ac-symbol { font-weight: 400; }
.ac-tip-eq { font-weight: 400; color: var(--text-4); }
.ac-tip-value .ac-badge { align-self: center; margin-left: 0.15rem; }
.ac-tip-title {
    display: block; margin-top: 0.35rem; font-weight: 600; color: var(--text-1);
    overflow-wrap: anywhere;
}
.ac-tip-authors { display: block; color: var(--text-3); overflow-wrap: anywhere; }
.ac-tip-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem;
    margin-top: 0.5rem; padding-top: 0.45rem; border-top: 1px solid var(--border-2);
    font-size: 0.75rem; color: var(--text-3);
}

/* ── Badges ──
   One colour per status, as ArenaChart.STATUS_TONE names it; the public
   pages (arena-public.css) and the app's chips follow the same map. */
.ac-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.1rem 0.5rem; border-radius: var(--radius-pill);
    font-size: 0.7rem; font-weight: 600; line-height: 1.5; letter-spacing: 0.02em; white-space: nowrap;
    background: var(--surface-4); color: var(--text-2);
}
.ac-badge .ac-icon { width: 11px; height: 11px; stroke-width: 3; }
.ac-badge-verified { background: var(--success-bg); color: var(--success-deep); }
.ac-badge-accepted { background: var(--accent-bg); color: var(--accent-deep); }
.ac-badge-disputed { background: var(--warning-bg); color: var(--warning-deep); }
.ac-badge-pending { background: var(--surface-4); color: var(--text-3); }
.ac-badge-rejected { background: var(--danger-bg); color: var(--danger-strong); }
.ac-badge-withdrawn { background: var(--surface-3); color: var(--text-3); }
.ac-badge-record { background: var(--accent); color: var(--text-inverse); }
.ac-badge-record-upper { background: var(--accent2); }

/* ── A two-sided parameter's interval: "0 ≤ Λ ≤ 0.189" (ArenaChart.renderBounds) ──
   Inline and in the type of wherever it sits (a hero figure, a card, a
   table cell); it wraps between its parts, never inside a number. */
.ac-bounds {
    display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.3em;
    max-width: 100%; font-variant-numeric: tabular-nums;
}
.ac-bound { white-space: nowrap; }
.ac-bound.is-baseline { color: var(--text-3); }
.ac-rel { font-weight: 400; color: var(--text-4); }
.ac-bounds.is-crossed .ac-rel { color: var(--warning-text); font-weight: 600; }
/* Its content stays inline, so .mb-tex-safe's vertical-align still sets the
   symbol on the baseline the parts align by. */
.ac-bounds-symbol { font-weight: 400; min-width: 0; }
.ac-bounds-name { font-weight: 600; }
.ac-bounds-none { color: var(--text-3); }

/* ── Empty states ── */
.ac-empty {
    position: absolute; z-index: 3; pointer-events: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.2rem; padding: 1rem; text-align: center; box-sizing: border-box;
}
.ac-empty-card {
    display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    padding: 0.8rem 1.2rem; border-radius: var(--radius-lg); background: var(--ac-surface);
}
.ac-empty .ac-icon { width: 30px; height: 30px; stroke-width: 1.5; color: var(--text-6); margin-bottom: 0.35rem; }
.ac-empty-title { font-size: 0.98rem; font-weight: 600; color: var(--text-2); }
.ac-empty-text { font-size: 0.85rem; color: var(--text-3); max-width: 30rem; }
.ac-empty-top { justify-content: flex-start; padding-top: 0.6rem; }
.ac-empty-pill {
    padding: 0.2rem 0.7rem; border-radius: var(--radius-pill);
    background: var(--surface-3); color: var(--text-3); font-size: 0.78rem; font-weight: 500;
}
.ac-empty-box {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    padding: 2.2rem 1.5rem; text-align: center;
    border: 1.5px dashed var(--border-4); border-radius: var(--radius-xl);
}
.ac-note { margin: 0.6rem 0 0; font-size: 0.8rem; color: var(--text-3); }

/* ── Leaderboard ── */
/* Scroll shadows: the two `local` washes travel with the table and cover the
   two fixed shadows at whichever end is fully scrolled to, so a shadow shows
   only on a side with more to see. */
.ac-board-scroll {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    background:
        linear-gradient(to right, var(--ac-surface) 40%, transparent) left / 2.5rem 100% no-repeat local,
        linear-gradient(to left, var(--ac-surface) 40%, transparent) right / 2.5rem 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, var(--shadow-1), transparent) left / 0.8rem 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, var(--shadow-1), transparent) right / 0.8rem 100% no-repeat scroll;
    background-color: var(--ac-surface);
}
.ac-board-scroll:focus { outline: none; }
.ac-board-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-table {
    width: 100%; min-width: 40rem; border-collapse: collapse;
    font-size: 0.87rem; line-height: 1.4; color: var(--text-1);
}
.ac-table th, .ac-table td {
    padding: 0.7rem 0.75rem; text-align: left; vertical-align: middle;
    border-bottom: 1px solid var(--border-2); font-weight: 400;
}
.ac-table thead th {
    padding-top: 0.5rem; padding-bottom: 0.55rem;
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-3); border-bottom-color: var(--border-3); white-space: nowrap; vertical-align: bottom;
}
.ac-table tbody tr { transition: background 0.12s; }
.ac-table tbody tr:hover { background: var(--surface-2); }
.ac-table tbody tr:last-child > * { border-bottom: 0; }
.ac-table .ac-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ac-table th.ac-num { text-align: right; }
/* Symbols and units read as math, not as an uppercase label. */
.ac-th-param { display: inline-flex; align-items: baseline; gap: 0.3rem; text-transform: none; letter-spacing: 0; }
.ac-th-param .ac-symbol { font-size: 1.35em; font-weight: 400; color: var(--text-2); }
.ac-th-unit { font-size: 0.95em; font-weight: 500; color: var(--text-3); }
.ac-table td.ac-col-main { font-size: 0.96rem; font-weight: 650; color: var(--text-strong); }
.ac-table thead th.ac-col-main .ac-symbol { color: var(--text-strong); }
.ac-col-rank { width: 3rem; }
.ac-table td.ac-col-rank { padding-right: 0; }
.ac-rank {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill);
    font-size: 0.8rem; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums;
}
.ac-medal { font-weight: 700; }
.ac-medal-1 { background: var(--tag-amber-bg); color: var(--tag-amber-fg); box-shadow: inset 0 0 0 1.5px var(--warning-muted); }
.ac-medal-2 { background: var(--tag-slate-bg); color: var(--tag-slate-fg); box-shadow: inset 0 0 0 1.5px var(--border-5); }
.ac-medal-3 { background: var(--tag-red-bg); color: var(--tag-red-fg); box-shadow: inset 0 0 0 1.5px var(--danger-muted); }
.ac-record-mark {
    display: inline-flex; vertical-align: -2px; margin-right: 0.35rem; color: var(--accent);
}
.ac-record-mark .ac-icon { width: 15px; height: 15px; }
.ac-record-mark-upper { color: var(--accent2); }
/* A two-sided parameter: a section per bound, each with its own table. */
.ac-board-section + .ac-board-section { margin-top: 1.75rem; }
.ac-board-title {
    display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.6rem;
    font-size: 0.95rem; font-weight: 650; color: var(--text-strong);
}
.ac-board-title .ac-mark { position: static; flex-shrink: 0; width: 18px; height: 18px; margin: 0 -0.1rem 0 -0.2rem; }
.ac-board-order { font-weight: 400; color: var(--text-3); }
.ac-th-rel { font-size: 1.1em; font-weight: 400; color: var(--text-3); }
.ac-cell-bound { display: block; }
.ac-table th.ac-col-title { min-width: 13rem; }
.ac-table tbody th.ac-col-title { font-weight: 600; color: var(--text-strong); }
.ac-table a.ac-title-link { color: var(--text-strong); text-decoration: none; }
.ac-table a.ac-title-link:hover { color: var(--accent-hover); text-decoration: underline; }
.ac-table a.ac-title-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }
.ac-table td.ac-col-authors { min-width: 9rem; max-width: 18rem; color: var(--text-3); }
.ac-table td.ac-col-date { white-space: nowrap; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ac-table .ac-col-status { white-space: nowrap; }

.ac-icon { display: inline-block; flex-shrink: 0; }
.ac-sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media (max-width: 640px) {
    .ac-head { gap: 0.5rem 1rem; }
    .ac-table { font-size: 0.84rem; }
    .ac-table th, .ac-table td { padding: 0.6rem 0.55rem; }
}
@media (prefers-reduced-motion: reduce) {
    .ac-point::before, .ac-mark, .ac-table tbody tr { transition: none; }
}
