/*
 * pss: the app theme (design tokens). Loaded AFTER css/app.css and overrides its --ps-* tokens, so every screen follows.
 * Palette: "smoke" (light) and "graphite" (dark), neutral and warm, never blue. The one accent is the logo's gold #B79D66.
 * Gold is a FILL with black text (8:1) in both modes; on graphite it may also be text, in a lighter tint (--ps-accent-line).
 *
 * Theme choice: <html data-theme="light|dark"> set by js/pss-theme.js from the person's manual switch (localStorage).
 * No switch made yet: the system setting decides (prefers-color-scheme).
 * Rules for tokens: body.ps-app only (the themes package and Bootstrap read the --bg, --text ... aliases defined at the end).
 */

/* ---------------------------------------------------------------- shared: type, space, shape, motion */
body.ps-app {
    --ps-sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ps-serif: "Literata", "Iowan Old Style", Georgia, serif;   /* reading text only: clauses, quotes, document sheets */
    /* fluid type scale, 16 px at the least for body text */
    --ps-fs-xs: .8125rem;
    --ps-fs-s: .875rem;
    --ps-fs-m: 1rem;
    --ps-fs-l: clamp(1.0625rem, 1.02rem + .2vw, 1.1875rem);
    --ps-fs-xl: clamp(1.25rem, 1.12rem + .6vw, 1.5rem);
    --ps-fs-2xl: clamp(1.5rem, 1.25rem + 1.1vw, 2rem);
    --ps-fs-3xl: clamp(2rem, 1.5rem + 2.2vw, 2.75rem);
    /* space, a 4 px scale: 4 8 12 16 24 32 48 64 */
    --ps-sp-1: .25rem; --ps-sp-2: .5rem; --ps-sp-3: .75rem; --ps-sp-4: 1rem; --ps-sp-5: 1.5rem; --ps-sp-6: 2rem; --ps-sp-7: 3rem; --ps-sp-8: 4rem;
    --ps-gutter: 1rem;
    --ps-section: 2rem;
    --ps-pad: 1rem;
    --ps-target: 2.75rem;                 /* 44 px touch targets */
    /* shape */
    --ps-radius: 10px;
    --ps-radius-panel: 14px;
    --ps-bar: 4px;
    /* motion */
    --ps-ease: cubic-bezier(.2, .6, .2, 1);
    --ps-dur: 180ms;
    --ps-tabbar-h: 3.75rem;
}
@media (min-width: 641px) { body.ps-app { --ps-gutter: 2rem; --ps-section: 2.5rem; --ps-pad: 1.5rem; } }
@media (min-width: 761px) { body.ps-app { --ps-target: 2.5rem; } }

/* ---------------------------------------------------------------- light: smoke */
body.ps-app {
    color-scheme: light;
    --ps-paper: #ecebe8;
    --ps-surface: #f8f7f5;
    --ps-sunk: #e2e0dc;
    --ps-ink: #1b1a18;
    --ps-ink-strong: #0e0d0c;
    --ps-ink-2: #5b5852;
    --ps-line: #d6d3cd;
    --ps-line-2: #8c8880;
    --ps-accent: #b79d66;
    --ps-accent-2: #a88d55;
    --ps-accent-soft: #efe8d8;
    --ps-accent-line: #7e6638;           /* gold as text or a thin line on smoke: 5:1 */
    --ps-on-accent: #000000;
    --ps-link: #1b1a18;
    --ps-focus: #0e0d0c;
    --ps-success: #1f5d4a;
    --ps-sev-critical: #8c1d18;  --ps-sev-high: #b3261e;  --ps-sev-medium: #9a5b00;  --ps-sev-low: #5f6b63;  --ps-sev-info: #8a938e;
    --ps-sev-critical-ink: #7a1712; --ps-sev-critical-soft: #f6dfdb;
    --ps-sev-high-ink: #9c2119;     --ps-sev-high-soft: #f6e3e0;
    --ps-sev-medium-ink: #7a4a00;   --ps-sev-medium-soft: #f5ead2;
    --ps-sev-low-ink: #46504a;      --ps-sev-low-soft: #e6e8e4;
    --ps-sev-info-ink: #5b6360;     --ps-sev-info-soft: #e9ebe8;
    --ps-del: #b3261e; --ps-del-bg: #f6e3e0;
    --ps-ins: #1f5d4a; --ps-ins-bg: #dcebe3;
    --ps-line-high: #e5bfb9; --ps-line-medium: #e3cc9d; --ps-line-clear: #b3d3c3; --ps-line-danger: #e5bfb9;
    --ps-on-sev: #ffffff;
    --ps-btn-dark: #1b1a18; --ps-btn-dark-ink: #f8f7f5;
    --ps-track: #c4c1ba; --ps-knob: #ffffff;
    --ps-overlay-shadow: 0 8px 24px rgba(27, 26, 24, .16);
    --ps-logo-dark: none; --ps-logo-light: block;
    --ps-check-filter: none;
}

