/* Stats page. Builds on style.css (Nova tokens, nav, panels, buttons, footer). */

:root {
    /* Chart colours: darker steps of Nova's blue/green, validated against the dark surface
       (lightness band, colour-blind separation, contrast). Nova's UI accents are too light for marks. */
    --chart-1: #339af0;
    --chart-2: #2f9e44;
    --chart-wash: rgba(51, 154, 240, 0.1);
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-surface: #0c0e14;
}

.stats-main {
    padding: calc(var(--nav-h) + 72px) 0 40px;
}

.stats-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
}

.stats-title {
    margin-top: 10px;
    font-size: clamp(2.4rem, 6vw, 4.4rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-head .section-sub { margin-top: 14px; }

.stats-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.status-pill.offline .dot { background: var(--bad); }

.updated {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-faint);
}

.stats-section { margin-top: 56px; }
.stats-section[hidden] { display: none; }

.block-title {
    margin-bottom: 18px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-row .block-title { margin-bottom: 0; }

/* ---------------------------------------------------------------- Tiles */

.now-grid,
.economy-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 2fr;
    gap: 14px;
}

.economy-grid { margin-bottom: 14px; }

.tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.tiles-5 { grid-template-columns: repeat(5, 1fr); }
.tiles-2 { grid-template-columns: repeat(2, 1fr); }

.tile {
    padding: 20px 22px;
}

.tile-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
}

.tile-value {
    margin-top: 8px;
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    font-weight: 800;
    line-height: 1.1;
}

.tile-foot {
    margin-top: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-faint);
}

.hero-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 26px 28px;
}

.hero-value {
    margin-top: 10px;
    font-size: clamp(3rem, 6vw, 4.5rem);
    font-weight: 800;
    line-height: 1;
}

.hero-max {
    margin-left: 6px;
    font-size: 0.4em;
    font-weight: 700;
    color: var(--text-faint);
}

/* Capacity meter: the unfilled track is a lighter step of the same blue. */
.meter {
    height: 8px;
    margin-top: 20px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(51, 154, 240, 0.16);
}

.meter-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--chart-1);
    transition: width 0.8s var(--ease);
}

/* ---------------------------------------------------------------- Duty tiles */

.duty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.duty {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
}

.duty-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--c) 16%, #0c0e14);
    border: 2px solid var(--c);
}

.duty-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--c);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.duty-icon svg .solid { fill: var(--c); stroke: none; }

.duty-count {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.duty-name {
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
}

.duty-sub {
    font-size: 0.72rem;
    color: var(--text-faint);
}

/* ---------------------------------------------------------------- Charts */

.chart-panel { padding: 24px 26px 18px; }
.two-col .chart-panel { min-width: 0; }

.chart-title {
    font-size: 1rem;
    font-weight: 800;
}

.chart-sub {
    margin-top: 2px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.chart {
    position: relative;
    margin-top: 18px;
    min-height: 120px;
    transition: opacity 0.2s ease;
}

.chart.loading { opacity: 0.5; }

.chart svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.chart .axis-text {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    fill: var(--text-faint);
}

.chart .label-text {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-dim);
}

.chart .value-text {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    fill: var(--text);
}

.chart .mark { transition: opacity 0.15s ease, filter 0.15s ease; }
/* Marks and labels let the pointer through to the (bigger) hit area underneath. */
.chart .mark,
.chart text { pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover + .mark,
.chart .hit:focus-visible + .mark { filter: brightness(1.25); }

.chart-empty {
    display: grid;
    place-items: center;
    min-height: 160px;
    font-size: 0.85rem;
    color: var(--text-faint);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Money split: one bar, two segments with a 2px surface gap. */
.split {
    display: flex;
    gap: 2px;
    height: 14px;
    margin-top: 22px;
}

.split span {
    min-width: 4px;
    height: 100%;
}

.split span:first-child { border-radius: 4px 0 0 4px; }
.split span:last-child { border-radius: 0 4px 4px 0; }
.split span:only-child { border-radius: 4px; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.legend-item i {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-item b {
    color: var(--text);
    font-weight: 700;
}

/* Tooltip: value leads, label follows; series keyed with a short line. */
.chart-tip {
    position: fixed;
    z-index: 90;
    min-width: 120px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(12, 14, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    font-size: 0.78rem;
}

.chart-tip[hidden] { display: none; }

.tip-head {
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-faint);
}

.tip-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tip-row i {
    width: 12px;
    height: 2px;
    border-radius: 2px;
}

.tip-row b {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
}

.tip-row span { color: var(--text-dim); }

/* Table views */
.table-view {
    margin-top: 12px;
    border-top: 1px solid var(--panel-border);
    padding-top: 10px;
}

.table-view summary {
    width: fit-content;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    cursor: pointer;
}

.table-view summary:hover { color: var(--text-dim); }

.data-table,
.player-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table { margin-top: 10px; }

.data-table th,
.data-table td,
.player-table th,
.player-table td {
    padding: 8px 4px;
    text-align: left;
    border-bottom: 1px solid var(--panel-border);
}

.data-table th,
.player-table th {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.data-table td,
.player-table td { color: var(--text-dim); }

.data-table .num,
.player-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.player-table { font-size: 0.9rem; }
.player-table th, .player-table td { padding: 12px 22px; }
.player-table td:first-child { color: var(--text); font-weight: 600; }
.player-table tr:last-child td { border-bottom: 0; }
.player-table td.muted { color: var(--text-dim); font-weight: 500; }

/* Range toggle */
.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--panel-border);
}

.segmented button {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    transition: background 0.2s ease, color 0.2s ease;
}

.segmented button.active {
    color: var(--text);
    background: var(--surface-hover);
}

.stats-note {
    margin-top: 48px;
    font-size: 0.8rem;
    color: var(--text-faint);
}

.stats-note:empty { display: none; }

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 980px) {
    .now-grid, .economy-grid { grid-template-columns: 1fr; }
    .tiles-5 { grid-template-columns: repeat(3, 1fr); }
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .stats-head { flex-direction: column; align-items: flex-start; }
    .stats-status { align-items: flex-start; }
    .tiles, .tiles-5 { grid-template-columns: repeat(2, 1fr); }
    .tile { padding: 16px 18px; }
    .player-table th, .player-table td { padding: 12px 16px; }
    .chart-panel { padding: 20px 18px 14px; }
}
