/* ScamTrace India - site styles.
   Colours are named by their job, defined once here, and swapped for dark mode
   (device setting, or the theme button which sets data-theme on <html>). */

:root {
  color-scheme: light;
  --page:        #f6f7fb;
  --surface:     #ffffff;
  --text:        #0e1330;
  --text-2:      #4a4f66;
  --muted:       #7b8098;
  --grid:        #e4e6ef;
  --axis:        #c9ccd9;
  --border:      rgba(14, 19, 48, 0.09);
  --series-1:    #2a78d6;   /* blue   - the main series */
  --series-2:    #eb6834;   /* orange - the emphasised group / second series */
  --neutral:     #b5b3ab;   /* grey   - everything not emphasised */
  --accent-soft: #fdeee7;
  --hero-1:      #0f1838;   /* hero background, top */
  --hero-2:      #1e2761;   /* hero background, bottom */
  --shadow:      0 1px 2px rgba(14, 19, 48, 0.05), 0 8px 24px rgba(14, 19, 48, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0b0d17; --surface: #151827; --text: #f3f4fa; --text-2: #c3c6d6; --muted: #8a8fa6;
    --grid: #262a3d; --axis: #3a3f57; --border: rgba(255, 255, 255, 0.08);
    --series-1: #3987e5; --series-2: #d95926; --neutral: #5c5b57; --accent-soft: #33221a;
    --hero-1: #070a16; --hero-2: #141a3d; --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0d17; --surface: #151827; --text: #f3f4fa; --text-2: #c3c6d6; --muted: #8a8fa6;
  --grid: #262a3d; --axis: #3a3f57; --border: rgba(255, 255, 255, 0.08);
  --series-1: #3987e5; --series-2: #d95926; --neutral: #5c5b57; --accent-soft: #33221a;
  --hero-1: #070a16; --hero-2: #141a3d; --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; scroll-padding-top: 70px; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.55;
}
a { color: var(--series-1); }
h1, h2, h3 { line-height: 1.2; }
p { margin: 8px 0; }

/* ---------- top menu bar ---------- */
.topnav {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 24px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; color: var(--text); text-decoration: none; margin-right: auto; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--hero-2);
  background-image: linear-gradient(135deg, transparent 45%, var(--series-2) 45% 60%, transparent 60%);
}
.navlinks { display: flex; gap: 18px; flex-wrap: wrap; }
.navlinks a { color: var(--text-2); text-decoration: none; font-size: 0.93rem; font-weight: 500; }
.navlinks a:hover { color: var(--series-1); }
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--axis);
  background: var(--surface); color: var(--text); font-size: 1rem; cursor: pointer;
}
@media (max-width: 720px) { .navlinks { order: 3; width: 100%; gap: 14px; } .topnav { padding: 10px 16px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: 10px; font: inherit; font-weight: 650;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--series-1); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-soft { background: var(--page); color: var(--series-1); border-color: var(--axis); width: 100%; margin-top: 12px; }

/* ---------- hero ---------- */
.hero {
  background: radial-gradient(1200px 500px at 80% -10%, rgba(57, 135, 229, 0.35), transparent 60%),
              linear-gradient(180deg, var(--hero-1), var(--hero-2));
  color: #fff; padding: 64px 24px 40px;
}
.hero-inner { max-width: 1160px; margin: 0 auto; }
.eyebrow {
  display: inline-block; margin: 0 0 16px; padding: 4px 12px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.82rem; letter-spacing: 0.02em; color: #cfd6f5;
}
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); margin: 0 0 16px; max-width: 18ch; letter-spacing: -0.02em; }
.lead { font-size: 1.12rem; color: #d7dcf3; max-width: 62ch; }
.lead b { color: #fff; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0 32px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px; padding: 18px;
}
.tile .value { font-size: 2rem; font-weight: 750; line-height: 1.1; color: #fff; }
.tile .label { color: #cfd6f5; font-size: 0.9rem; margin-top: 6px; }
.tile .src { color: #8f99c6; font-size: 0.75rem; margin-top: 6px; }

.data-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-top: 18px; padding: 12px 16px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.86rem; color: #cfd6f5;
}
.ds-label { font-weight: 700; color: #fff; }
.ds-item b, .ds-updated b { color: #fff; }
.ds-updated { margin-left: auto; padding: 2px 10px; border-radius: 12px; background: rgba(235, 104, 52, 0.22); }
.ds-source { flex-basis: 100%; color: #8f99c6; font-size: 0.78rem; }
@media (max-width: 640px) { .ds-updated { margin-left: 0; } }

/* ---------- sections ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 0 24px 40px; }
@media (max-width: 640px) { main { padding: 0 16px 32px; } .hero { padding: 40px 16px 28px; } }
.section { padding-top: 56px; }
.section-head h2 { font-size: 1.9rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.section-head p { color: var(--text-2); margin: 0 0 20px; max-width: 70ch; }
.eyebrow-dark { margin: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--series-2); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow);
}
.card-title { font-weight: 650; margin: 14px 0 6px; font-size: 0.95rem; }
.fineprint { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }
.chart-box { position: relative; width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-2 > *, .map-layout > * { min-width: 0; }   /* a wide table scrolls inside its card instead */

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip-row button {
  font: inherit; font-size: 0.86rem; cursor: pointer; padding: 6px 14px; border-radius: 20px;
  background: var(--page); color: var(--text-2); border: 1px solid var(--axis);
}
.chip-row button:hover { border-color: var(--series-1); color: var(--series-1); }
.chip-row button[aria-pressed="true"] { background: var(--series-1); color: #fff; border-color: var(--series-1); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-2); margin: 0 0 8px; }
.legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px; background: var(--swatch);
}

/* ---------- map + state panel ---------- */
.map-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 920px) { .map-layout { grid-template-columns: 1fr; } }
.map-wrap { position: relative; }
#indiaMap { width: 100%; height: auto; max-height: 620px; display: block; }
.map-state { stroke: var(--surface); stroke-width: 0.8; cursor: pointer; transition: fill 0.25s, opacity 0.15s; outline: none; }
.map-state:hover, .map-state:focus { opacity: 0.8; stroke: var(--text); stroke-width: 1.2; }
.map-state.is-selected { stroke: var(--series-2); stroke-width: 2.5; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 2; max-width: 200px;
  background: var(--surface); color: var(--text); border: 1px solid var(--axis);
  border-radius: 8px; padding: 6px 10px; font-size: 0.82rem; box-shadow: var(--shadow);
}
.map-tip span { color: var(--muted); }
.map-legend, .map-top { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 0.8rem; color: var(--text-2); margin-top: 10px; }
.legend-title { flex-basis: 100%; font-weight: 650; color: var(--text); font-size: 0.82rem; }
.legend-step i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.map-top button {
  font: inherit; font-size: 0.82rem; background: var(--page); color: var(--text-2);
  border: 1px solid var(--grid); border-radius: 8px; padding: 4px 10px; cursor: pointer;
}
.map-top button:hover { border-color: var(--series-1); }

.state-panel { position: sticky; top: 76px; }
@media (max-width: 920px) { .state-panel { position: static; } }
.state-panel h3 { font-size: 1.7rem; margin: 2px 0 12px; }
.explorer-controls { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.explorer-controls label { flex: 1 1 150px; display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-2); }
.explorer-controls select {
  width: 100%; min-width: 0; font: inherit; font-size: 0.92rem; color: var(--text); background: var(--page);
  border: 1px solid var(--axis); border-radius: 8px; padding: 7px 8px;
}
.ex-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ex-card { background: var(--page); border: 1px solid var(--grid); border-radius: 10px; padding: 9px 11px; }
.ex-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.ex-label { color: var(--text-2); font-size: 0.76rem; }
.ex-value { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.ex-value small, .ex-vs small { font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.ex-vs { font-size: 0.82rem; margin-top: 2px; color: var(--text-2); }
.ex-vs span { color: var(--series-2); font-weight: 650; }
.ex-story { margin-top: 10px; }
.ex-story .card-title { display: none; }
.ex-story p { margin: 6px 0; font-size: 0.9rem; color: var(--text-2); }
.ex-story b { color: var(--text); }
.badge {
  display: inline-block; background: var(--accent-soft); color: var(--text); border: 1px solid var(--series-2);
  border-radius: 12px; padding: 1px 9px; font-size: 0.78rem; font-weight: 650; margin-right: 4px;
}

/* ---------- findings ---------- */
.finding { margin-top: 18px; }
.grid-2 .finding { margin-top: 0; }
.finding-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.finding-head h3 { margin: 2px 0 2px; font-size: 1.15rem; }
.finding-head p { margin: 0; color: var(--text-2); font-size: 0.92rem; }
.num {
  flex: 0 0 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--hero-2); color: #fff; font-weight: 750;
}

/* ---------- tables ---------- */
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--series-1); font-size: 0.88rem; font-weight: 550; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; margin-top: 8px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-2); font-weight: 600; }
td { font-variant-numeric: tabular-nums; }
tr.hl td { background: var(--accent-soft); }

/* ---------- ask (inline assistant) ---------- */
.ask-card { display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; padding: 28px; }
@media (max-width: 820px) { .ask-card { grid-template-columns: 1fr; padding: 20px; } }
.ask-intro h2 { font-size: 1.9rem; margin: 4px 0 8px; }
.ask-intro p { color: var(--text-2); }
.ask-chat { display: flex; flex-direction: column; min-height: 420px; max-height: 520px;
  background: var(--page); border: 1px solid var(--grid); border-radius: 14px; overflow: hidden; }
.ask-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ask-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--grid); background: var(--surface); }
.ask-form input, #chat-input {
  flex: 1; min-width: 0; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--page); border: 1px solid var(--axis); border-radius: 10px;
}

