/* VHOLUME standings — light, minimal. No build step, no webfonts. */

:root {
    --bg: #fbfbf9;
    --surface: #ffffff;
    --ink: #1f2226;
    --muted: #74787f;
    --faint: #9a9ea5;
    --line: #e7e7e2;
    --line-soft: #f0f0ec;
    --accent: #2e6b5e;
    --accent-soft: #e9f1ee;
    --down: #a4443a;
    --down-soft: #f7ecea;
    --warn-ink: #8a6d1f;
    --warn-bg: #faf3dd;
    --warn-line: #e8d9a8;
    --row-hover: #f7f8f6;
    --chip-bg: #f4f3ee;
    --shadow: rgba(15, 17, 20, 0.12);
    --radius: 8px;
}

:root[data-theme="dark"] {
    --bg: #14161a;
    --surface: #1b1e23;
    --ink: #e6e8ea;
    --muted: #9ba1a8;
    --faint: #797f87;
    --line: #2a2f36;
    --line-soft: #23272d;
    --accent: #74c2ac;
    --accent-soft: #1d2b28;
    --down: #e08579;
    --down-soft: #2e2320;
    --warn-ink: #dcb75e;
    --warn-bg: #2c281c;
    --warn-line: #4b4227;
    --row-hover: #22262c;
    --chip-bg: #262a31;
    --shadow: rgba(0, 0, 0, 0.45);
}

/* Theme swaps are atomic: tr.row's 100ms background transition otherwise
 * ramps the open row through translucent midtones (the page colour bleeds
 * through) while the detail row - same tint, no transition - jumps at
 * once, so the two layers disagree for ~6 frames. setTheme() adds
 * .theme-swap for exactly one painted frame to suppress all transitions
 * during the palette change; everything else keeps its fades. */
html.theme-swap *,
html.theme-swap *::before,
html.theme-swap *::after {
    transition: none !important;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- header */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 28px 0 20px;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: 0.01em;
}

h1 .sub {
    margin-left: 10px;
    font-size: 15px;
    font-weight: 400;
    color: var(--muted);
}

.totals {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13.5px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.badge.stale {
    border-color: var(--warn-line);
    background: var(--warn-bg);
    color: var(--warn-ink);
}

.badge.fixture::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--faint);
    vertical-align: 1px;
}

.stale-banner {
    background: var(--warn-bg);
    border-bottom: 1px solid var(--warn-line);
    color: var(--warn-ink);
    font-size: 13.5px;
    padding: 9px 0;
}

/* ---------------------------------------------------------- header tools */

.header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
    color: var(--ink);
    border-color: var(--faint);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

.help-wrap { position: relative; }

.help-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: 290px;
    max-width: calc(100vw - 40px);
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px var(--shadow);
    font-size: 13px;
    line-height: 1.55;
    color: var(--muted);
}

.help-pop::before {
    content: "";
    position: absolute;
    top: -5px;
    right: 22px;
    width: 8px;
    height: 8px;
    background: var(--surface);
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
    transform: rotate(45deg);
}

.help-pop h5 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
}

.help-pop p { margin: 0 0 10px; }
.help-pop p:last-child { margin-bottom: 0; }

.points-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px 8px;
    margin: 0 0 12px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.points-grid b {
    display: block;
    font-weight: 600;
    color: var(--ink);
}

.points-grid span { color: var(--muted); }

/* -------------------------------------------------------------- controls */

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 22px 0 12px;
}

.search-label {
    position: relative;
    display: block;
    flex: 1;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    width: 15px;
    height: 15px;
    margin-top: -7.5px;
    color: var(--faint);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 8px 12px 8px 33px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 120ms ease;
}

#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--faint); }

