/* ── Design tokens: the palette carried over from .streamlit/config.toml ──── */
:root {
  --orange:      #f97316;
  --orange-dark: #ea580c;
  --red:         #ef4444;
  --red-dark:    #dc2626;
  --amber:       #fbbf24;
  --green:       #22c55e;
  --ink:         #0f172a;
  --body:        #4b5563;
  --muted:       #6b7280;
  --faint:       #9ca3af;
  --line:        #e2e8f0;
  --surface:     #f8fafc;
  --card:        #f1f5f9;
  --bg:          #ffffff;
  --maxw:        1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ── Site header ──────────────────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .wrap { padding-top: 20px; padding-bottom: 0; }

.eyebrow {
  color: var(--orange-dark);
  font-size: 11px; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 8px;
}
.site-title {
  font-size: 34px; font-weight: 900;
  margin: 0 0 10px; line-height: 1.15;
}
.site-intro {
  color: var(--body); font-size: 15px;
  max-width: 680px; line-height: 1.75; margin: 0 0 10px;
}
.byline { color: var(--faint); font-size: 13px; margin: 0 0 16px; }
.byline a { color: var(--orange-dark); text-decoration: none; font-weight: 600; }
.byline a:hover { text-decoration: underline; }

/* ── Nav tabs ─────────────────────────────────────────────────────────────── */
.nav { display: flex; gap: 8px; }
.nav a {
  color: var(--muted); text-decoration: none;
  padding: 9px 22px; font-weight: 600; font-size: 14px;
  border-radius: 4px 4px 0 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] {
  color: var(--orange); background: var(--bg);
  border-bottom-color: var(--orange);
}

/* ── Sections and cards ───────────────────────────────────────────────────── */
.section { padding: 28px 0; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: none; }
.section h2 { font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.section .caption { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.card { background: var(--card); border-radius: 8px; padding: 16px 20px; }
.card-top { border-top: 3px solid var(--orange); }

.metric .label { color: var(--muted); font-size: 11px; }
.metric .value { color: var(--ink); font-size: 20px; font-weight: 800; }
.metric .value.hot { color: var(--red); }

.badge {
  background: var(--line); color: #374151;
  padding: 4px 10px; border-radius: 4px;
  font-size: 12px; margin: 2px; display: inline-block;
  text-decoration: none;
}

.finding {
  background: var(--surface); border-radius: 6px;
  padding: 14px 18px; margin-bottom: 10px;
  display: flex; gap: 14px; align-items: flex-start;
}
.finding .icon { font-size: 20px; }
.finding .text { color: #374151; font-size: 14px; line-height: 1.6; }

.note {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 6px; padding: 10px 14px; font-size: 13px; margin: 12px 0;
}

/* ── Charts ───────────────────────────────────────────────────────────────── */
.chart { width: 100%; }
.chart-frame { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

/* ── Error state ──────────────────────────────────────────────────────────── */
.error {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: 8px; padding: 20px 24px; margin: 32px 0;
}
.error h3 { margin: 0 0 6px; font-size: 16px; }
.error p  { margin: 0; font-size: 14px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 40px;
  padding: 24px 0; color: var(--faint); font-size: 13px;
}
.site-footer a { color: var(--orange-dark); text-decoration: none; }

/* ── Explorer ─────────────────────────────────────────────────────────────── */
.filters {
  display: grid; gap: 16px; align-items: end;
  grid-template-columns: 2fr 1fr 1fr auto;
  padding: 16px 0;
}
.filters label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.filters select, .filters input[type="range"] { width: 100%; }
.filters select {
  padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); font-size: 14px; color: var(--ink);
}

.explorer-layout { display: grid; grid-template-columns: 3fr 1fr; gap: 16px; }
#map { height: 520px; border-radius: 8px; border: 1px solid var(--line); }

.detail { background: var(--surface); border-radius: 8px; padding: 16px; }
.detail h3 { margin: 0 0 2px; font-size: 16px; }
.detail .event-id { color: var(--faint); font-size: 11px; margin-bottom: 12px; word-break: break-all; }
.detail .empty { color: var(--muted); font-size: 13px; }

.legend {
  background: var(--bg); border-radius: 6px; padding: 8px 12px;
  font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.12); line-height: 1.7;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .explorer-layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .site-title { font-size: 26px; }
  .nav { overflow-x: auto; }
}

/* ── Story hero ───────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #fff7ed 0%, #ffffff 55%, #fef2f2 100%);
  padding: 56px 32px 44px;
  text-align: center;
  border-bottom: 1px solid #fed7aa;
}
.hero h1 { color: var(--ink); font-size: 48px; font-weight: 900; line-height: 1.1; margin: 0 0 14px; }
.hero .lede { color: var(--muted); font-size: 16px; max-width: 540px; margin: 0 auto 36px; line-height: 1.75; }

/* Was an inline min-width:580px grid, which overflowed narrow screens. */
.hero-stats {
  display: inline-grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  border: 1px solid #fed7aa;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(249, 115, 22, 0.08);
  min-width: 580px;
  max-width: 100%;
}
.hero-stats > div { padding: 20px 28px; border-right: 1px solid #fee2e2; }
.hero-stats > div:last-child { border-right: none; }
.hero-stats .n { font-size: 30px; font-weight: 900; line-height: 1; }
.hero-stats .k {
  color: var(--faint); font-size: 11px; margin-top: 6px; line-height: 1.5;
  text-transform: uppercase; letter-spacing: 1px;
}

@media (max-width: 640px) {
  .hero { padding: 36px 20px 28px; }
  .hero h1 { font-size: 32px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); min-width: 0; width: 100%; }
  .hero-stats > div:nth-child(2n) { border-right: none; }
  .story-section { padding: 36px 20px !important; }
}

.story-section { max-width: 860px; margin: 0 auto; padding: 52px 32px; border-bottom: 1px solid var(--line); }
.story-section h2 { color: var(--ink); font-size: 26px; font-weight: 800; margin: 0 0 14px; }
.story-section p { color: var(--body); font-size: 15px; line-height: 1.8; }
.disclaimer { color: var(--faint); font-size: 12px; font-style: italic; }
