/* ============================================================
   Deadlock Timers — design language derived from in-game UI
   (see design/tokens.css for the canonical token set)
   ============================================================ */

:root {
  /* surfaces */
  --bg-0: #0a0d0b;
  --bg-1: #111512;
  --panel: rgba(46, 47, 40, 0.55);
  --panel-solid: #23251f;

  /* ink */
  --ink: #ece5d4;
  --ink-2: #b5b0a1;
  --ink-3: #82806f;

  /* accent — the glowing mint of the game UI */
  --mint: #86efab;
  --mint-deep: #3fbf7f;
  --mint-glow: rgba(134, 239, 171, 0.45);
  --mint-glow-soft: rgba(134, 239, 171, 0.14);

  /* chrome */
  --line: #262a25;
  --border: rgba(236, 229, 212, 0.16);
  --border-strong: rgba(236, 229, 212, 0.32);

  /* diverging resistance ramp (bad time to hit -> neutral -> good) */
  --resist: #c2504a;
  --resist-mid: #3a3d38;
  --resist-weak: #3e9e57;

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;

  /* subtle film-grain noise, tiled */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- atmospheric backdrop: green smoke + compass web + grain ---- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 700px at 62% 18%, rgba(28, 84, 58, 0.30), transparent 65%),
    radial-gradient(900px 600px at 85% 75%, rgba(96, 34, 30, 0.16), transparent 60%),
    radial-gradient(800px 800px at 8% 90%, rgba(22, 60, 46, 0.18), transparent 60%),
    var(--bg-0);
}
.backdrop::before {
  /* faint compass-web ring pattern, like the menu background */
  content: '';
  position: absolute;
  inset: -20%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1400' height='1400' viewBox='0 0 1400 1400'%3E%3Cg fill='none' stroke='%237fdca8' stroke-opacity='0.05'%3E%3Ccircle cx='700' cy='700' r='220'/%3E%3Ccircle cx='700' cy='700' r='420'/%3E%3Ccircle cx='700' cy='700' r='640'/%3E%3Cpath d='M700 0v1400M0 700h1400M120 120l1160 1160M1280 120L120 1280'/%3E%3Ccircle cx='700' cy='480' r='4' fill='%237fdca8' fill-opacity='0.10' stroke='none'/%3E%3Ccircle cx='990' cy='860' r='3' fill='%237fdca8' fill-opacity='0.08' stroke='none'/%3E%3Ccircle cx='360' cy='900' r='3' fill='%237fdca8' fill-opacity='0.08' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
  background-position: center -200px;
  background-repeat: no-repeat;
  background-size: 1600px;
}
.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.05;
  mix-blend-mode: overlay;
}

.wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 28px 60px;
}

/* ============================ header ============================ */

header.site {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 6px 2px 18px;
}

.title-block h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 48px;
  letter-spacing: 0.06em;
  line-height: 1;
  margin: 0;
  text-transform: uppercase;
  color: var(--mint);
  text-shadow:
    0 0 18px var(--mint-glow),
    0 0 42px rgba(134, 239, 171, 0.22);
}
.title-block .sub {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 16px;
  letter-spacing: 0.02em;
}
.title-block .sub a { color: var(--ink-2); }

/* ---- match clock ---- */

.clock {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
}
.clock::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--noise);
  opacity: 0.04;
  border-radius: 10px;
  pointer-events: none;
}
.clock-time {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 36px;
  letter-spacing: 0.05em;
  min-width: 114px;
  text-align: center;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.clock.running .clock-time {
  color: var(--mint);
  text-shadow: 0 0 14px var(--mint-glow);
}
.clock-btns { display: flex; gap: 8px; align-items: center; }
.clock-next {
  border-left: 1px solid var(--border);
  padding-left: 14px;
  min-width: 200px;
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.clock-next .lbl {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--ink-3);
  display: block;
}
.clock-next .evt strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.clock-next .evt .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

/* ---- game-style buttons ---- */

.btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.14)),
    var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 16px;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.btn:hover {
  border-color: var(--mint);
  box-shadow: 0 0 10px var(--mint-glow-soft), inset 0 0 8px rgba(134, 239, 171, 0.06);
}
.btn:focus-visible,
.toggle:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}
.btn.small { padding: 5px 12px; font-size: 13.5px; }
.btn.primary {
  color: #0c1410;
  background: linear-gradient(180deg, #9df5bc, #6fdd9a);
  border-color: transparent;
  box-shadow: 0 0 14px var(--mint-glow-soft);
}
.btn.primary:hover { box-shadow: 0 0 18px var(--mint-glow); }

.icon-btn {
  cursor: pointer;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--panel-solid);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.icon-btn:hover { border-color: var(--mint); box-shadow: 0 0 10px var(--mint-glow-soft); }

/* ============================ intro hint ============================ */

.hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  padding: 10px 14px;
  background: var(--mint-glow-soft);
  border: 1px solid rgba(134, 239, 171, 0.35);
  border-left: 3px solid var(--mint);
  border-radius: 8px;
  color: var(--ink);
  font-size: 15.5px;
}
.hint b { color: var(--mint); }
.hint .close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--ink-2); font-size: 16px; padding: 4px 8px;
}
.hint .close:hover { color: var(--ink); }

