/* app/static/css/wordle.css
 *
 * World Wardle "Connected Flow" theme, scoped to .ww-page so it cannot leak
 * into the other visualizers (seismic, f1, capital reactor).
 * Tokens are ported from WorldWardle's app/static/css/design-system.css.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

.ww-page {
  /* Background layers — deep navy-slate, never pure black */
  --bg-950: #090d16;
  --bg-900: #0e1321;
  --bg-800: #151b2e;
  --bg-700: #1c2540;
  --bg-600: #253052;
  /* Text hierarchy */
  --text-strong: #e8ecf4;
  --text-default: #b0b8cc;
  --text-soft: #6b7a94;
  --text-muted: #3d4a5e;
  /* Accents */
  --accent-blue: #3b82f6;
  --accent-blue-hover: #5b9aff;
  --accent-teal: #14b8a6;
  --accent-violet: #8b5cf6;
  /* Medals */
  --medal-gold: #f5c542;
  --medal-gold-muted: rgba(245, 197, 66, 0.15);
  --medal-silver: #94a3b8;
  --medal-silver-muted: rgba(148, 163, 184, 0.12);
  --medal-bronze: #d97706;
  --medal-bronze-muted: rgba(217, 119, 6, 0.12);
  /* Semantic */
  --color-win: #22c55e;
  --color-loss: #ef4444;
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  /* Wordle score buckets */
  --score-1: #2e7d46;
  --score-2: #6aaa64;
  --score-3: #c9b458;
  --score-4: #e8a33d;
  --score-5: #e2703a;
  --score-6: #c0392b;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  background: var(--bg-950);
  color: var(--text-default);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* The page owns the document background so the dark field runs edge to edge. */
body:has(.ww-page) { background: #090d16; margin: 0; }

.ww-page .hidden { display: none !important; }

.ww-page a:not(.ww-btn) { color: var(--accent-blue); text-decoration: none; }
.ww-page a:not(.ww-btn):hover { color: var(--accent-blue-hover); }

.ww-error {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 40px);
  color: var(--text-soft);
  font-size: 15px;
}

/* ── Type ─────────────────────────────────────────────────────────────── */

.ww-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ww-meta--teal { color: var(--accent-teal); }
.ww-meta--muted { color: var(--text-muted); }
.ww-meta--hard { color: var(--score-5); }
.ww-meta--easy { color: var(--score-2); }

.ww-h2 {
  margin: 8px 0 0;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-strong);
}
.ww-h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-strong); }
.ww-lede {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-default);
  max-width: 62ch;
  text-wrap: pretty;
}
.ww-sub { margin: 4px 0 16px; font-size: 13px; line-height: 1.5; color: var(--text-soft); }
.ww-mono-soft { font-family: var(--mono); font-size: 11px; color: var(--text-soft); }

/* ── Layout ───────────────────────────────────────────────────────────── */

.ww-hero {
  padding: clamp(28px, 6vw, 64px) clamp(16px, 4vw, 40px) clamp(32px, 5vw, 56px);
  background:
    radial-gradient(110% 80% at 20% 0%, rgba(59, 130, 246, 0.16), transparent 62%),
    radial-gradient(90% 70% at 95% 10%, rgba(20, 184, 166, 0.10), transparent 58%);
}
.ww-hero-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
}
.ww-hero-title {
  margin: 14px 0 12px;
  font-size: clamp(34px, 7vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-strong);
  text-wrap: pretty;
}
.ww-hero-desc {
  margin: 0 0 22px;
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.55;
  color: var(--text-default);
  max-width: 46ch;
  text-wrap: pretty;
}
.ww-hero-desc strong { color: var(--text-strong); font-weight: 600; }
.ww-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.ww-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(16px, 4vw, 40px) 40px;
  display: flex;
  flex-direction: column;
  gap: clamp(48px, 8vw, 96px);
}
.ww-section { display: flex; flex-direction: column; gap: 18px; }
.ww-section-head > * { margin-top: 0; }
.ww-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }

.ww-accent-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(20, 184, 166, 0.2), rgba(59, 130, 246, 0.2), transparent);
}

/* ── Cards, buttons ──────────────────────────────────────────────────── */

.ww-card {
  background: var(--bg-800);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: clamp(16px, 3vw, 24px);
}
.ww-card--center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ww-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ww-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--bg-800);
  border: 1px solid var(--border-default);
  color: var(--text-default);
  font-size: 14px;
  font-weight: 600;
  transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
