/* The three realms (olympus / mortal / hades) for the whole app. Load AFTER style.css.
   Every selector is :root[data-realm="..."] (0,2,0) so it beats style.css's html[data-theme="light"] (0,1,1).
   Palettes follow admin/admin-theme.css; the tokens that file lacks are filled in here for each realm. */

/* ── Shared: aliases and constants (same specificity as the palettes; they set different properties) ── */
:root[data-realm] {
    --serif: Georgia, 'Times New Roman', serif;
    --royal: var(--accent);
    --royal-hi: var(--accent-hover);
    --success: var(--good);
    --success-bg: var(--good-dim);
    --error: var(--danger);
    --warn-bg: var(--warn-dim);
    --white: #fff;
}

/* ── Olympus: light, sage and gold ─────────────────────────────── */
:root[data-realm="olympus"] {
    color-scheme: light;
    --bg: #e4e6d9; --surface: #fffefa; --raised: #d5dcc8;
    --head-bg: #eceee0; --row-hover: #eef1e4;
    --fg: #1e3630; --fg-soft: #30483b; --muted: #46574c; --faint: #46574c;
    --border: #aeb9a3; --border-subtle: #c8d0bb; --border-row: #e1e5d4;
    --accent: #466345; --accent-hover: #334e34; --accent-dim: #e0e7d8; --royal-dim: #334e34;
    --on-royal: #fffefa;
    --royal-bg: rgba(70,99,69,0.12);
    --baby: #2a6579;
    --gold: #917347; --good: #3f6339; --good-dim: #e2eadc; --success-fg: #2f5229;
    --danger: #9e3d37; --danger-dim: #f5e2dc; --error-fg: #99372f; --error-bg: rgba(172,68,60,0.10);
    --warn: #775520; --warn-dim: #f1e7cc; --warn-fg: #6c4b12;
    --projected: #2a6579; --projected-soft: rgba(42,101,121,0.5);
    --sidebar-bg: #243e35; --sidebar-fg: #fffef3; --sidebar-active: #47654f;
    --sidebar-icon: #d4bb84; --sidebar-muted: #bfd0c4;
}
/* ── Mortal: light, harbour blue ───────────────────────────────── */
:root[data-realm="mortal"] {
    color-scheme: light;
    --bg: #d5e6ec; --surface: #fbfeff; --raised: #c3dce4;
    --head-bg: #e1eef2; --row-hover: #e6f1f5;
    --fg: #103747; --fg-soft: #254958; --muted: #3d5965; --faint: #3d5965;
    --border: #91b2bf; --border-subtle: #b3ccd6; --border-row: #d6e5ea;
    --accent: #286e79; --accent-hover: #1d5660; --accent-dim: #d8eaed; --royal-dim: #1d5660;
    --on-royal: #fbfeff;
    --royal-bg: rgba(40,110,121,0.12);
    --baby: #2a6579;
    --gold: #917347; --good: #266b5d; --good-dim: #d9ece5; --success-fg: #1c5246;
    --danger: #9f3f37; --danger-dim: #f5e2dc; --error-fg: #99372f; --error-bg: rgba(172,68,60,0.10);
    --warn: #79561e; --warn-dim: #f1e7cc; --warn-fg: #6c4b12;
    --projected: #2a6579; --projected-soft: rgba(42,101,121,0.5);
    --sidebar-bg: #10394c; --sidebar-fg: #f5fcff; --sidebar-active: #2d6277;
    --sidebar-icon: #d4bb84; --sidebar-muted: #b5cfdb;
}
/* ── Hades: dark, plum and copper ──────────────────────────────── */
:root[data-realm="hades"] {
    color-scheme: dark;
    --bg: #231f25; --surface: #2c262e; --raised: #352d35;
    --head-bg: #29232b; --row-hover: #322b34;
    --fg: #eee3d3; --fg-soft: #d8ccbf; --muted: #b7aaa9; --faint: #b7aaa9;
    --border: #493d47; --border-subtle: #3d333c; --border-row: #342c35;
    --accent: #e4aa80; --accent-hover: #f2c6a3; --accent-dim: #493239; --royal-dim: #cf9367;
    --on-royal: #231f25;
    --royal-bg: rgba(228,170,128,0.14);
    --baby: #9fc7d6;
    --gold: #dfac7c; --good: #b4c28a; --good-dim: #363d2d; --success-fg: #b4c28a;
    --danger: #f29b8b; --danger-dim: #4c3035; --error-fg: #f29b8b; --error-bg: rgba(242,155,139,0.14);
    --warn: #e3bd78; --warn-dim: #453a2c; --warn-fg: #e3bd78;
    --projected: #8cc4d6; --projected-soft: rgba(140,196,214,0.55);
    --sidebar-bg: #19171e; --sidebar-fg: #e6d7ce; --sidebar-active: #57343f;
    --sidebar-icon: #dfac7c; --sidebar-muted: #b7aaa9;
}

/* ── Dark sidebar in every realm: re-scope the tokens its subtree reads, markup stays as it is ── */
:root[data-realm] :is(.sidebar, .top-bar, .help-rail) {
    --fg: var(--sidebar-fg); --fg-soft: var(--sidebar-fg);
    --muted: var(--sidebar-muted); --faint: var(--sidebar-muted);
    --border: rgba(255,255,255,0.28); --border-subtle: rgba(255,255,255,0.15); --border-row: rgba(255,255,255,0.10);
    --raised: var(--sidebar-active); --row-hover: var(--sidebar-active);
    --royal: var(--sidebar-icon); --royal-hi: var(--sidebar-icon); --royal-bg: var(--sidebar-active);
    --warn-fg: var(--sidebar-fg); --warn-bg: rgba(255,255,255,0.12);
    --gold: var(--sidebar-fg);
    --white: var(--sidebar-fg);
    color: var(--sidebar-fg);
}
:root[data-realm] :is(.sidebar, .top-bar, .help-rail) .lang-dropdown-menu { background: var(--sidebar-bg); }
:root[data-realm] .nav-item:hover,
:root[data-realm] .nav-item.active { color: var(--sidebar-fg); }
:root[data-realm] .nav-icon { color: var(--sidebar-icon); }

/* ── Text on a --royal fill (copper in hades is light, so white fails there) ── */
:root[data-realm] :is(.btn-primary, button.primary) { color: var(--on-royal); }
:root[data-realm] .seg-toggle-opt.active { color: var(--on-royal); }
:root[data-realm] .badge-in { color: var(--on-royal); }
:root[data-realm] .switch input:checked + .switch-track::before { background: var(--on-royal); }

/* ── Type: Georgia for page, modal and card-section titles only ── */
:root[data-realm] :is(.page-head h1, .page-title, .modal-title, .modal-box h2, .modal-box h3, .list-head h2, .section > h2, .section > h3,
    body.dashboard-page .section-title, .chart-card-title, .loc-section-title) {
    font-family: var(--serif);
    font-weight: 400;
    letter-spacing: -0.01em;
}
/* card titles are small uppercase captions in style.css; as serif they read at title size */
:root[data-realm] :is(body.dashboard-page .section-title, .chart-card-title, .loc-section-title) {
    text-transform: none; font-size: 1.05rem; color: var(--fg);
}

/* ── Focus ring in gold, app-wide ── */
:root[data-realm] :focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
:root[data-realm] :is(input, select, textarea):focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--royal-bg); }
:root[data-realm] .toolbar-search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--royal-bg); }
:root[data-realm] .switch input:focus-visible + .switch-track { outline-color: var(--gold); }
