:root {
  --bg: #070514;
  --trim: #3df0ff;
  --ember: #ff7a2a;
  --magenta: #ff3db5;
  --amber: #ffc14a;
  --text: #e9f7ff;
  --muted: #8ea6bd;
  --line: rgba(61, 240, 255, 0.22);
  --panel: #120e18;
  --font: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body { min-height: 100%; }

a { color: var(--trim); }
button, input { font-family: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--trim);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 8px; }

.kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  color: var(--magenta);
}

.hero {
  display: grid;
  background: var(--bg);
}
.hero-media {
  grid-area: 1 / 1;
  position: relative;
  align-self: start;
  width: 100%;
  aspect-ratio: 16 / 5;
}
.hero-media picture, .hero-media img, .hero-loop {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}
.hero-loop {
  position: absolute;
  inset: 0;
}
.hero-copy {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  align-self: start;
  width: min(40%, 36rem);
  max-width: 40%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding: clamp(24px, 2.4vw, 36px) clamp(20px, 2vw, 28px);
}
.hero-copy h1 {
  margin: 0;
  font-weight: 900;
  font-size: clamp(32px, 3.6vw, 56px);
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.hero-copy p, .hero-copy h1 {
  text-shadow: 0 2px 16px #070514;
}
#intro {
  margin: 0;
  max-width: 36ch;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 32px; }