/* ---------- report a scam ---------- */
.help-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .help-grid { grid-template-columns: 1fr; } }
.help-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.help-num { font-size: 1.45rem; font-weight: 800; color: var(--series-2); overflow-wrap: anywhere; }
.help-card p { margin: 6px 0 0; font-size: 0.92rem; color: var(--text-2); }
.help-card b { color: var(--text); }

/* ---------- about ---------- */
.pipeline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.pipeline span { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; font-weight: 600; box-shadow: var(--shadow); }
.pipeline i { color: var(--muted); font-style: normal; }
ul.plain { padding-left: 18px; margin: 8px 0 0; }
ul.plain li { margin: 7px 0; color: var(--text-2); font-size: 0.92rem; }
ul.plain b { color: var(--text); }
.about h3, #limitations, #sources { margin-top: 0; }

.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 32px 16px 80px; border-top: 1px solid var(--grid); margin-top: 48px; }
.footer p { margin: 4px 0; }

/* ---------- chat bubble + messages (chat.js) ---------- */
#chat-open {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  background: var(--series-2); color: #fff; border: 0; border-radius: 24px;
  padding: 12px 18px; font: inherit; font-weight: 650; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}
#chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 21;
  width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); overflow: hidden;
}
#chat-panel[hidden], #chat-open[hidden] { display: none; }
#chat-panel header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
#chat-panel header span { display: block; color: var(--muted); font-size: 0.78rem; }
#chat-close { background: none; border: 0; color: var(--text-2); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px; }
#chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--grid); }
#chat-form button { background: var(--series-1); color: #fff; border: 0; border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 650; cursor: pointer; }

.chat-msg { max-width: 92%; padding: 9px 13px; border-radius: 14px; font-size: 0.9rem; overflow-wrap: anywhere; }
.chat-msg p, .chat-msg ul, .chat-msg ol { margin: 4px 0; }
.chat-msg ul, .chat-msg ol { padding-left: 20px; }
.chat-user { align-self: flex-end; background: var(--series-1); color: #fff; border-bottom-right-radius: 4px; }
.chat-bot  { align-self: flex-start; background: var(--surface); border: 1px solid var(--grid); border-bottom-left-radius: 4px; }
.chat-bot table { font-size: 0.8rem; margin: 6px 0; overflow-wrap: normal; word-break: normal; }
.chat-bot th, .chat-bot td { padding: 3px 6px; white-space: normal; }
.chat-note { color: var(--muted); font-size: 0.78rem; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-chips button, .chat-jump {
  background: var(--page); color: var(--series-1); border: 1px solid var(--axis);
  border-radius: 14px; padding: 4px 10px; font: inherit; font-size: 0.8rem; cursor: pointer; text-align: left;
}
.chat-jump { margin-top: 8px; border-style: dashed; }
