/* mots — hand-rolled styles. Dark, quiet, data-first. Win = teal, loss = coral,
   used consistently across sparklines, badges and (later) charts. */

:root {
    --bg: #0e1117;
    --surface: #161b22;
    --surface-2: #1c232d;
    --border: #262d38;
    --border-strong: #333d4a;

    --text: #d6dde6;
    --text-dim: #8b95a3;
    --text-faint: #5c6673;

    --win: #2dd4bf;
    --win-dim: #14b8a6;
    --loss: #fb7185;
    --loss-dim: #f43f5e;
    --accent: #60a5fa;

    --radius: 8px;
    --gap: 14px;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---- top navigation ---------------------------------------------------- */

.topnav {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 0 24px;
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topnav a {
    color: var(--text-dim);
    font-size: 14px;
    padding: 4px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.12s;
}

.topnav a:hover {
    color: var(--text);
}

.topnav a.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.topnav .brand {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    letter-spacing: 0.02em;
}

.content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px;
}

/* ---- generic bits ------------------------------------------------------ */

.empty {
    color: var(--text-dim);
    padding: 40px 0;
    text-align: center;
}

.error {
    color: var(--loss);
    background: color-mix(in srgb, var(--loss) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--loss) 30%, transparent);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 12px 0;
}

.loading {
    color: var(--text-faint);
    padding: 24px 0;
}

/* ---- filter bar -------------------------------------------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.filters label {
    font-size: 12px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 2px;
}

.filters select,
.filters input {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
}

.filters input::placeholder {
    color: var(--text-faint);
}

.seg {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    overflow: hidden;
}

.seg button {
    background: var(--surface-2);
    color: var(--text-dim);
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.seg button:not(:last-child) {
    border-right: 1px solid var(--border-strong);
}

.seg button.on {
    background: var(--accent);
    color: #0b1220;
    font-weight: 600;
}

/* ---- session groups ---------------------------------------------------- */

.session {
    margin-bottom: 26px;
}

.session-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 4px 2px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.session-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.session-record {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-dim);
}

/* ---- replay row -------------------------------------------------------- */

.row {
    display: grid;
    grid-template-columns: 52px 160px 1fr 100px 60px 78px 44px;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition:
        background 0.1s,
        border-color 0.1s;
}

.row:hover {
    background: var(--surface);
    border-color: var(--border);
}

.row .time {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-dim);
}

