/*
 * Oldways Fibre colour tokens (v14). Every colour on the site, public and
 * admin, is defined here once and used through var(--name)
 * (playbooks/colour-and-contrast.md, Nikita 2026-10-07; whole site,
 * Nikita 2026-10-11). Light is the site's Meadow palette as it was, with
 * the shades that failed contrast darkened: notes text (was #6b7280 and
 * #9ca3af), field borders (was #d1d5db), the bright green and orange
 * action links and the red required mark. Dark is new.
 *
 * Every pair one token is drawn on another is listed in
 * tools/contrast-pairs.json and measured by tools/check-contrast.php:
 * 4.5:1 for text, 3:1 for borders and markers, in both themes.
 *
 * The theme follows the computer unless the visitor picks Light or
 * Dark; the choice is a cookie the server reads (ow_theme), so the page
 * is drawn in the right colours from the first byte.
 */
:root {
    color-scheme: light dark;
    --canvas: #f5f0e8;
    --admin-canvas: #f3f4f6;
    --panel: #ffffff;
    --paper: #fdfcfa;
    --panel-soft: #f9fafb;
    --fill: #f3f4f6;
    --line-soft: #f3f4f6;
    --line: #e5e7eb;
    --parch-line: #ece4d4;
    --parch-line-2: #ddd0ba;
    --line-strong: #7f8691;
    --field-line: #8c816d;
    --ink-strong: #111827;
    --ink: #1f2937;
    --ink-2: #374151;
    --soft: #5c6370;
    --faint: #5c6370;
    --accent: #4a7c59;
    --accent-ink: #3d6a4b;
    --accent-dark: #3a6347;
    --accent-deep: #2d4e38;
    --accent-soft: #b3dbc7;
    --accent-tint: #f1f7f4;
    --on-accent: #ffffff;
    --link: #3a5884;
    --link-button: #3a5884;
    --marker: #4a7c59;
    --denim: #3f6497;
    --denim-deep: #2d4568;
    --denim-tint: #eef2f8;
    --denim-tint-2: #d4ddef;
    --denim-line: #a9bbde;
    --good: #166534;
    --good-bg: #f0fdf4;
    --good-bg-2: #dcfce7;
    --good-line: #86efac;
    --bad: #991b1b;
    --bad-bg: #fef2f2;
    --bad-bg-2: #fee2e2;
    --bad-line: #fca5a5;
    --warn: #92400e;
    --warn-bg: #fffbeb;
    --warn-bg-2: #fef9c3;
    --warn-line: #fde68a;
    --warn-strong: #b45309;
    --orange: #9a3412;
    --orange-bg: #fff7ed;
    --orange-line: #fed7aa;
    --info: #1e3a5f;
    --info-strong: #1d4ed8;
    --info-bg: #eff6ff;
    --info-line: #bfdbfe;
    --shadow-1: rgba(0, 0, 0, 0.05);
    --shadow-2: rgba(0, 0, 0, 0.12);
    --overlay: rgba(0, 0, 0, 0.5);
    --focus-ring: rgba(58, 88, 132, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --canvas: #141917;
        --admin-canvas: #121614;
        --panel: #1c2320;
        --paper: #1f2723;
        --panel-soft: #222a26;
        --fill: #28312c;
        --line-soft: #2a332e;
        --line: #36413b;
        --parch-line: #3a453f;
        --parch-line-2: #4a5650;
        --line-strong: #7f8c85;
    --field-line: #7f8c85;
        --field-line: #7f8c85;
        --ink-strong: #f4f7f5;
        --ink: #e9eeeb;
        --ink-2: #d2dad5;
        --soft: #aab5ae;
        --faint: #aab5ae;
        --accent: #3b7550;
        --accent-ink: #8fcca3;
        --accent-dark: #33664a;
        --accent-deep: #a9d8b7;
        --accent-soft: #3d5a48;
        --accent-tint: #1f2d25;
        --on-accent: #ffffff;
        --link: #9db8e3;
        --link-button: #3d5a8a;
        --marker: #8fcca3;
        --denim: #8eaad8;
        --denim-deep: #c3d3ef;
        --denim-tint: #1f2735;
        --denim-tint-2: #2a3550;
        --denim-line: #46598a;
        --good: #86d9a3;
        --good-bg: #15291d;
        --good-bg-2: #1a3324;
        --good-line: #2f6b45;
        --bad: #f2a3a3;
        --bad-bg: #2d1717;
        --bad-bg-2: #3a1c1c;
        --bad-line: #7a3434;
        --warn: #f3c97a;
        --warn-bg: #2c2310;
        --warn-bg-2: #362b12;
        --warn-line: #6e5521;
        --warn-strong: #a14f0a;
        --orange: #f6b38a;
        --orange-bg: #2d1d12;
        --orange-line: #7a4627;
        --info: #a9c4f0;
        --info-strong: #9fbdf5;
        --info-bg: #172235;
        --info-line: #34507d;
        --shadow-1: rgba(0, 0, 0, 0.4);
        --shadow-2: rgba(0, 0, 0, 0.55);
        --overlay: rgba(0, 0, 0, 0.7);
        --focus-ring: rgba(157, 184, 227, 0.45);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #141917;
    --admin-canvas: #121614;
    --panel: #1c2320;
    --paper: #1f2723;
    --panel-soft: #222a26;
    --fill: #28312c;
    --line-soft: #2a332e;
    --line: #36413b;
    --parch-line: #3a453f;
    --parch-line-2: #4a5650;
    --line-strong: #7f8c85;
    --field-line: #7f8c85;
    --ink-strong: #f4f7f5;
    --ink: #e9eeeb;
    --ink-2: #d2dad5;
    --soft: #aab5ae;
    --faint: #aab5ae;
    --accent: #3b7550;
    --accent-ink: #8fcca3;
    --accent-dark: #33664a;
    --accent-deep: #a9d8b7;
    --accent-soft: #3d5a48;
    --accent-tint: #1f2d25;
    --on-accent: #ffffff;
    --link: #9db8e3;
    --link-button: #3d5a8a;
    --marker: #8fcca3;
    --denim: #8eaad8;
    --denim-deep: #c3d3ef;
    --denim-tint: #1f2735;
    --denim-tint-2: #2a3550;
    --denim-line: #46598a;
    --good: #86d9a3;
    --good-bg: #15291d;
    --good-bg-2: #1a3324;
    --good-line: #2f6b45;
    --bad: #f2a3a3;
    --bad-bg: #2d1717;
    --bad-bg-2: #3a1c1c;
    --bad-line: #7a3434;
    --warn: #f3c97a;
    --warn-bg: #2c2310;
    --warn-bg-2: #362b12;
    --warn-line: #6e5521;
    --warn-strong: #a14f0a;
    --orange: #f6b38a;
    --orange-bg: #2d1d12;
    --orange-line: #7a4627;
    --info: #a9c4f0;
    --info-strong: #9fbdf5;
    --info-bg: #172235;
    --info-line: #34507d;
    --shadow-1: rgba(0, 0, 0, 0.4);
    --shadow-2: rgba(0, 0, 0, 0.55);
    --overlay: rgba(0, 0, 0, 0.7);
    --focus-ring: rgba(157, 184, 227, 0.45);
}

:root[data-theme="light"] {
    color-scheme: light;
}

/* The colour choice, on the public footer and the admin bar. */
.themeswitch { display: inline-flex; gap: 2px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; }
.themeswitch button {
    border: 0; background: transparent; color: var(--soft); font: inherit; font-size: 0.8rem;
    padding: 2px 10px; border-radius: 999px; cursor: pointer; min-height: 0;
}
.themeswitch button.on { background: var(--accent); color: var(--on-accent); }
