/* psud0 colours, dark and light.
 *
 * Every themed page loads this file and /apps/js/theme.js in its <head>.
 * theme.js sets data-palette="light" on <html> when the person's theme is
 * light (or auto on a light computer) AND the page has data-theme-ready on
 * its <html> — pages that haven't been converted stay dark.
 *
 * Converting a page: add data-theme-ready to <html>, load these two files,
 * and replace every typed-in colour with one of the variables below (the
 * page's own :root block can go, apart from anything only it uses). The
 * light block wins over a page's own :root either way (higher specificity).
 *
 * Themes = palette + accent (+ home layout), see /apps/js/theme.js:
 *   data-palette  light | dark   — surfaces, text, status colours
 *   data-accent   gold | …       — the --brand-gold* family below
 * The --brand-gold* names mean "the accent", whatever its colour. Adding
 * an accent (say green) is a CSS block for each palette plus a theme
 * entry in theme.js and lib/themes.js — no page changes:
 *   :root[data-accent="green"] {
 *       --brand-gold: #22c55e; --brand-gold-dim: #16a34a;
 *       --brand-gold-faint: #05200f; --brand-gold-text: #22c55e;
 *       --brand-gold-hover: #4ade80; --brand-on-gold: #04130a;
 *       --brand-gold-ring: 0 0 0 3px rgba(34, 197, 94, 0.12);
 *   }
 *   :root[data-palette="light"][data-accent="green"] { …light values… }
 * A theme can also change any other colour (text, surfaces, borders,
 * status colours) with its own block keyed on data-theme, e.g.
 *   :root[data-theme="forest"] { --brand-text: #e3efe6; … }
 *   :root[data-theme="forest"][data-palette="light"] { … }  (if it can be light)
 * Put theme blocks at the END of this file: they're as specific as the
 * palette/accent blocks, so the later one wins.
 * Pages must never type an accent colour themselves (no #ffb800, no
 * rgba(255,184,0,…)) or it stays gold under every accent. Known leftover:
 * the scrollbar arrow SVGs are gold (#cc9300); they only show on some OS
 * scrollbar styles.
 *
 * Names: --brand-muted is a SURFACE (borders, chips, tracks), not text —
 * grey text is --brand-text-muted / --brand-text-dim. Gold text, links and
 * active nav use --brand-gold-text; --brand-gold is for fills and icons
 * (bright gold is unreadable as text on white).
 */