.back { margin: 18px 0; }
.ghost {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(233, 247, 255, 0.28);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: end;
  margin-bottom: 18px;
}
.search { display: grid; gap: 6px; flex: 1 1 240px; }
.search input, .filter-panel {
  background: #0c101c;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.search input {
  min-height: 48px;
  padding: 0 14px;
  font-size: 16px;
}
.dataset-label {
  margin: 0;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.scope-note {
  margin: 0;
  flex: 1 1 100%;
  max-width: 52ch;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
#filter-open { display: none; }

.filter-panel { padding: 12px 14px 16px; margin-bottom: 22px; }
.filter-head { display: flex; justify-content: space-between; align-items: center; }
.filter-title { margin: 12px 0 6px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
#filter-close { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.chip[aria-pressed="true"] {
  border-color: var(--trim);
  color: #071018;
  background: var(--trim);
}
.chip[data-type="bridge"] { --chip: #3df0ff; }
.chip[data-type="key compromise"] { --chip: #ff7a2a; }
.chip[data-type="smart-contract bug"] { --chip: #ffc14a; }
.chip[data-type="oracle or price manipulation"] { --chip: #ff3db5; }
.chip[data-type="phishing or social engineering"] { --chip: #c9a6ff; }
.chip[data-type="rug or exit"] { --chip: #ff5a6a; }
.chip[data-type="other"] { --chip: #8ea6bd; }
.chip[data-type] { box-shadow: inset 0 -2px 0 var(--chip); }

.section-head, .timeline-block h2, #cases h2 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
}
h2 { margin: 0 0 12px; font-weight: 900; letter-spacing: -0.02em; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  color: var(--text);
}
.rank-name { font-weight: 700; }
.bar {
  display: block;
  height: 22px;
  width: calc(var(--w) * 1%);
  min-width: 18px;
  border-radius: 3px 7px 4px 3px;
  background:
    repeating-linear-gradient(90deg,
      #4a3024 0 12px,
      #6a4634 12px 14px,
      #2a1c16 14px 26px,
      transparent 26px 30px);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 193, 74, 0.25);
}
.amt {
  font-family: var(--mono);
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rank li:nth-child(n + 13) { display: none; }

.belt {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(#1a2430, #1a2430) center / 100% 10px no-repeat,
    #0c101c;
  padding: 28px 0 36px;
  cursor: grab;
}
.belt:active { cursor: grabbing; }
.belt-track { position: relative; height: 92px; min-width: 1400px; }
.rivet {
  position: absolute;
  top: 38px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d7e7f2, #5d6c7a 55%, #1c2430);
  box-shadow: 0 0 0 3px #243140;
}
.rivet span {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.marker {
  position: absolute;
  top: 28px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(7, 5, 20, 0.8);
}
.marker[data-band="2"] { width: 26px; height: 26px; margin-left: -13px; top: 24px; }
.marker[data-band="3"] { width: 34px; height: 34px; margin-left: -17px; top: 20px; }
.marker[data-type="bridge"] { background: #3df0ff; }
.marker[data-type="key compromise"] { background: #ff7a2a; }
.marker[data-type="smart-contract bug"] { background: #ffc14a; }
.marker[data-type="oracle or price manipulation"] { background: #ff3db5; }
.marker[data-type="phishing or social engineering"] { background: #c9a6ff; }
.marker[data-type="rug or exit"] { background: #ff5a6a; }
.marker[data-type="other"] { background: #8ea6bd; }
.year-list { display: none; }
.year-sticky {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 8px 0;
  background: rgba(7, 5, 20, 0.92);
  font-family: var(--mono);
  color: var(--amber);
}
.year-items { list-style: none; margin: 0; padding: 0; }
.year-items button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.case {
  position: relative;
  margin: 0 0 14px;
  padding: 16px 16px 14px 22px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid rgba(255, 193, 74, 0.28);
  overflow: hidden;
}
.case::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: repeating-linear-gradient(135deg, #ffc14a 0 6px, #1a1208 6px 12px);
}
.case.is-open { animation: drawer 150ms ease-out; }
.case-top { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; }
.case time { font-family: var(--mono); color: var(--muted); font-size: 13px; }
.case h3 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.case .chips { margin-top: 8px; }
.case .chip { cursor: default; }
.loss {
  margin: 12px 0;
  font-family: var(--mono);
  font-size: clamp(28px, 4vw, 40px);
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.loss small { font-size: 12px; color: var(--muted); margin-left: 6px; }
.how summary { cursor: pointer; font-weight: 700; }
.how ol { margin: 8px 0 0; padding-left: 18px; }
.how li { margin: 6px 0; line-height: 1.4; }
.lesson {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(61, 240, 255, 0.06);
  border: 1px solid var(--line);
}
.lesson img { width: 64px; height: 64px; flex: none; }
.lesson p { margin: 0; }
.stamp {
  display: inline-block;
  margin-left: 8px;
  padding: 4px 8px;
  border: 2px solid var(--trim);
  color: var(--trim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  transform: rotate(-6deg);
  animation: thump 120ms ease-out;
}
.stamp.part { border-color: var(--amber); color: var(--amber); }
.stamp.none { border-color: var(--ember); color: var(--ember); }
.sources { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 14px; }
.empty { color: var(--muted); }

.colophon {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 48px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.colophon p { margin: 0 0 8px; }

@keyframes drawer {
  from { transform: translateY(8px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
@keyframes thump {
  from { transform: rotate(-6deg) scale(1.2); }
  to { transform: rotate(-6deg) scale(1); }
}

@media (max-width: 640px) {
  .hero {
    display: flex;
    flex-direction: column;
  }
  .hero-media {
    position: relative;
    width: 100%;
    aspect-ratio: 8 / 5;
    flex: none;
  }
  .hero-media picture,
  .hero-media img {
    width: 100%;
    height: auto;
    aspect-ratio: 8 / 5;
    object-fit: cover;
    object-position: center;
  }
  .hero-copy {
    position: static;
    width: 100%;
    max-width: none;
    padding: 16px;
  }
  #intro {
    max-width: none;
    font-size: 14px;
  }
  .hero-loop { display: none !important; }
}

@media (max-width: 719px) {
  #filter-open { display: inline-flex; }
  .filter-panel { display: none; }
  .filter-panel.is-open {
    display: block;
    position: fixed;
    z-index: 4;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    border-radius: 18px 18px 0 0;
    max-height: 80vh;
    overflow: auto;
    background: #100c18;
  }
  #filter-close { display: inline-flex; }
  .rank button { grid-template-columns: 1fr auto; }
  .rank .bar { display: none; }
  .rank li:nth-child(n + 11) { display: none; }
  .belt { display: none; }
  .year-list { display: block; }
}

@media (min-width: 720px) {
  .filter-panel { display: block; }
  .how summary { list-style: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .hero-loop { display: none !important; }
}