.ww-btn:hover { background: var(--bg-700); border-color: var(--border-strong); color: var(--text-strong); }
.ww-btn--primary { background: var(--accent-blue); border-color: transparent; color: #fff; }
.ww-btn--primary:hover { background: var(--accent-blue-hover); color: #fff; box-shadow: 0 0 20px rgba(59, 130, 246, 0.35); }
.ww-btn:active { background: var(--bg-600); }
.ww-btn--primary:active { background: #2563eb; }

/* ── Wordle tiles ─────────────────────────────────────────────────────── */

.ww-tiles { display: flex; gap: clamp(5px, 1.2vw, 9px); perspective: 800px; }
.ww-tile {
  flex: 1;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--score-2);
  color: #0b0b0b;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 700;
  text-transform: uppercase;
  animation: wwFlip 380ms ease-out both;
}

/* ── Stat blocks ──────────────────────────────────────────────────────── */

.ww-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 22px;
  background: var(--border-default);
  border-radius: 10px;
  overflow: hidden;
}
.ww-hero-stats .ww-stat { background: var(--bg-800); border: 0; border-radius: 0; padding: 14px 12px; }

.ww-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.ww-stat {
  background: var(--bg-800);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 18px;
  animation: wwRise 400ms ease-out both;
}
.ww-stat-value {
  font-family: var(--mono);
  font-size: clamp(22px, 2.8vw, 28px);
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.ww-stat-value--win { color: var(--color-win); }
.ww-stat-value--loss { color: var(--color-loss); }
.ww-stat-value--blue { color: var(--accent-blue); }
.ww-stat-value--teal { color: var(--accent-teal); }
.ww-stat-value--gold { color: var(--medal-gold); }
.ww-stat-label {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

/* ── Stacked distribution bars ────────────────────────────────────────── */

.ww-hero-dist { margin-top: 20px; }
.ww-stack {
  display: flex;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
  transform-origin: left center;
  animation: wwGrow 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ww-stack--tall { height: 34px; border-radius: 6px; }
.ww-stack-seg { min-width: 0; }
.ww-stack-seg--empty { background: var(--bg-700); flex: 1; }
.ww-stack-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}

.ww-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; }
.ww-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-default);
}
.ww-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* ── Line chart ───────────────────────────────────────────────────────── */

.ww-chart-wrap { display: flex; gap: 10px; }
.ww-chart-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: clamp(160px, 26vw, 240px);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}
.ww-chart-svg { flex: 1 1 0; min-width: 0; }
.ww-chart-svg svg {
  width: 100%;
  min-width: 0;
  height: clamp(160px, 26vw, 240px);
  display: block;
  overflow: visible;
}
.ww-chart-line { animation: wwTrace 2600ms ease-out 300ms both; }
.ww-chart-marker { animation: wwFade 400ms ease-out 2400ms both; }
.ww-chart-xaxis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-left: 34px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}
.ww-chart-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.ww-chart-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-default); }
.ww-chart-note strong { color: var(--text-strong); font-weight: 600; text-transform: capitalize; }
.ww-dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }

/* ── Keyboard heat map ────────────────────────────────────────────────── */

.ww-keyboard { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.ww-keyboard-row { display: flex; gap: 4px; justify-content: center; }
.ww-key {
  width: clamp(26px, 7.2vw, 38px);
  height: clamp(26px, 7.2vw, 38px);
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: clamp(12px, 3vw, 16px);
  font-weight: 600;
  color: #fff;
  animation: wwFlip 300ms ease-out both;
}
.ww-keyboard--small .ww-key { width: 26px; height: 26px; font-size: 11px; }
.ww-key--thin { opacity: 0.45; border: 1px dashed var(--border-strong); }
.ww-key--empty { background: transparent; border: 1px dashed var(--border-default); color: var(--text-muted); }

.ww-scale { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.ww-scale-ramp {
  width: clamp(90px, 30vw, 160px);
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(130, 55%, 38%), hsl(65, 55%, 38%), hsl(0, 55%, 38%));
}

/* ── Compare bars ─────────────────────────────────────────────────────── */

.ww-compare { display: flex; flex-direction: column; gap: 12px; }
.ww-compare-row {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr auto;
  gap: 10px;
  align-items: center;
}
.ww-compare-label { font-size: 13px; color: var(--text-default); }
.ww-compare-label span { color: var(--text-muted); }
.ww-compare-track { height: 10px; border-radius: 999px; background: var(--bg-700); overflow: hidden; }
.ww-compare-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-blue);
  transform-origin: left center;
  animation: wwGrow 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ww-compare-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.ww-compare-divider { height: 1px; background: var(--border-subtle); }