.row .map {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row .heroes {
    color: var(--text-dim);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row .dur {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-faint);
    text-align: right;
}

.row .final {
    font-family: var(--mono);
    font-size: 13px;
    text-align: right;
    font-weight: 600;
}

.final.pos {
    color: var(--win);
}

.final.neg {
    color: var(--loss);
}

.final.zero {
    color: var(--text-faint);
}

/* result badge */
.badge {
    justify-self: end;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 5px;
    min-width: 34px;
    text-align: center;
}

.badge.win {
    color: var(--win);
    background: color-mix(in srgb, var(--win) 14%, transparent);
}

.badge.loss {
    color: var(--loss);
    background: color-mix(in srgb, var(--loss) 14%, transparent);
}

.badge.na {
    color: var(--text-faint);
    background: var(--surface-2);
}

/* sparkline cell */
.spark {
    display: block;
}

.spark-zero {
    stroke: var(--border-strong);
    stroke-width: 1;
    stroke-dasharray: 2 2;
}

/* ===== View 2 — replay detail ========================================== */

.detail-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.detail-head .back {
    color: var(--text-dim);
    font-size: 13px;
}

.detail-head .back:hover {
    color: var(--text);
}

.detail-head h1 {
    font-size: 22px;
    margin: 0;
    font-weight: 600;
}

.detail-head .meta {
    color: var(--text-faint);
    font-size: 13px;
    font-family: var(--mono);
    margin-left: auto;
}

/* "us" player list under the title: name (hero) pills */
.our-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.our-player {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 13px;
}
.op-name {
    color: var(--text);
    font-weight: 500;
}
.op-hero {
    color: var(--text-dim);
    margin-left: 5px;
}

/* metric badges (switch the chart's main line) */
.metric-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.metric-badge {
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s;
}

.metric-badge:hover {
    color: var(--text);
}

.metric-badge.on {
    background: var(--accent);
    color: #0b1220;
    border-color: var(--accent);
    font-weight: 600;
}

/* the chart */
.chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px 2px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.chart {
    display: block;
}

.chart .grid-v,
.chart .grid-h {
    stroke: var(--border);
    stroke-width: 1;
    opacity: 0.5;
}

.chart .axis {
    stroke: var(--border-strong);
    stroke-width: 1.2;
}

.chart .zero-line {
    stroke: var(--text-faint);
    stroke-width: 1;
    stroke-dasharray: 4 3;
    opacity: 0.7;
}

.chart .axis-label {
    fill: var(--text-faint);
    font-family: var(--mono);
    font-size: 10px;
}

.chart .tier-band {
    fill: var(--loss);
    opacity: 0.08;
}

.chart .obj-band {
    fill: #f5c14e;
    opacity: 0.1;
}

.chart .obj-dot {
    stroke: var(--bg);
    stroke-width: 1;
}
.chart .obj-dot.win {
    fill: var(--win);
}
.chart .obj-dot.loss {
    fill: var(--loss);
}
.chart .obj-dot.na {
    fill: var(--text-faint);
}

.chart .main-line {
    fill: none;
    stroke: #e6edf5;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart .bench-line {
    fill: none;
    stroke: var(--text-dim);
    stroke-width: 1.4;
    stroke-dasharray: 5 4;
    opacity: 0.85;
}

.chart .death-bar,
.chart .death-tick {
    opacity: 0.85;
}
.chart .death-bar.us,
.chart .death-tick.us {
    fill: var(--loss);
}
.chart .death-bar.them,
.chart .death-tick.them {
    fill: var(--win);
}

/* camp captures: team-colored diamonds; pre-objective ones stand out */
.chart .camp {
    cursor: pointer;
    opacity: 0.5;
}
.chart .camp.pre {
    opacity: 1;
    stroke: var(--bg);
    stroke-width: 0.8;
}
.chart .camp:hover {
    opacity: 1;
}
.chart .camp.us {
    fill: var(--win);
}
.chart .camp.them {
    fill: var(--loss);
}

.chart .crosshair {
    stroke: var(--text-dim);
    stroke-width: 1;
    opacity: 0.6;
}

.chart .hover-dot {
    fill: #fff;
    stroke: var(--accent);
    stroke-width: 1.5;
}

.chart .tip-bg {
    fill: var(--surface-2);
    stroke: var(--border-strong);
    stroke-width: 1;
    opacity: 0.97;
}
.chart .tip-t {
    fill: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
}
.chart .tip-v,
.chart .tip-b {
    fill: var(--text-dim);
    font-size: 11px;
}

.chart .pulse {
    stroke: var(--accent);
    stroke-width: 2;
    animation: pulse-fade 1.1s ease-out infinite;
}

@keyframes pulse-fade {
    0% {
        opacity: 0.9;
    }
    100% {
        opacity: 0.15;
    }
}

/* hallmark badges */
.hallmarks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.hallmark {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    font-family: inherit;
    cursor: help;
}

.hallmark.clickable {
    cursor: pointer;
    transition: border-color 0.12s;
}
.hallmark:hover {
    border-color: var(--border-strong);
}

.hm-title {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hm-value {
    font-size: 19px;
    font-family: var(--mono);
    font-weight: 600;
    color: var(--text);
}

/* win-average reference line under the value: muted label + bold white value */
.hm-ref {
    font-family: var(--mono);
    font-size: 13px;
}
.hm-ref-k {
    color: var(--text-faint);
    margin-right: 5px;
}
.hm-ref-v {
    color: var(--text);
    font-weight: 600;
}

.hm-sub {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-faint);
}

/* good/bad marker beside the value */
.mark {
    font-size: 11px;
    margin-left: 6px;
    vertical-align: 1px;
}
.mark.good {
    color: var(--win);
}
.mark.bad {
    color: var(--loss);
}
.mark.muted {
    color: var(--text-faint);
}

/* themed hover popup (like the chart's tooltip) with the exact difference */
.htip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: -1px;
    z-index: 30;
    width: max-content;
    max-width: 250px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--sans);
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-dim);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
.hallmark:hover .htip {
    display: block;
}
.htip div {
    margin: 1px 0;
}
/* first line is the numeric difference — make it stand out */
.htip div:first-child {
    color: var(--text);
    font-family: var(--mono);
    margin-bottom: 3px;
}

