/*
 * Theme "Tusche in Lila" - every design value of the site lives here
 * (prompt section 8): colours, fonts, spacing, radii, shadows. Component
 * styles in base.css only use these variables.
 *
 * Light: rice paper with a hint of lavender, violet-black ink, the seal
 * and highlights in the brand purple #5b2a86. Dark: the same set
 * inverted - night-violet paper, light ink. Default follows the system
 * (prefers-color-scheme); the switch in the header stores an explicit
 * choice in a cookie, which the server writes as data-theme on <html>.
 *
 * Contrast (WCAG 2.2 AA, checked): every text colour reaches at least
 * 4.5:1 (body text at least 6:1) on --color-bg and --color-surface in
 * both sets; form field borders (--color-border-strong) and the focus
 * ring at least 3:1.
 *
 * Fonts (SIL Open Font License, served locally, licences next to the
 * files): Shippori Mincho for headings, Zen Kaku Gothic New for text.
 * Only Latin subsets plus the two seal glyphs are shipped.
 */

@font-face {
    font-family: "Shippori Mincho";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/shippori-mincho-latin-ext-500.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Shippori Mincho";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/shippori-mincho-latin-500.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Shippori Mincho";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/shippori-mincho-latin-ext-700.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Shippori Mincho";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/shippori-mincho-latin-700.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Zen Kaku Gothic New";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/zen-kaku-gothic-new-latin-ext-400.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Zen Kaku Gothic New";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/zen-kaku-gothic-new-latin-400.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Zen Kaku Gothic New";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/zen-kaku-gothic-new-latin-ext-700.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Zen Kaku Gothic New";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/zen-kaku-gothic-new-latin-700.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Only the seal glyphs 詠春 and the numerals 一 二 三. */
@font-face {
    font-family: "Shippori Mincho";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/shippori-mincho-seal-700.woff2") format("woff2");
    unicode-range: U+4E00, U+4E09, U+4E8C, U+6625, U+8A60;
}

:root {
    color-scheme: light;

    /* Colours - light */
    --color-canvas: #ddd3e6;
    --color-bg: #f4f0f7;
    --color-surface: #fbf9fc;
    --color-surface-strong: #ebe3f2;
    --color-text: #221a2b;
    --color-muted: #5b5166;
    --color-border: #d6cbe1;
    --color-border-strong: #86749a;
    --color-accent: #221a2b;
    --color-accent-hover: #5b2a86;
    --color-on-accent: #f7f3fa;
    --color-link: #5b2a86;
    --color-focus: #5b2a86;
    --color-seal: #5b2a86;
    --color-on-seal: #f7f1fb;
    --color-brush: rgba(142, 95, 184, 0.55);
    --color-group: #5b2a86;
    --color-danger: #b00020;
    --color-success: #1b5e20;
    --color-tooltip-bg: #221a2b;
    --color-tooltip-text: #f7f3fa;
    --paper-texture: url("../img/paper-texture.svg");
    --paper-glow: rgba(91, 42, 134, 0.10);
    --map-tile-filter: saturate(0.85);
    --select-arrow: url("../img/chevron-light.svg");
    --focus-ring: 0 0 0 3px rgba(91, 42, 134, 0.22);

    /* Fonts */
    --font-sans: "Zen Kaku Gothic New", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Shippori Mincho", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --font-size-base: 1rem;
    --font-size-small: 0.9rem;
    --font-size-xsmall: 0.85rem;
    --font-size-h1: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem);
    --font-size-h2: 1.45rem;
    --font-weight-normal: 400;
    --font-weight-strong: 700;
    --font-weight-bold: 700;
    --line-height: 1.6;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2.5rem;
    --page-width: 46rem;
    --page-width-wide: 84rem;
    --touch-target: 44px;

    /* Radii - ink and paper: small, calm curves */
    --radius-small: 4px;
    --radius: 6px;
    --radius-large: 10px;
    --radius-pill: 4px;
    --radius-seal: 3px;

    /* Frames and shadows */
    --frame: 0 0 0 4px var(--color-surface), 0 0 0 5px var(--color-border);
    --shadow-card: 0 1px 2px rgba(34, 26, 43, 0.06), 0 4px 16px rgba(34, 26, 43, 0.06);
    --shadow-sheet: 0 1px 2px rgba(34, 26, 43, 0.06), 0 18px 48px -18px rgba(34, 26, 43, 0.35);
    --shadow-control: 0 1px 2px rgba(34, 26, 43, 0.12), 0 1px 6px rgba(34, 26, 43, 0.08);
    --shadow-pin: 0 1px 4px rgba(0, 0, 0, 0.4);
    --shadow-popover: 0 6px 24px rgba(34, 26, 43, 0.2);
}

/* Dark - used when the system prefers it and no explicit light choice
   was made, or when dark was chosen explicitly. Both blocks hold the
   same values. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --color-canvas: #0d0a10;
        --color-bg: #17121d;
        --color-surface: #211a29;
        --color-surface-strong: #2c2336;
        --color-text: #ece6f2;
        --color-muted: #b9aec6;
        --color-border: #3a3046;
        --color-border-strong: #7f6d93;
        --color-accent: #e6dcef;
        --color-accent-hover: #c9a8ee;
        --color-on-accent: #1b1422;
        --color-link: #d4b8f3;
        --color-focus: #e2cdf8;
        --color-seal: #7e46b3;
        --color-on-seal: #fbf7fe;
        --color-brush: rgba(201, 168, 238, 0.45);
        --color-group: #c9a8ee;
        --color-danger: #ff8d97;
        --color-success: #8fd694;
        --color-tooltip-bg: #ece6f2;
        --color-tooltip-text: #17121d;
        --paper-texture: none;
        --paper-glow: rgba(126, 70, 179, 0.16);
        --map-tile-filter: brightness(0.82) contrast(1.05);
        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
        --shadow-popover: 0 6px 24px rgba(0, 0, 0, 0.5);
    --shadow-sheet: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 18px 48px -18px rgba(0, 0, 0, 0.8);
    --shadow-control: 0 1px 3px rgba(0, 0, 0, 0.5);
    --select-arrow: url("../img/chevron-dark.svg");
    --focus-ring: 0 0 0 3px rgba(201, 168, 238, 0.3);
        --shadow-sheet: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 18px 48px -18px rgba(0, 0, 0, 0.8);
        --shadow-control: 0 1px 3px rgba(0, 0, 0, 0.5);
        --select-arrow: url("../img/chevron-dark.svg");
        --focus-ring: 0 0 0 3px rgba(201, 168, 238, 0.3);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --color-canvas: #0d0a10;
    --color-bg: #17121d;
    --color-surface: #211a29;
    --color-surface-strong: #2c2336;
    --color-text: #ece6f2;
    --color-muted: #b9aec6;
    --color-border: #3a3046;
    --color-border-strong: #7f6d93;
    --color-accent: #e6dcef;
    --color-accent-hover: #c9a8ee;
    --color-on-accent: #1b1422;
    --color-link: #d4b8f3;
    --color-focus: #e2cdf8;
    --color-seal: #7e46b3;
    --color-on-seal: #fbf7fe;
    --color-brush: rgba(201, 168, 238, 0.45);
    --color-group: #c9a8ee;
    --color-danger: #ff8d97;
    --color-success: #8fd694;
    --color-tooltip-bg: #ece6f2;
    --color-tooltip-text: #17121d;
    --paper-texture: none;
    --paper-glow: rgba(126, 70, 179, 0.16);
    --map-tile-filter: brightness(0.82) contrast(1.05);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-popover: 0 6px 24px rgba(0, 0, 0, 0.5);
}