:root {
    --brand-base: #0d0900;
    --brand-surface: #111111;
    --brand-card: #181818;
    --brand-border: #242424;
    --brand-muted: #333333;
    --brand-gold: #ffb800;
    --brand-gold-dim: #cc9300;
    --brand-gold-faint: #1c1600;
    --brand-gold-text: #ffb800;
    --brand-gold-hover: #ffc933;
    --brand-gold-ring: 0 0 0 3px rgba(255, 184, 0, 0.08);
    --brand-on-gold: #0d0900;
    --brand-text: #e8e3db;
    --brand-text-muted: #7a7570;
    --brand-text-dim: #67625c; /* ~3:1 on the dark surfaces (was #444, too faint) */

    --color-success: #10b981;
    --color-success-bg: #051a10;
    --color-success-border: #064e3b;
    --color-success-text: #34d399;
    --color-danger: #ef4444;
    --color-danger-bg: #1a0505;
    --color-danger-border: #3f1515;
    --color-danger-text: #f87171;
    --color-info: #3b82f6;
    --color-info-bg: #0c1a33;
    --color-info-border: #1e3a5f;
    --color-info-text: #60a5fa;
    --color-warning: #f59e0b;
    --color-warning-bg: #1a1000;
    --color-warning-border: #3d2800;
    --color-warning-text: #fbbf24;
    --color-purple: #8b5cf6;
    --color-purple-bg: #1a0d3a;
    --color-purple-border: #2d1a5a;
    --color-purple-text: #a78bfa;

    /* Bars, overlays and shadows */
    --header-bg: rgba(13, 9, 0, 0.97);
    --scrollbar-track: rgba(13, 9, 0, 0.97);
    --overlay: rgba(0, 0, 0, 0.75);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

:root[data-palette="light"] {
    --brand-base: #f5f3ee;
    --brand-surface: #fbfaf7;
    --brand-card: #ffffff;
    --brand-border: #e6e1d8;
    --brand-muted: #d8d2c7;
    --brand-gold: #d99a00;
    --brand-gold-dim: #9a6b00;
    --brand-gold-faint: #fff3d1;
    --brand-gold-text: #9a6b00;
    --brand-gold-hover: #e8a800;
    --brand-gold-ring: 0 0 0 3px rgba(217, 154, 0, 0.18);
    --brand-on-gold: #1d1b18;
    --brand-text: #1d1b18;
    --brand-text-muted: #6b665e;
    --brand-text-dim: #857f75; /* ≥3.5:1 on the light surfaces */

    --color-success: #059669;
    --color-success-bg: #ecfdf5;
    --color-success-border: #a7f3d0;
    --color-success-text: #047857;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-danger-border: #fecaca;
    --color-danger-text: #b91c1c;
    --color-info: #2563eb;
    --color-info-bg: #eff6ff;
    --color-info-border: #bfdbfe;
    --color-info-text: #1d4ed8;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fde68a;
    --color-warning-text: #b45309;
    --color-purple: #7c3aed;
    --color-purple-bg: #f5f3ff;
    --color-purple-border: #ddd6fe;
    --color-purple-text: #6d28d9;

    --header-bg: rgba(251, 250, 247, 0.96);
    --scrollbar-track: #ebe7df;
    --overlay: rgba(29, 27, 24, 0.45);
    --shadow-sm: 0 4px 14px rgba(29, 27, 24, 0.14);
    --shadow-lg: 0 8px 24px rgba(29, 27, 24, 0.12);
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--brand-gold-dim);
    border-radius: 4px;
    transition: background 0.15s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-gold);
}
/* Up/down (and left/right) arrow buttons at the track ends — only rendered
   by some browsers/OS scrollbar themes, so they're drawn to match rather
   than hidden outright. The #cc9300 arrows read on both palettes. */