/* ============================ filter row ============================ */

.filters {
  display: flex;
  align-items: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
  position: relative;
}
.filters::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--noise);
  opacity: 0.04;
  border-radius: 12px;
  pointer-events: none;
}
.filters .label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--ink-3);
  margin-right: 4px;
}
.filters .bulk { margin-left: auto; display: flex; gap: 8px; }

/* game-style toggle switch, tinted per category */
.toggle {
  --c: var(--mint);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}
.toggle .track {
  position: relative;
  width: 40px; height: 20px;
  border-radius: 999px;
  background: #171915;
  border: 1px solid var(--border);
  transition: background 0.18s, border-color 0.18s;
  flex: none;
}
.toggle .knob {
  position: absolute;
  top: 50%; left: 1px;
  translate: 0 -50%;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #55584e;
  display: grid;
  place-items: center;
  transition: left 0.18s, background 0.18s, box-shadow 0.18s;
}
.toggle .knob svg { width: 11px; height: 11px; opacity: 0; transition: opacity 0.18s; }
.toggle[aria-pressed="true"] { color: var(--ink); }
.toggle[aria-pressed="true"] .track {
  background: color-mix(in srgb, var(--c) 22%, #171915);
  border-color: color-mix(in srgb, var(--c) 55%, transparent);
}
.toggle[aria-pressed="true"] .knob {
  left: calc(100% - 21px);
  background: var(--c);
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 55%, transparent);
}
.toggle[aria-pressed="true"] .knob svg { opacity: 1; }
.toggle .swatch {
  width: 9px; height: 9px;
  border-radius: 2px;
  rotate: 45deg;
  background: var(--c);
  flex: none;
  opacity: 0.45;
  transition: opacity 0.15s;
}
.toggle[aria-pressed="true"] .swatch { opacity: 1; }

/* ============================ timeline panel ============================ */

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(0, 0, 0, 0.12)),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image: var(--noise);
  opacity: 0.045;
  pointer-events: none;
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 19px;
  margin: 0;
  padding: 16px 20px 0;
  color: var(--ink);
}

#timeline-panel { padding-bottom: 10px; }
#timeline-host {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#timeline-host::-webkit-scrollbar { height: 8px; }
#timeline-host::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
/* Desktop: JS sizes the svg to the container so it fills exactly (no scroll).
   Narrow screens: svg is wider than the host, which scrolls. */
#timeline { display: block; }
#timeline-empty {
  padding: 60px 20px 70px;
  text-align: center;
  color: var(--ink-3);
  font-size: 15px;
}
#timeline-empty b { color: var(--ink-2); }

/* SVG text + marks */
#timeline text {
  font-family: var(--font-body);
  fill: var(--ink-2);
}
#timeline .axis-tick { fill: var(--ink-3); font-size: 13px; font-family: var(--font-display); letter-spacing: 0.06em; }
#timeline .grid { stroke: var(--line); stroke-width: 1; }
#timeline .grid.major { stroke: #2d322c; }
#timeline .cat-label {
  font-family: var(--font-display);
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  fill: var(--ink-2);
}
#timeline .row-label { fill: var(--ink); font-size: 16px; font-weight: 600; }
#timeline .row-cadence { fill: var(--ink-3); font-size: 12.5px; }
#timeline .mark-label { fill: var(--ink-2); font-size: 12px; font-family: var(--font-display); letter-spacing: 0.04em; }
#timeline .mark-sub { fill: var(--ink-3); font-size: 10.5px; font-family: var(--font-display); letter-spacing: 0.08em; }
#timeline .seg-label { fill: var(--ink); font-size: 13px; font-weight: 600; }
#timeline .grad-label { fill: var(--ink-2); font-size: 11.5px; font-family: var(--font-display); letter-spacing: 0.03em; }

