/* India Open Data — design system
   Self-contained: no external fonts, no CDN, no tracking. */

:root {
  color-scheme: light dark;

  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceef6;
  --border: #dfe3ee;
  --border-strong: #c6cce0;

  --text: #14161f;
  --text-muted: #5b6172;
  --text-subtle: #868da1;

  --brand: #2f4bd8;
  --brand-hover: #263fb8;
  --brand-soft: #eaeeff;
  --brand-ring: rgba(47, 75, 216, 0.32);

  --accent: #e8630a;
  --accent-soft: #fff1e6;
  --success: #0f7b4f;
  --success-soft: #e6f6ee;
  --danger: #c02b3c;
  --danger-soft: #fdecee;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 31, 0.06);
  --shadow: 0 4px 16px rgba(20, 22, 31, 0.08);
  --shadow-lg: 0 18px 48px rgba(20, 22, 31, 0.14);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --wrap: 1080px;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1017;
    --bg-elevated: #171a24;
    --bg-sunken: #12141d;
    --border: #262a38;
    --border-strong: #39405a;

    --text: #eef0f7;
    --text-muted: #a2a9bd;
    --text-subtle: #7c8398;

    --brand: #8fa4ff;
    --brand-hover: #a8b8ff;
    --brand-soft: #1c2340;
    --brand-ring: rgba(143, 164, 255, 0.35);

    --accent: #ff9a4d;
    --accent-soft: #2c1d10;
    --success: #4ed191;
    --success-soft: #10281d;
    --danger: #ff7b8a;
    --danger-soft: #2d1419;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1017;
  --bg-elevated: #171a24;
  --bg-sunken: #12141d;
  --border: #262a38;
  --border-strong: #39405a;
  --text: #eef0f7;
  --text-muted: #a2a9bd;
  --text-subtle: #7c8398;
  --brand: #8fa4ff;
  --brand-hover: #a8b8ff;
  --brand-soft: #1c2340;
  --brand-ring: rgba(143, 164, 255, 0.35);
  --accent: #ff9a4d;
  --accent-soft: #2c1d10;
  --success: #4ed191;
  --success-soft: #10281d;
  --danger: #ff7b8a;
  --danger-soft: #2d1419;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand small {
  display: block;
  font-weight: 450;
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a, .nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.nav a:hover, .nav button:hover {
  background: var(--bg-sunken);
  color: var(--text);
  text-decoration: none;
}
.nav a[aria-current="page"] { color: var(--text); background: var(--bg-sunken); }

@media (max-width: 640px) {
  .nav .nav-label { display: none; }
  .brand small { display: none; }
}

/* ---------- hero ---------- */

.hero { padding: 40px 0 24px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 4.6vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.hero p.lede {
  margin: 0 0 26px;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 16px;
}

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.pill strong { color: var(--text); font-weight: 650; }

/* ---------- search ---------- */

.search-shell {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: visible;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
}

.search-row .icon { color: var(--text-subtle); flex: none; display: flex; }

#q {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  padding: 12px 0;
}
#q:focus { outline: none; }
#q::placeholder { color: var(--text-subtle); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
}
:root[data-theme="dark"] .btn { color: #0e1017; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn { color: #0e1017; }
}
.btn:hover { background: var(--brand-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }

.btn-sm { padding: 6px 10px; font-size: 12.5px; font-weight: 550; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg-sunken);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.hint {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--text-subtle);
  min-height: 18px;
}

/* ---------- results ---------- */

.results { margin: 22px 0 8px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card { margin-top: 14px; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card-head .sub { color: var(--text-muted); font-size: 13px; }
.card-head .spacer { margin-left: auto; }

.card-body { padding: 18px; }

.title-lg {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.chip-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}
.kv dt { color: var(--text-subtle); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }

@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-sunken);
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-sunken); }
table.data td.num { font-variant-numeric: tabular-nums; text-align: right; }
table.data .mono { font-family: var(--mono); font-size: 12.5px; }

.scroll-x { overflow-x: auto; }
.scroll-y { max-height: 460px; overflow-y: auto; }

/* ---------- suggestions ---------- */

.suggestions {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.suggestion {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.suggestion:hover, .suggestion[aria-selected="true"] {
  background: var(--brand-soft);
}
.suggestion .s-main { font-weight: 550; }
.suggestion .s-meta {
  margin-left: auto;
  color: var(--text-subtle);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- states ---------- */

.state {
  padding: 26px 18px;
  text-align: center;
  color: var(--text-muted);
}
.state .big { font-size: 34px; margin-bottom: 8px; }
.state h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- skeleton ---------- */

.skel {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: skel 1.3s ease infinite;
  border-radius: 6px;
  height: 14px;
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- code / api ---------- */

pre.code {
  margin: 0;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
}

code.inline {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 2px 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  word-break: break-word;
}

.url-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.url-bar code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
  scrollbar-width: none;
}
.url-bar code::-webkit-scrollbar { display: none; }

/* ---------- prose ---------- */

.prose { max-width: 74ch; }
.prose h2 {
  margin: 34px 0 10px;
  font-size: 20px;
  letter-spacing: -0.015em;
}
.prose h3 { margin: 24px 0 8px; font-size: 16px; }
.prose p, .prose li { color: var(--text-muted); }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 56px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 13px;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  align-items: center;
}
.site-footer .spacer { margin-left: auto; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat .n {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .l { color: var(--text-muted); font-size: 13px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
