/* =========================================================================
   UDISE+ District Education Intelligence Portal — public landing page
   Design tokens: light by default, dark via [data-theme="dark"] (set by
   assets/theme-init.js from the saved "udise_theme" or the OS preference).
   Chart series colours were checked with the dataviz palette validator
   (lightness band, chroma, colour-blind separation, contrast) on each
   theme's card surface.
   ========================================================================= */
:root {
    color-scheme: light;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef2f6;
    --line: #dde3ea;
    --ink: #0f172a;
    --ink-2: #3b4a60;
    --muted: #5d6b80;
    --accent: #0f766e;          /* links, small accent text (AA on white) */
    --accent-bg: #0d9488;       /* buttons */
    --accent-soft: rgba(13, 148, 136, 0.10);
    --on-accent: #ffffff;
    --series-1: #009b8c;        /* validated: light, surface #ffffff */
    --series-2: #eb6834;
    --grid: #e6eaf0;
    --axis: #c4ccd7;
    --good: #006300;
    --bad: #b42318;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
    --radius: 14px;
    --hero-bg: #0a0e14;
    --hero-ink: #e6ecf5;
    --hero-muted: #9aa7bd;
    --hero-teal: #33d9c4;
    --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0e14;
    --surface: #10151f;
    --surface-2: #141b28;
    --line: #212a3a;
    --ink: #e6ecf5;
    --ink-2: #c7d2e2;
    --muted: #8b97ad;
    --accent: #33d9c4;
    --accent-bg: #33d9c4;
    --accent-soft: rgba(51, 217, 196, 0.10);
    --on-accent: #05100e;
    --series-1: #12a594;        /* validated: dark, surface #141b28 */
    --series-2: #d95926;
    --grid: #1c2431;
    --axis: #2c3646;
    --good: #2fbf71;
    --bad: #ff8a8a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
}
/* No-JS fallback: follow the OS setting. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg: #0a0e14; --surface: #10151f; --surface-2: #141b28; --line: #212a3a;
        --ink: #e6ecf5; --ink-2: #c7d2e2; --muted: #8b97ad; --accent: #33d9c4;
        --accent-bg: #33d9c4; --on-accent: #05100e; --series-1: #12a594; --series-2: #d95926;
        --grid: #1c2431; --axis: #2c3646; --good: #2fbf71; --bad: #ff8a8a;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { overflow-x: clip; margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent-bg); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 1000; background: var(--accent-bg); color: var(--on-accent); padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: rgba(10, 14, 20, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(51, 217, 196, 0.15); color: var(--hero-ink); }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--hero-ink); text-decoration: none; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; color: #05100e; background: linear-gradient(135deg, #33d9c4, #9d7bff); font-size: 1rem; }
.brand-text strong { display: block; font-size: 1rem; letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 0.68rem; color: var(--hero-muted); font-family: var(--mono); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.site-nav a { display: block; color: #c9d4e5; text-decoration: none; font-size: 0.84rem; font-weight: 600; padding: 8px 9px; border-radius: 8px; white-space: nowrap; }
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.14); background: transparent; color: var(--hero-ink); cursor: pointer; font-size: 0.95rem; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 10px 18px; font-weight: 700; font-size: 0.9rem; text-decoration: none; border: 1px solid transparent; cursor: pointer; font-family: inherit; white-space: nowrap; }
.btn-primary { background: #33d9c4; color: #05100e; box-shadow: 0 4px 16px rgba(51, 217, 196, 0.25); }
.btn-primary:hover { background: #5ce3d1; }
.btn-ghost { border-color: rgba(255, 255, 255, 0.22); color: var(--hero-ink); background: rgba(255, 255, 255, 0.03); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.nav-toggle { display: none; }
@media (max-width: 1320px) {
    .nav-toggle { display: grid; }
    .site-nav { position: absolute; top: 64px; left: 0; right: 0; background: #0a0e14; border-bottom: 1px solid rgba(51, 217, 196, 0.15); display: none; }
    .site-nav.open { display: block; }
    .site-nav ul { flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
    .site-nav a { padding: 12px; font-size: 0.95rem; }
    .header-actions { margin-left: auto; }
}
@media (max-width: 520px) {
    .brand-text span { display: none; }
    .header-actions .btn { padding: 9px 12px; }
    .header-actions .btn .label-long { display: none; }
}

/* ---------- Hero (keeps the login screen's navy grid identity) ---------- */
.hero { position: relative; overflow: hidden; background: var(--hero-bg); color: var(--hero-ink); padding: 64px 0 72px; }
.hero::before { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(51, 217, 196, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(51, 217, 196, 0.06) 1px, transparent 1px); background-size: 40px 40px; }
.hero::after { content: ''; position: absolute; width: 720px; height: 720px; right: -160px; top: -200px; pointer-events: none; background: radial-gradient(circle, rgba(51, 217, 196, 0.14), transparent 65%); }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; } .hero { padding: 44px 0 52px; } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hero-teal); background: rgba(51, 217, 196, 0.08); border: 1px solid rgba(51, 217, 196, 0.25); padding: 6px 10px; border-radius: 999px; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); margin: 18px 0 14px; color: #fff; }
.hero h1 em { font-style: normal; color: var(--hero-teal); }
.hero-lead { font-size: 1.08rem; color: #c3cfdf; max-width: 560px; }
.hero-purpose { font-size: 0.92rem; color: var(--hero-muted); max-width: 560px; margin-top: 10px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; font-size: 0.8rem; color: var(--hero-muted); font-family: var(--mono); }
.hero-meta i { color: var(--hero-teal); margin-right: 6px; }
.hero-card { background: rgba(16, 21, 31, 0.85); border: 1px solid #212a3a; border-radius: 16px; padding: 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45); }
.hero-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hero-card-head h2 { font-size: 0.95rem; color: #fff; }
.hero-card-head span { font-size: 0.72rem; color: var(--hero-muted); font-family: var(--mono); }
.hero-spark { height: 150px; margin: 12px 0 14px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hero-stat b { font-size: clamp(0.9rem, 3.6vw, 1.15rem); white-space: nowrap; }
.hero-stat { background: #141b28; border: 1px solid #212a3a; border-radius: 10px; padding: 10px 10px; min-width: 0; }
.hero-stat b { display: block; font-size: 1.15rem; color: #fff; }
.hero-stat span { font-size: 0.72rem; color: var(--hero-muted); }

/* ---------- Sections ---------- */
main section { padding: 64px 0; }
main section + section { border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; margin-bottom: 26px; }
.section-head h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
.section-head p { color: var(--muted); max-width: 680px; margin-top: 6px; }
.section-kicker { font-family: var(--mono); font-size: 0.72rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; display: block; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-family: var(--mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }

.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)); }
@media (max-width: 960px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card h3 { font-size: 1rem; }
.card-sub { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .span-2 { grid-column: auto; } }

/* KPI tiles */
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .kpi-grid { grid-template-columns: minmax(0, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-top { display: flex; align-items: center; gap: 10px; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.kpi-title { font-size: 0.88rem; font-weight: 700; color: var(--ink-2); }
.kpi-value { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.kpi-unit { font-size: 0.82rem; color: var(--muted); }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; font-size: 0.78rem; color: var(--muted); }
.delta { font-weight: 700; font-family: var(--mono); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.neutral { color: var(--ink-2); }
.unavailable { color: var(--muted); font-size: 0.9rem; font-style: italic; }

/* Charts */
.chart-box { position: relative; width: 100%; height: 280px; margin-top: 14px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 200px; }
.chart-summary { font-size: 0.82rem; color: var(--ink-2); margin-top: 10px; }
.chart-note { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }
details.data-table { margin-top: 10px; font-size: 0.8rem; }
details.data-table summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.table-wrap { overflow-x: auto; margin-top: 8px; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 700; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
tr:last-child td { border-bottom: none; }

/* Gender proportion bar */
.split-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-top: 16px; gap: 2px; background: var(--surface); }
.split-bar span { display: block; height: 100%; }
.split-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; }
.split-legend div { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.split-legend b { color: var(--ink); }

/* CLRC table with inline bars */
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.clrc-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.clrc-tools input { flex: 1; min-width: 180px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 0.88rem; }
.sort-btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); border-radius: 9px; padding: 8px 12px; font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.sort-btn[aria-pressed="true"] { border-color: var(--accent-bg); color: var(--accent); }

/* Insights */
.insight { display: flex; flex-direction: column; gap: 8px; }
.insight-type { align-self: flex-start; font-size: 0.68rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2); }
.insight-type i { margin-right: 4px; color: var(--accent); }
.insight p { color: var(--ink); }
.insight .basis { font-size: 0.75rem; color: var(--muted); margin-top: auto; }

/* Reports */
.report-card { display: flex; flex-direction: column; gap: 10px; }
.report-card .kpi-icon { width: 42px; height: 42px; font-size: 1.05rem; }
.report-card ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 0.85rem; }
.report-card .lock { margin-top: auto; font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.report-card .lock a { font-weight: 700; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .about-grid { grid-template-columns: minmax(0, 1fr); } }
.about-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.about-list li { display: flex; gap: 10px; font-size: 0.9rem; color: var(--ink-2); }
.about-list i { color: var(--accent); margin-top: 4px; width: 16px; text-align: center; }
.era-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.era-list li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; font-size: 0.85rem; color: var(--ink-2); }
.era-list b { font-family: var(--mono); color: var(--ink); font-size: 0.8rem; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 0.88rem; }
.notice i { color: var(--accent); margin-top: 3px; }

/* Footer */
.site-footer { background: var(--hero-bg); color: var(--hero-muted); padding: 36px 0; font-size: 0.85rem; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.site-footer strong { color: var(--hero-ink); }
.site-footer a { color: var(--hero-teal); }