/* event log */
.log-head {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 10px;
}
.log-head h2 {
    font-size: 15px;
    margin: 0;
    font-weight: 600;
}
.toggle {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.event-log {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.ev {
    display: grid;
    grid-template-columns: 54px 14px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    font-size: 13px;
}
.ev:nth-child(odd) {
    background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.ev-time {
    font-family: var(--mono);
    color: var(--text-faint);
    font-size: 12px;
}

.ev-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.ev-dot.ev-obj {
    background: #f5c14e;
}
.ev-dot.ev-death-us {
    background: var(--loss);
}
.ev-dot.ev-death-enemy {
    background: var(--win);
}
.ev-dot.ev-camp {
    background: var(--accent);
}

.ev-text {
    color: var(--text);
}

.ev-flag {
    font-size: 11px;
    color: var(--text-dim);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
}

/* rosters footer */
.rosters {
    display: flex;
    gap: 24px;
    color: var(--text-dim);
    font-size: 13px;
    padding: 4px 2px;
}
.roster.us {
    color: var(--text);
}

/* Let hovers reach the interactive overlay shapes: everything drawn on top of
   the bands/deaths (the line/area/axis/crosshair/tooltips) ignores the pointer,
   while the bands, death bars and their lanes stay hoverable. */
.chart .area,
.chart .main-line,
.chart .bench-line,
.chart .zero-line,
.chart .grid-h,
.chart .grid-v,
.chart .axis,
.chart .axis-label,
.chart .crosshair,
.chart .hover-dot,
.chart .pulse,
.chart .obj-dot,
.chart .cross-tip,
.chart .item-tip {
    pointer-events: none;
}

.chart .obj-band,
.chart .tier-band,
.chart .death-bar,
.chart .death-tick {
    cursor: pointer;
}

.chart .obj-band:hover {
    opacity: 0.2;
}
.chart .tier-band:hover {
    opacity: 0.16;
}
.chart .death-bar:hover,
.chart .death-tick:hover {
    opacity: 1;
}

/* ===== View 3 — trends ================================================= */

.trend-header {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.wr-overall {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.wr-big {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
}
.wr-sub {
    font-size: 13px;
    color: var(--text-faint);
}

.map-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.map-chip {
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 9px;
    font-size: 12px;
    font-family: var(--mono);
    cursor: pointer;
}
.map-chip:hover {
    color: var(--text);
    border-color: var(--border-strong);
}
.map-chip.on {
    background: var(--accent);
    color: #0b1220;
    border-color: var(--accent);
    font-weight: 600;
}

.small-sample {
    color: #f5c14e;
    background: color-mix(in srgb, #f5c14e 8%, transparent);
    border: 1px solid color-mix(in srgb, #f5c14e 26%, transparent);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 13px;
    margin: 0 0 16px;
}

/* metric tabs above the big chart (reuses .metric-badge look) */
.trend-tabs {
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.trend-chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px 8px;
}

.trend-caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
}
.trend-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.trend-current {
    font-family: var(--mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.trend-current-note {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 400;
    color: var(--text-faint);
    margin-left: 6px;
}

.trend-big-svg {
    display: block;
    width: 100%;
    aspect-ratio: 920 / 360;
    height: auto;
}

.trend-big-svg .p-grid {
    stroke: var(--border);
    stroke-width: 1;
    opacity: 0.45;
    vector-effect: non-scaling-stroke;
}
.trend-big-svg .p-axis {
    fill: var(--text-faint);
    font-family: var(--mono);
    font-size: 10px;
}
.trend-big-svg .p-zero {
    stroke: var(--text-faint);
    stroke-dasharray: 3 3;
    stroke-width: 1;
    opacity: 0.7;
    vector-effect: non-scaling-stroke;
}
.trend-big-svg .p-roll {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.5;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.trend-big-svg .p-roll.faint {
    stroke: var(--text-faint);
    stroke-dasharray: 5 4;
}
.trend-big-svg .dot.win {
    fill: var(--win);
}
.trend-big-svg .dot.loss {
    fill: var(--loss);
}
