/* "Rewind" theme: dark, glowing bento grid, big gradient numbers. */
:root {
  color-scheme: dark;
  --page: #08080c;
  --surface: #14141c;
  --surface-2: #1b1b25;
  --ink: #f4f4f8;
  --ink-2: #b9b9c8;
  --muted: #8a8a9c;
  --grid: #24242f;
  --axis: #33333f;
  --border: rgba(255, 255, 255, 0.08);
  --s1: #7b83ff;  /* Chicago / English */
  --s2: #f0444f;  /* Vietnam / Vietnamese */
  --s3: #16a394;  /* Korean & Japanese */
  --seq1: #2a1418; --seq2: #4d1a22; --seq3: #82222f; --seq4: #bd2f3d; --seq5: #f0444f; --seq6: #ff9da2;
  --glow-1: rgba(240, 68, 79, 0.22);
  --glow-2: rgba(123, 131, 255, 0.2);
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: -20vh -10vw auto; height: 90vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vw 40vh at 18% 30%, var(--glow-1), transparent 70%),
    radial-gradient(45vw 45vh at 85% 15%, var(--glow-2), transparent 70%);
  filter: blur(20px);
}
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

.topbar { display: flex; justify-content: space-between; align-items: center; height: 64px; font-size: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--s2), var(--s1)); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.topbar a.code { text-decoration: none; color: var(--ink-2); padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255, 255, 255, 0.03); }
.topbar a.code:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.2); }

/* Hero */
.hero { padding: 72px 0 56px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); }
.pill .live { width: 7px; height: 7px; border-radius: 50%; background: var(--s2); box-shadow: 0 0 0 4px rgba(240, 68, 79, 0.2); }
h1 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(48px, 9vw, 112px); line-height: 0.95; letter-spacing: -0.045em;
  margin: 26px 0 22px;
}
.grad { background: linear-gradient(100deg, #ff6b73 0%, #f0444f 30%, #a07bff 70%, #7b83ff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: clamp(17px, 2vw, 20px); color: var(--ink-2); max-width: 680px; margin: 0 auto; }
.chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.chip { font-size: 12.5px; color: var(--ink-2); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); }

/* Bento grid */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.tile {
  grid-column: span 12; min-width: 0; position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)), var(--surface);
  border: 1px solid var(--border); border-radius: 24px; padding: 26px 26px 22px;
  transition: border-color 0.25s, transform 0.25s;
}
.tile:hover { border-color: rgba(255, 255, 255, 0.16); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
@media (max-width: 980px) { .span-3 { grid-column: span 6; } .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; } }
@media (max-width: 520px) { .span-3 { grid-column: span 12; } }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.tile h2 { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 8px 0 8px; }
.tile .insight { color: var(--ink-2); font-size: 15px; margin: 0 0 20px; max-width: 760px; }
.tile .insight b { color: var(--ink); font-weight: 600; }

/* Stat tiles */
.stat .big { font-family: var(--display); font-weight: 800; font-size: clamp(44px, 5.4vw, 64px); line-height: 1; letter-spacing: -0.04em; margin: 14px 0 8px; }
.stat .sub { color: var(--ink-2); font-size: 14px; }
.stat.with-ring { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ring { flex: none; }
.ring .bg { stroke: var(--grid); }
.ring .fg { stroke: var(--s2); stroke-linecap: round; transition: stroke-dashoffset 1.6s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* Split comparison */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 18px; }
.side .where { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.side .n { font-family: var(--display); font-weight: 800; font-size: 40px; letter-spacing: -0.03em; line-height: 1; margin-top: 16px; }
.side .l { font-size: 13px; color: var(--muted); margin-top: 4px; }
.side .foot { font-size: 12.5px; color: var(--muted); margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* On repeat list */
.top-track { display: flex; gap: 16px; align-items: center; padding: 16px; border-radius: 18px; background: linear-gradient(120deg, rgba(240, 68, 79, 0.18), rgba(123, 131, 255, 0.12)); border: 1px solid var(--border); margin-bottom: 8px; }
.top-track .plays { font-family: var(--display); font-weight: 800; font-size: 44px; letter-spacing: -0.03em; line-height: 1; }
.top-track .t { font-weight: 600; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.top-track .c { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.replays { list-style: none; margin: 0; padding: 0; }
.replays li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--border); }
.replays li:last-child { border-bottom: 0; }
.replays .rank { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.replays .t { font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replays .c { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replays .n { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--ink-2); margin: -8px 0 14px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

.method { color: var(--ink-2); font-size: 14.5px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 16px; }
.method-grid h3 { font-size: 14px; color: var(--ink); margin: 0 0 6px; }
.method-grid p { margin: 0; }
.method code { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }

footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 14px; padding: 40px 0 64px; }

/* Charts */
.chart { width: 100%; }
svg { display: block; overflow: visible; }
svg text { font-family: var(--sans); }
svg .tick { font-size: 11.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg .label { font-size: 13px; fill: var(--ink-2); }
svg .value { font-size: 12.5px; fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .axis { stroke: var(--axis); stroke-width: 1; }
svg .crosshair { stroke: var(--axis); stroke-width: 1; }
svg .track { fill: var(--grid); }
svg .hover-row path, svg .cell { transition: opacity 0.15s; }
svg:has(.hover-row:hover) .hover-row:not(:hover) path { opacity: 0.4; }
svg .cell:hover { stroke: #fff; stroke-width: 1.5; }

.chart-tip {
  position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; z-index: 50;
  background: rgba(30, 30, 40, 0.92); color: var(--ink); font: 13px/1.5 var(--sans);
  padding: 9px 12px; border-radius: 12px; max-width: 280px; transition: opacity 0.12s;
  border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.chart-tip b { font-weight: 600; }

/* Entrance animations: paused until the chart scrolls into view. */
.chart.animate .bar-x { transform-box: fill-box; transform-origin: left center; animation: grow-x 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 40ms); }
.chart.animate .bar-y { transform-box: fill-box; transform-origin: center bottom; animation: grow-y 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 30ms); }
.chart.animate .line-draw { stroke-dasharray: 1; animation: draw 1.6s cubic-bezier(0.5, 0, 0.2, 1) both; }
.chart.animate .fade { animation: fade 0.8s ease both; }
.chart.animate .fade.late { animation-delay: calc(0.5s + var(--i, 0) * 40ms); }
.chart.animate .cell { animation: fade 0.6s ease both; animation-delay: calc(var(--i, 0) * 25ms); }
.chart.animate:not(.in) * { animation-play-state: paused !important; }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .chart * { animation: none !important; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .ring .fg { transition: none; }
}