.count {
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The count line appears only while filtering (the header owns the totals at
   rest) and shares its flex slot with the permanent hint; the wrapper keeps
   .controls at two children so space-between doesn't centre the count. The
   app only ever writes the inner #count. */
.count-wrap {
    display: flex;
    align-items: baseline;
    gap: 14px;
}
.hint {
    color: var(--faint);
    font-size: 12.5px;
}

/* ----------------------------------------------------------------- table */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

thead th {
    padding: 0;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

thead th.num { text-align: right; }

.sort {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

th.num .sort { justify-content: flex-end; }
.sort:hover { color: var(--ink); }
.sort::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 3.5px solid transparent;
    border-right: 3.5px solid transparent;
    opacity: 0;
}

th[aria-sort="ascending"] .sort::after {
    border-bottom: 5px solid currentColor;
    opacity: 1;
}

th[aria-sort="descending"] .sort::after {
    border-top: 5px solid currentColor;
    opacity: 1;
}

th[aria-sort] .sort { color: var(--ink); }

tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 14.5px;
}

tbody tr.row {
    cursor: pointer;
    transition: background 100ms ease;
}

tbody tr.row:hover { background: var(--row-hover); }
tbody tr.row.open { background: var(--accent-soft); }
tbody tr.row.tie > td { border-bottom-style: dotted; }
tbody tr.row:last-child > td { border-bottom: 0; }

td.col-rank { color: var(--muted); width: 52px; }
td.col-points { font-weight: 600; }
td.col-wr, td.col-pod { color: var(--muted); }

.name-cell {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
}

.name {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.name:hover {
    color: var(--accent);
    border-bottom-color: var(--accent-soft);
}

/* Expandability marker: sits centred between the table edge and the leftmost
 * digit of its rank (ranks are right-aligned, so the gap varies per row - no
 * stylesheet can read the number's width, so placeChevrons() in app.js
 * measures it once at build time and stamps the exact offset; left: 0 is the
 * fallback). Hidden at rest, revealed on hover/focus, kept while open; touch
 * has no hover, so its marker is always on. Opacity-only reveal means the
 * rank number never shifts. */
.col-rank { position: relative; }
.col-rank .chev {
    position: absolute;
    left: 0;
    top: 50%;
    font-size: 17px;
    color: var(--faint);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: transform 120ms ease, opacity 120ms ease;
}
tr.row:hover .col-rank .chev,
tr.row:focus-visible .col-rank .chev,
tr.row.open .col-rank .chev {
    opacity: 1;
}
tr.row.open .col-rank .chev {
    transform: translate(-50%, -50%) rotate(90deg);
}
@media (hover: none) {
    .col-rank .chev { opacity: 1; }
}

.unknown {
    color: var(--muted);
    font-style: italic;
}

.masked {
    color: var(--faint);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.ext {
    color: var(--faint);
    font-size: 11px;
    text-decoration: none;
}
/* The external-link arrow is a hover/focus affordance; its space stays
   reserved (it trails the name), so nothing shifts when it appears. */
.name-cell .ext {
    opacity: 0;
    transition: opacity 120ms ease;
}
tr.row:hover .name-cell .ext,
tr.row:focus-visible .name-cell .ext {
    opacity: 1;
}

a.name:hover + .ext, .ext:hover { color: var(--accent); }

.delta { font-variant-numeric: tabular-nums; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--down); }
.delta.flat, .delta.none { color: var(--faint); }

.state {
    padding: 26px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.empty {
    margin: 10px 0 0;
    padding: 18px;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

/* ----------------------------------------------------------- expansion */

tr.detail-row > td {
    padding: 4px 14px 18px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--line);
}

.detail {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 10px 26px;
    padding-top: 8px;
}

.detail h4 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.detail-summary {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.chip .lv { color: var(--ink); }
.chip .rk { font-weight: 600; }

.chip.p1 {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.chip.p1 .lv { color: var(--accent); }

.chip.p23 { background: var(--chip-bg); }
.chip.p23 .rk { color: var(--ink); }

.history-box { min-width: 0; }

.spark {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.spark .pts-line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark .pts-area { fill: var(--accent); opacity: 0.07; }
.spark .rank-line {
    fill: none;
    stroke: var(--faint);
    stroke-width: 1.2;
    stroke-dasharray: 3 3;
}
.spark .last-dot { fill: var(--accent); }

.legend {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--faint);
}

.legend .k-pts::before,
.legend .k-rank::before {
    content: "";
    display: inline-block;
    width: 14px;
    margin-right: 5px;
    vertical-align: 3px;
    border-top: 2px solid var(--accent);
}

.legend .k-rank::before {
    border-top: 2px dashed var(--faint);
}

.no-detail {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
}

/* --------------------------------------------------------------- footer */

.site-footer {
    padding: 26px 0 40px;
}

.site-footer p {
    margin: 0;
    color: var(--faint);
    font-size: 13px;
    line-height: 1.6;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
    .wrap { padding: 0 14px; }
    .site-header { padding: 20px 0 16px; }
    h1 { font-size: 19px; }
    h1 .sub { display: block; margin: 2px 0 0; }
    .controls { padding: 16px 0 10px; flex-wrap: wrap; }
    .search-label { max-width: none; }
    .col-wr, .col-pod { display: none; }
    table { min-width: 0; }
    .detail { grid-template-columns: minmax(0, 1fr); }
    .spark { max-width: 100%; }
}