#timeline .rowband:nth-child(odd) { fill: rgba(236, 229, 212, 0.018); }
#timeline .hit { cursor: help; }
#timeline .hit.clickable { cursor: pointer; }
#timeline .hit:focus { outline: none; }
#timeline .hit:hover .mark-shape,
#timeline .hit:focus-visible .mark-shape { filter: brightness(1.25) drop-shadow(0 0 6px currentColor); }

@keyframes pulse-soon {
  0%, 100% { filter: drop-shadow(0 0 2px currentColor); }
  50% { filter: drop-shadow(0 0 10px currentColor) brightness(1.35); }
}
#timeline .soon .mark-shape { animation: pulse-soon 1.6s ease-in-out infinite; }

#timeline .now-line { stroke: var(--mint); stroke-width: 1.5; filter: drop-shadow(0 0 6px var(--mint-glow)); }
#timeline .now-hit { cursor: ew-resize; }
#timeline.scrubbing { cursor: ew-resize; }
#timeline.scrubbing .hit { pointer-events: none; }

/* ============================ tooltip ============================ */

.tooltip {
  position: fixed;
  z-index: 50;
  max-width: 360px;
  pointer-events: none;
  background: rgba(18, 21, 18, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 6px;
}
.tooltip .tt-head .key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.tooltip .tt-time {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.tooltip p { margin: 5px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.tooltip p:first-of-type { margin-top: 2px; }
.tooltip .tt-action {
  color: var(--mint);
  font-weight: 700;
  font-size: 13px;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

/* ============================ reference cards ============================ */

#cards-section { margin-top: 26px; }
#cards-section > h2 {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 18px;
  color: var(--ink);
  margin: 0 0 4px;
  padding-left: 2px;
}
#cards-section > .section-sub { color: var(--ink-3); font-size: 13.5px; margin: 0 0 14px; padding-left: 2px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.cat-card { padding: 0 0 6px; }
.cat-card .cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.cat-card .cat-head .key { width: 18px; height: 4px; border-radius: 2px; }
.cat-card .cat-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 15px;
  color: var(--ink);
}
.cat-card .cat-head .blurb { margin-left: auto; font-size: 12px; color: var(--ink-3); }

.entry { padding: 10px 16px 4px; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry h4 { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--ink); }
.entry .stats { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 7px; }
.entry .stat {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 13.5px;
}
.entry .stat .k {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--ink-3);
}
.entry .stat .v { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.entry ul { margin: 0 0 8px; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.entry li { margin: 3px 0; }

/* ============================ help modal ============================ */

dialog#help {
  background: none;
  border: none;
  padding: 0;
  max-width: 620px;
  width: calc(100% - 40px);
}
dialog#help::backdrop { background: rgba(4, 6, 5, 0.75); backdrop-filter: blur(3px); }
dialog#help .panel { padding: 26px 30px 24px; }
dialog#help h2 {
  padding: 0 0 4px;
  color: var(--mint);
  text-shadow: 0 0 14px var(--mint-glow);
  font-size: 24px;
}
dialog#help p { color: var(--ink-2); font-size: 14.5px; }
dialog#help ol { color: var(--ink-2); font-size: 14.5px; padding-left: 20px; }
dialog#help li { margin: 5px 0; }
dialog#help b { color: var(--ink); }
dialog#help .dim { color: var(--ink-3); font-size: 13px; }
dialog#help a { color: var(--mint); }
dialog#help .modal-foot { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ============================ footer ============================ */

footer.site {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12.5px;
  display: flex;
  gap: 8px 22px;
  flex-wrap: wrap;
}
footer.site a { color: var(--ink-2); }

/* ============================ responsive ============================ */

@media (max-width: 900px) {
  .wrap { padding: 16px 14px 40px; }
  .title-block h1 { font-size: 32px; }
  .clock { width: 100%; flex-wrap: wrap; }
  .clock-next { border-left: none; padding-left: 0; }
  .filters .bulk { margin-left: 0; width: 100%; }
}