/* ---------------------------------------------------------------- dark: graphite */
html[data-theme="dark"] body.ps-app {
    color-scheme: dark;
    --ps-paper: #121211;
    --ps-surface: #1b1b19;
    --ps-sunk: #262624;
    --ps-ink: #eceae5;
    --ps-ink-strong: #ffffff;
    --ps-ink-2: #aaa69d;
    --ps-line: #33322e;
    --ps-line-2: #7d7a71;
    --ps-accent: #b79d66;
    --ps-accent-2: #c9ae76;
    --ps-accent-soft: #2c271b;
    --ps-accent-line: #d6bd88;           /* gold as text on graphite: 9:1 */
    --ps-on-accent: #000000;
    --ps-link: #e4cd9a;
    --ps-focus: #d6bd88;
    --ps-success: #6fc7a3;
    --ps-sev-critical: #f2766c;  --ps-sev-high: #f08a80;  --ps-sev-medium: #e0a24a;  --ps-sev-low: #98a59d;  --ps-sev-info: #8a938e;
    --ps-sev-critical-ink: #ffb9b2; --ps-sev-critical-soft: #3b201d;
    --ps-sev-high-ink: #ffc0b9;     --ps-sev-high-soft: #38211e;
    --ps-sev-medium-ink: #f2c98a;   --ps-sev-medium-soft: #36291a;
    --ps-sev-low-ink: #c4cec8;      --ps-sev-low-soft: #252926;
    --ps-sev-info-ink: #b9c1bd;     --ps-sev-info-soft: #232624;
    --ps-del: #ffb4ab; --ps-del-bg: #3b201d;
    --ps-ins: #9ed8bf; --ps-ins-bg: #17302a;
    --ps-line-high: #5a2f2a; --ps-line-medium: #5a4524; --ps-line-clear: #25503f; --ps-line-danger: #5a2f2a;
    --ps-on-sev: #1a0f0e;
    --ps-btn-dark: #eceae5; --ps-btn-dark-ink: #121211;
    --ps-track: #4a4943; --ps-knob: #eceae5;
    --ps-overlay-shadow: 0 10px 30px rgba(0, 0, 0, .55);
    --ps-logo-dark: block; --ps-logo-light: none;
    --ps-check-filter: invert(1);
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) body.ps-app {
        color-scheme: dark;
        --ps-paper: #121211; --ps-surface: #1b1b19; --ps-sunk: #262624;
        --ps-ink: #eceae5; --ps-ink-strong: #ffffff; --ps-ink-2: #aaa69d;
        --ps-line: #33322e; --ps-line-2: #7d7a71;
        --ps-accent-2: #c9ae76; --ps-accent-soft: #2c271b; --ps-accent-line: #d6bd88;
        --ps-link: #e4cd9a; --ps-focus: #d6bd88; --ps-success: #6fc7a3;
        --ps-sev-critical: #f2766c; --ps-sev-high: #f08a80; --ps-sev-medium: #e0a24a; --ps-sev-low: #98a59d; --ps-sev-info: #8a938e;
        --ps-sev-critical-ink: #ffb9b2; --ps-sev-critical-soft: #3b201d;
        --ps-sev-high-ink: #ffc0b9; --ps-sev-high-soft: #38211e;
        --ps-sev-medium-ink: #f2c98a; --ps-sev-medium-soft: #36291a;
        --ps-sev-low-ink: #c4cec8; --ps-sev-low-soft: #252926;
        --ps-sev-info-ink: #b9c1bd; --ps-sev-info-soft: #232624;
        --ps-del: #ffb4ab; --ps-del-bg: #3b201d; --ps-ins: #9ed8bf; --ps-ins-bg: #17302a;
        --ps-line-high: #5a2f2a; --ps-line-medium: #5a4524; --ps-line-clear: #25503f; --ps-line-danger: #5a2f2a;
        --ps-on-sev: #1a0f0e; --ps-btn-dark: #eceae5; --ps-btn-dark-ink: #121211;
        --ps-track: #4a4943; --ps-knob: #eceae5;
        --ps-overlay-shadow: 0 10px 30px rgba(0, 0, 0, .55);
        --ps-logo-dark: block; --ps-logo-light: none; --ps-check-filter: invert(1);
    }
}

/* aliases the themes package and Bootstrap (sign-in, consent) read; re-pointed here so they follow the mode */
body.ps-app {
    --bg: var(--ps-paper); --surface: var(--ps-surface); --text: var(--ps-ink); --muted: var(--ps-ink-2); --line: var(--ps-line);
    --brand: var(--ps-accent); --brand-ink: var(--ps-on-accent); --link: var(--ps-link); --accent: var(--ps-accent);
    --glass-bg: var(--ps-surface); --glass-line: var(--ps-line);
    --bs-body-bg: var(--ps-paper); --bs-body-color: var(--ps-ink); --bs-secondary-color: var(--ps-ink-2); --bs-border-color: var(--ps-line);
    --bs-link-color: var(--ps-link); --bs-link-hover-color: var(--ps-link); --bs-emphasis-color: var(--ps-ink);
    --bs-card-bg: var(--ps-surface); --bs-tertiary-bg: var(--ps-sunk); --bs-form-control-bg: var(--ps-surface);
}