/* ── Podium lists ─────────────────────────────────────────────────────── */

.ww-podium { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ww-podium-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--border-strong);
  animation: wwRise 350ms ease-out both;
}
.ww-podium-row--1 { border-left-color: var(--medal-gold); background: var(--medal-gold-muted); }
.ww-podium-row--2 { border-left-color: var(--medal-silver); background: var(--medal-silver-muted); }
.ww-podium-row--3 { border-left-color: var(--medal-bronze); background: var(--medal-bronze-muted); }
.ww-podium-rank { font-family: var(--mono); font-size: 11px; color: var(--text-soft); }
.ww-podium-word {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-default);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ww-podium-row--1 .ww-podium-word,
.ww-podium-row--2 .ww-podium-word,
.ww-podium-row--3 .ww-podium-word { color: var(--text-strong); }
.ww-podium-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-soft);
}
.ww-podium-score {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-default);
  font-variant-numeric: tabular-nums;
}
.ww-podium-row--1 .ww-podium-score,
.ww-podium-row--2 .ww-podium-score,
.ww-podium-row--3 .ww-podium-score { color: var(--text-strong); }

/* ── Streak histogram ─────────────────────────────────────────────────── */

.ww-histogram { display: flex; align-items: flex-end; gap: 2px; height: clamp(120px, 20vw, 170px); }
.ww-histogram-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.ww-histogram-bar {
  border-radius: 3px 3px 0 0;
  background: var(--accent-blue);
  transform-origin: bottom center;
  animation: wwGrowY 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ww-histogram-bar--gold { background: var(--medal-gold); }

/* ── Table ────────────────────────────────────────────────────────────── */

.ww-disclosure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border-default);
  background: var(--bg-800);
  color: var(--text-strong);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.ww-disclosure:hover { background: var(--bg-700); border-color: var(--border-strong); }

.ww-table-panel { padding: 0; overflow: hidden; }
.ww-table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-default);
}
.ww-table-controls input {
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-900);
  color: var(--text-strong);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.ww-table-controls input:focus { border-color: var(--accent-blue); }

.ww-table-header,
.ww-row {
  display: grid;
  grid-template-columns: 62px minmax(72px, 1fr) 2fr 62px 62px;
  gap: 10px;
  align-items: center;
}
.ww-table-header { padding: 10px 16px; border-bottom: 1px solid var(--border-default); background: var(--bg-900); }
.ww-th {
  text-align: left;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.ww-th:hover { color: var(--text-strong); }
.ww-th--right { text-align: right; }
.ww-th--static { cursor: default; }
.ww-th--active { color: var(--text-strong); }

.ww-table-body { max-height: 560px; overflow-y: auto; }
.ww-row { padding: 9px 16px; border-bottom: 1px solid var(--border-subtle); transition: background 120ms ease; }
.ww-row:hover { background: var(--bg-700); }
.ww-row-num { font-family: var(--mono); font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.ww-row-word {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ww-row-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--bg-700); }
.ww-row-avg {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.ww-row-players {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* ── Outro ────────────────────────────────────────────────────────────── */

.ww-outro { gap: 18px; }
.ww-outro-cta { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.ww-outro-copy {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-strong);
  max-width: 40ch;
  text-wrap: pretty;
}
.ww-caveats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.ww-caveat-line { font-size: 12px; line-height: 1.6; color: var(--text-soft); }
.ww-disclaimer { margin: 6px 0 0; font-size: 11px; line-height: 1.6; color: var(--text-muted); }

/* ── Motion ───────────────────────────────────────────────────────────── */

/* Everything inside a [data-reveal] section stays parked until wordle.js sets
   an inline animation-play-state (which wins over this rule). */
.ww-page [data-reveal] * { animation-play-state: paused; }

@keyframes wwFlip {
  0% { transform: rotateX(-92deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotateX(0deg); opacity: 1; }
}
@keyframes wwGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes wwGrowY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes wwRise { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes wwTrace { from { stroke-dashoffset: 8000; } to { stroke-dashoffset: 0; } }
@keyframes wwFade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .ww-page * { animation: none !important; }
}
