/* Guildrun Compendium — tokens follow the validated reference dataviz palette.
   Tier badges use the blue ordinal ramp, rarity the orange ordinal ramp — both
   validated light+dark with the skill's palette validator. Identity is never
   color-alone: badges always carry their letter/label. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --good: #006300;
  --bad: #d03b3b;
  --bar: #2a78d6;
  --bar-track: #e1e0d9;
  --tier-S: #104281; --tier-A: #1c5cab; --tier-B: #2a78d6; --tier-C: #5598e7; --tier-D: #86b6ef;
  --tier-ink-S: #fff; --tier-ink-A: #fff; --tier-ink-B: #fff; --tier-ink-C: #fff; --tier-ink-D: #0b0b0b;
  --rar-Epic: #8a3612; --rar-Rare: #d95926; --rar-Common: #f0916b;
  /* game-keyword tints (description markup); AA-checked on both surfaces */
  --kw-attack: #b3401f; --kw-magic: #6a3fc4; --kw-defense: #3f6480;
  --kw-crit: #a3372f; --kw-heal: #1e7a34; --kw-mana: #1f6ab3;
  --kw-burn: #c2510e; --kw-frost: #1a7ba6; --kw-poison: #4a8014;
  --kw-rush: #b3701f; --kw-stall: #7a5ab0; --kw-generic: #52514e;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good: #0ca30c;
    --bad: #e66767;
    --bar: #3987e5;
    --bar-track: #2c2c2a;
    --tier-S: #b7d3f6; --tier-A: #86b6ef; --tier-B: #5598e7; --tier-C: #256abf; --tier-D: #184f95;
    --tier-ink-S: #0b0b0b; --tier-ink-A: #0b0b0b; --tier-ink-B: #0b0b0b; --tier-ink-C: #fff; --tier-ink-D: #fff;
    --rar-Epic: #f7b697; --rar-Rare: #eb6834; --rar-Common: #a8431a;
    --kw-attack: #f0946f; --kw-magic: #bfa1f2; --kw-defense: #94bdd9;
    --kw-crit: #f09a90; --kw-heal: #7fce8e; --kw-mana: #85b9ec;
    --kw-burn: #f0a05f; --kw-frost: #74c4e8; --kw-poison: #a9d06a;
    --kw-rush: #ecb377; --kw-stall: #c3aae8; --kw-generic: #c3c2b7;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.site {
  display: flex; align-items: baseline; gap: 1.2rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--grid);
}
header.site h1 { font-size: 1.1rem; margin: 0; }
header.site h1 a { color: var(--ink); }
header.site nav { display: flex; gap: 1rem; font-size: 0.92rem; }
main { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1.5rem 4rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 1rem 0; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px;
}
.tile .v { font-size: 1.7rem; font-weight: 650; }
.tile .k { color: var(--muted); font-size: 0.82rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin: 1rem 0;
}

table.stats { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.stats th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem;
  padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
table.stats td { padding: 7px 10px; border-bottom: 1px solid var(--grid); }
table.stats td.num, table.stats th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.stats tbody tr:hover { background: color-mix(in oklab, var(--accent) 6%, transparent); }
table.stats a { color: var(--ink); }

.badge {
  display: inline-block; min-width: 1.6em; text-align: center;
  border-radius: 5px; padding: 1px 6px; font-weight: 650; font-size: 0.85rem;
}
.rarity { font-size: 0.8rem; font-weight: 600; }

.winbar { display: inline-flex; align-items: center; gap: 8px; min-width: 130px; }
/* spans need explicit display for width/height to apply */
.winbar .track { display: block; flex: 1; height: 4px; border-radius: 2px; background: var(--bar-track); overflow: hidden; }
.winbar .fill { display: block; height: 100%; border-radius: 2px; background: var(--bar); }
.winbar .lbl { font-variant-numeric: tabular-nums; font-size: 0.85rem; width: 3.2em; text-align: right; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0.8rem 0 1.2rem; }
.filters select, .filters button, .filters .tab {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 0.9rem; cursor: pointer;
}
.filters .tab.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.small { color: var(--muted); font-size: 0.82rem; }

.cmdwrap { position: relative; margin: 0 0 10px; }
pre.cmd {
  background: var(--page); border: 1px solid var(--grid); border-radius: 6px;
  padding: 8px 64px 8px 10px; font-size: 0.78rem; overflow-x: auto; margin: 0;
}
.cmdwrap .copy {
  position: absolute; top: 6px; right: 6px;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 8px; font: inherit; font-size: 0.75rem; cursor: pointer;
}
.cmdwrap .copy:hover { border-color: var(--accent); color: var(--accent); }
.cmdwrap .copy.ok { border-color: var(--good); color: var(--good); }

.dl {
  display: inline-block; margin: 2px 6px 2px 0; padding: 5px 12px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 6px;
  font-size: 0.9rem; font-weight: 600;
}
.dl:hover { background: color-mix(in oklab, var(--accent) 10%, transparent); text-decoration: none; }

.drop {
  display: block;
  border: 2px dashed var(--grid); border-radius: 10px; padding: 2rem; text-align: center;
  color: var(--ink-2); transition: border-color 0.15s; cursor: pointer;
}
.drop.hover { border-color: var(--accent); }
.drop input { display: none; }
.bar {
  height: 8px; margin: 6px 0 2px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); overflow: hidden;
}
.bar .fill {
  height: 100%; width: 0; background: var(--accent);
  transition: width 0.15s linear;
}
/* server-side parse: length is known, the wait isn't — pulse instead of creep */
.bar .fill.busy { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .bar .fill { transition: none; }
  .bar .fill.busy { animation: none; }
}
#where { margin-top: 10px; }
#where summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
#where[open] summary { margin-bottom: 8px; }
pre.result { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }

.timeline .b { border-left: 3px solid var(--grid); margin: 0 0 0 8px; padding: 4px 0 4px 14px; }
.timeline .b.victory { border-left-color: var(--good); }
.timeline .b.defeat { border-left-color: var(--bad); }
.timeline .phase { color: var(--ink-2); font-size: 0.88rem; margin: 2px 0 2px 22px; }
.timeline .hdr { font-weight: 600; }
.timeline .meta { color: var(--muted); font-size: 0.82rem; }
/* entity links inside dense replay rows stay quiet until hovered */
.timeline a[data-tip], .phase a[data-tip] { color: inherit; text-decoration: underline dotted; }
.timeline a[data-tip]:hover, .phase a[data-tip]:hover { color: var(--accent); }

/* ---- entity icons (extracted from the game build) ---- */
.eicon { vertical-align: -4px; border-radius: 4px; margin-right: 4px; }

/* ---- game-description keyword markup ---- */
.kw { font-weight: 600; color: var(--kw-generic); }
.kw-attack, .kw-attackdamage { color: var(--kw-attack); }
.kw-magic, .kw-mage, .kw-statcalcdamage { color: var(--kw-magic); }
.kw-defense, .kw-tank, .kw-shield { color: var(--kw-defense); }
.kw-crit, .kw-warrior { color: var(--kw-crit); }
.kw-health, .kw-hps, .kw-heal, .kw-statcalchps { color: var(--kw-heal); }
.kw-mana, .kw-manaregen, .kw-startingmana, .kw-mystic { color: var(--kw-mana); }
.kw-burn { color: var(--kw-burn); }
.kw-frost { color: var(--kw-frost); }
.kw-poison { color: var(--kw-poison); }
.kw-rush, .kw-attackspeed { color: var(--kw-rush); }
.kw-stall, .kw-stun { color: var(--kw-stall); }
.kw-bold { color: inherit; }

/* ---- item stat chips ---- */
.statchip {
  display: inline-block; padding: 0 7px; border-radius: 5px; margin: 1px 2px 1px 0;
  background: color-mix(in oklab, var(--accent) 9%, transparent);
  font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* ---- hover tooltip ---- */
.etip {
  position: fixed; z-index: 50; max-width: 330px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 10px 12px; font-size: 0.86rem; line-height: 1.45;
  pointer-events: none;
}
.etip .tip-hd { display: flex; align-items: center; gap: 8px; }
.etip .tip-hd .eicon { width: 34px; height: 34px; margin: 0; }
.etip .tip-name { font-weight: 650; }
.etip .tip-sub { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.etip .tip-line { margin-top: 6px; }
.etip .tip-stats {
  display: grid; grid-template-columns: auto auto auto auto; gap: 1px 10px;
  margin-top: 6px; font-size: 0.82rem;
}
.etip .tip-stats span { color: var(--muted); }
.etip .tip-stats strong { text-align: right; font-variant-numeric: tabular-nums; }