::-webkit-scrollbar-button {
    background-color: var(--scrollbar-track);
    background-repeat: no-repeat;
    background-position: center;
    display: block;
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-button:hover {
    background-color: var(--brand-surface);
}
::-webkit-scrollbar-button:vertical:start:decrement {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 6l3-3 3 3' fill='none' stroke='%23cc9300' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:vertical:end:increment {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' fill='none' stroke='%23cc9300' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:horizontal:start:decrement {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M6 2L3 5l3 3' fill='none' stroke='%23cc9300' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:horizontal:end:increment {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M4 2l3 3-3 3' fill='none' stroke='%23cc9300' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
::-webkit-scrollbar-button:vertical:start:decrement:hover,
::-webkit-scrollbar-button:vertical:end:increment:hover,
::-webkit-scrollbar-button:horizontal:start:decrement:hover,
::-webkit-scrollbar-button:horizontal:end:increment:hover {
    filter: brightness(1.3);
}
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--brand-gold-dim) var(--scrollbar-track);
}

/* ── Accents for the named themes (theme.js: accent) ── */
/* Blue — Tokyo Night. Dark only (no theme pairs it with light yet). */
:root[data-accent="blue"] {
    --brand-gold: #7aa2f7;
    --brand-gold-dim: #3d59a1;
    --brand-gold-faint: #1f2a48;
    --brand-gold-text: #7aa2f7;
    --brand-gold-hover: #89b4fa;
    --brand-on-gold: #16161e;
    --brand-gold-ring: 0 0 0 3px rgba(122, 162, 247, 0.16);
}
/* Lime — Moody Green. Dark only. */
:root[data-accent="lime"] {
    --brand-gold: #c5e08a;
    --brand-gold-dim: #8fa860;
    --brand-gold-faint: #232b1a;
    --brand-gold-text: #c5e08a;
    --brand-gold-hover: #d4eaa3;
    --brand-on-gold: #141810;
    --brand-gold-ring: 0 0 0 3px rgba(197, 224, 138, 0.14);
}

/* ── Named themes: their own surfaces, text and status colours ──
   Both are dark-only themes (palette "dark" in theme.js), so there's no
   [data-palette="light"] variant. Contrast checked: text ≥ 9:1, muted
   ≥ 6.4:1, dim ≥ 3.7:1, accent and status colours ≥ 5.8:1 on every surface. */
:root[data-theme="tokyo-night"] {
    --brand-base: #16161e;
    --brand-surface: #1a1b26;
    --brand-card: #1f2335;
    --brand-border: #292e42;
    --brand-muted: #3b4261;
    --brand-text: #c0caf5;
    --brand-text-muted: #9aa5ce;
    --brand-text-dim: #737aa2;

    --color-success: #9ece6a;
    --color-success-bg: color-mix(in srgb, #9ece6a 12%, #1a1b26);
    --color-success-border: color-mix(in srgb, #9ece6a 32%, #1a1b26);
    --color-success-text: #9ece6a;
    --color-danger: #f7768e;
    --color-danger-bg: color-mix(in srgb, #f7768e 12%, #1a1b26);
    --color-danger-border: color-mix(in srgb, #f7768e 32%, #1a1b26);
    --color-danger-text: #f7768e;
    --color-info: #7dcfff;
    --color-info-bg: color-mix(in srgb, #7dcfff 12%, #1a1b26);
    --color-info-border: color-mix(in srgb, #7dcfff 32%, #1a1b26);
    --color-info-text: #7dcfff;
    --color-warning: #e0af68;
    --color-warning-bg: color-mix(in srgb, #e0af68 12%, #1a1b26);
    --color-warning-border: color-mix(in srgb, #e0af68 32%, #1a1b26);
    --color-warning-text: #e0af68;
    --color-purple: #bb9af7;
    --color-purple-bg: color-mix(in srgb, #bb9af7 12%, #1a1b26);
    --color-purple-border: color-mix(in srgb, #bb9af7 32%, #1a1b26);
    --color-purple-text: #bb9af7;

    --header-bg: rgba(22, 22, 30, 0.96);
    --scrollbar-track: #16161e;
    --overlay: rgba(10, 10, 16, 0.72);
}

:root[data-theme="moody-green"] {
    --brand-base: #111310;
    --brand-surface: #151813;
    --brand-card: #1a1e18;
    --brand-border: #2a3026;
    --brand-muted: #3a4134;
    --brand-text: #e4e9d6;
    --brand-text-muted: #a0a693;
    --brand-text-dim: #767c6a;

    --color-success: #8fd18a;
    --color-success-bg: color-mix(in srgb, #8fd18a 12%, #151813);
    --color-success-border: color-mix(in srgb, #8fd18a 32%, #151813);
    --color-success-text: #8fd18a;
    --color-danger: #ec8e80;
    --color-danger-bg: color-mix(in srgb, #ec8e80 12%, #151813);
    --color-danger-border: color-mix(in srgb, #ec8e80 32%, #151813);
    --color-danger-text: #ec8e80;
    --color-info: #8fb6dc;
    --color-info-bg: color-mix(in srgb, #8fb6dc 12%, #151813);
    --color-info-border: color-mix(in srgb, #8fb6dc 32%, #151813);
    --color-info-text: #8fb6dc;
    --color-warning: #e8c27a;
    --color-warning-bg: color-mix(in srgb, #e8c27a 12%, #151813);
    --color-warning-border: color-mix(in srgb, #e8c27a 32%, #151813);
    --color-warning-text: #e8c27a;
    --color-purple: #bba5e2;
    --color-purple-bg: color-mix(in srgb, #bba5e2 12%, #151813);
    --color-purple-border: color-mix(in srgb, #bba5e2 32%, #151813);
    --color-purple-text: #bba5e2;

    --header-bg: rgba(17, 19, 16, 0.96);
    --scrollbar-track: #111310;
    --overlay: rgba(8, 10, 7, 0.72);
}
