/* Visual components layered on top of style.css */
:root { --track: #262b34; --ink-on: #ffffff; }

/* card titles get a small pixel marker */
h2.card-title { display: flex; align-items: center; gap: 8px; }
h2.card-title::before { content: ""; width: 8px; height: 8px; background: var(--emerald); box-shadow: 2px 2px 0 rgba(0,0,0,.45); flex: none; }
.page-head .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 11px; color: var(--emerald); letter-spacing: 1px; margin-bottom: 6px; }
.page-head .eyebrow svg { width: 14px; height: 14px; image-rendering: pixelated; }

/* KPI tiles with a visual */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.kpi {
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 2px solid var(--border); border-radius: 6px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.03), inset 0 -3px 0 rgba(0,0,0,.25);
}
.kpi .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.kpi .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; }
.kpi .v { font-family: var(--mono); font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.kpi .v small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .s { color: var(--text-2); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kpi .viz { flex: none; display: flex; align-items: center; }
.kpi .viz.wide { flex: 1; max-width: 110px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 3px; font: 600 11.5px var(--mono); background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip span { font-family: var(--sans); font-weight: 500; color: var(--muted); }
.chip.good { background: rgba(70,196,112,.14); color: var(--good); }
.chip.bad { background: rgba(230,103,103,.14); color: var(--bad); }

.ring { display: block; }
.ring text { font: 700 11px var(--mono); fill: var(--text); }
.spark { display: block; overflow: visible; }

.duo { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.duo i { display: block; height: 6px; border-radius: 0 2px 2px 0; min-width: 2px; }

/* hero */
.hero-card { position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 320px); gap: 24px; align-items: center; padding: 22px 24px; }
.hero-card::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px 220px at 70px 50%, color-mix(in srgb, var(--rk) 22%, transparent), transparent 70%); }
.hero-card > * { position: relative; z-index: 1; }
.hero-card .badge svg { width: 104px; height: 104px; image-rendering: pixelated; filter: drop-shadow(0 0 18px color-mix(in srgb, var(--rk) 45%, transparent)) drop-shadow(0 8px 12px rgba(0,0,0,.5)); }
.hero-card .div-name { font-family: var(--pixel); font-size: 28px; line-height: 1.05; color: var(--rk); }
.hero-card .elo { font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1.1; }
.hero-card .elo small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.hero-stats .hs { display: flex; flex-direction: column; }
.hero-stats .hs b { font: 700 16px var(--mono); }
.hero-stats .hs span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.hero-side { display: flex; flex-direction: column; gap: 12px; }
.hero-side .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; display: flex; justify-content: space-between; gap: 8px; }
.hero-side .lbl b { color: var(--text-2); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 12px; }
.wl-bar { display: flex; height: 10px; gap: 2px; }
.wl-bar i { display: block; height: 100%; }
.wl-bar i:first-child { border-radius: 2px 0 0 2px; }
.wl-bar i:last-child { border-radius: 0 2px 2px 0; }

/* race strip: a whole run laid out as segments */
.race { display: flex; flex-direction: column; gap: 10px; }
.race-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) 76px; gap: 12px; align-items: center; }
.race-lbl { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.race-lbl b { font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-lbl b i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.race-lbl span { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-track { position: relative; height: 30px; border-left: 1px solid var(--border-hi); }
.race-grid { position: absolute; inset: 0; pointer-events: none; }
.race-grid i { position: absolute; top: -4px; bottom: -4px; width: 1px; background: rgba(255,255,255,.07); }
.race-bar { position: relative; display: flex; gap: 2px; height: 100%; }
.race-seg { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--ink-on);
  font: 600 10.5px var(--sans); white-space: nowrap; min-width: 2px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.22), inset 0 2px 0 rgba(255,255,255,.12); }
.race-seg:first-child { border-radius: 3px 0 0 3px; }
.race-seg:last-child { border-radius: 0 3px 3px 0; }
.race-seg.alt { filter: brightness(.74); }
.race-tot { font: 700 14px var(--mono); text-align: right; }
.race-axis { display: grid; grid-template-columns: 160px minmax(0, 1fr) 76px; gap: 12px; }
.race-axis .ticks { position: relative; height: 16px; color: var(--muted); font: 10.5px var(--mono); }
.race-axis .ticks span { position: absolute; transform: translateX(-50%); }
.race-key { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 11.5px; margin-top: 10px; }
.race-key b { color: var(--text-2); font-weight: 600; }

/* diverging delta bar inside a table cell */
.dwrap { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.dbar { position: relative; width: 64px; height: 10px; flex: none; }
.dbar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--border-hi); }
.dbar i { position: absolute; top: 0; height: 100%; }
.dbar i.bad { left: 50%; background: var(--bad); border-radius: 0 2px 2px 0; }
.dbar i.good { right: 50%; background: var(--good); border-radius: 2px 0 0 2px; }
.dwrap b { font: 600 12px var(--mono); min-width: 62px; text-align: right; }

/* inline magnitude bar next to a number */
.mbar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.mbar .bg { width: 64px; height: 6px; background: var(--track); border-radius: 2px; overflow: hidden; flex: none; }
.mbar .bg i { display: block; height: 100%; }

/* heatmap cells */
td.heat .hv { display: inline-block; padding: 2px 7px; border-radius: 3px; min-width: 62px; text-align: right; }
.heat-key { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.heat-key i { width: 60px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, rgba(43,212,106,.05), rgba(43,212,106,.55)); }

/* W/L form strip */
.form { display: flex; flex-wrap: wrap; gap: 3px; }
.form i { width: 15px; height: 15px; border-radius: 2px; display: grid; place-items: center; font: 700 8.5px var(--mono); font-style: normal; color: rgba(0,0,0,.7); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.form i.w { background: var(--good); }
.form i.l { background: var(--bad); }
.form i.d { background: var(--surface-3); color: var(--muted); }

/* rank ladder */
.ladder { position: relative; padding-top: 30px; }
.ladder-bar { display: flex; height: 28px; gap: 2px; }
.ladder-bar div { height: 100%; min-width: 2px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.12); }
.ladder-bar div:first-child { border-radius: 3px 0 0 3px; }
.ladder-bar div:last-child { border-radius: 0 3px 3px 0; }
.ladder-pin { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font: 600 11px var(--sans); white-space: nowrap; z-index: 2; }
.ladder-pin b { background: var(--text); color: #111; padding: 2px 7px; border-radius: 3px; }
.ladder-pin::after { content: ""; width: 2px; height: 36px; background: var(--text); margin-top: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.ladder-ranks { display: flex; gap: 2px; margin-top: 8px; }
.ladder-ranks span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); overflow: hidden; white-space: nowrap; min-width: 0; }
.ladder-ranks svg { width: 13px; height: 13px; image-rendering: pixelated; flex: none; }

/* versus rows (ahead vs behind) */
.vs { display: flex; flex-direction: column; gap: 16px; }
.vs-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; }
.vs-row .nm { font-weight: 600; font-size: 13px; }
.vs-bars { display: flex; flex-direction: column; gap: 5px; }
.vs-bar { display: grid; grid-template-columns: 56px minmax(0, 1fr) 96px; gap: 8px; align-items: center; font-size: 11.5px; color: var(--text-2); }
.vs-bar .bg { height: 10px; background: var(--track); border-radius: 2px; overflow: hidden; position: relative; }
.vs-bar .bg::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.25); }
.vs-bar .bg i { display: block; height: 100%; }
.vs-bar .val { font: 600 11.5px var(--mono); text-align: right; color: var(--text); }
.vs-bar .val span { color: var(--muted); font-weight: 400; }

/* focus items */
.focus-item .cmp { margin-top: 8px; display: grid; grid-template-columns: 52px minmax(0, 1fr) 54px; gap: 3px 8px; align-items: center; font: 11px var(--mono); color: var(--muted); }
.focus-item .cmp i { display: block; height: 6px; border-radius: 0 2px 2px 0; }
.focus-item .cmp em { font-style: normal; text-align: right; color: var(--text-2); }

tr.res-w td:first-child { box-shadow: inset 3px 0 0 var(--good); }
tr.res-l td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.res-n td:first-child { box-shadow: inset 3px 0 0 var(--border-hi); }

@media (max-width: 1150px) {
  .hero-card { grid-template-columns: auto minmax(0, 1fr); }
  .hero-side { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .hero-card { grid-template-columns: 1fr; padding: 18px; }
  .hero-card .badge svg { width: 76px; height: 76px; }
  .hero-card .elo { font-size: 32px; }
  .race-row, .race-axis { grid-template-columns: 88px minmax(0, 1fr) 60px; gap: 8px; }
  .race-seg { font-size: 0; }
  .race-tot { font-size: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 19px; }
  .vs-row { grid-template-columns: 1fr; }
  .vs-bar { grid-template-columns: 50px minmax(0, 1fr) 84px; }
}
