/*
 * Dark theme for the Dreamscape public page and the admin panel.
 *
 * It only overrides the Organic design-system tokens (_ds/**, vendored, never edited), so every
 * component that uses a token follows automatically. Selection contract:
 *   :root[data-theme="dark"]   forces dark
 *   :root[data-theme="light"]  forces light (no rule here: the design-system tokens apply)
 *   no data-theme attribute    follows the OS via prefers-color-scheme
 * Both blocks are wrapped in `@media screen`, so printing (invoices, guides) is always light.
 * The two token blocks must stay identical; server/scripts/check-contrast.mjs checks that and
 * the WCAG contrast of every text/background pair (run it after any colour change).
 *
 * The ramps are inverted: step 100 is the darkest tint and 900 the lightest, so the design
 * system's pairings (800 text on 100 fill, 700 text/links, 900 headings) keep their meaning.
 */
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: #1a1612;
    --color-surface: #261f19;
    --color-text: #f3e8d6;
    --color-accent: #e8935c;
    --color-accent-2: #a3b57f;
    --color-divider: color-mix(in srgb, #f3e8d6 22%, transparent);
    --color-control-border: #8a7d6c;
    --color-on-accent: #1a1612;

    --color-neutral-100: #2d251e;
    --color-neutral-200: #3a3027;
    --color-neutral-300: #4c4034;
    --color-neutral-400: #6b5d4e;
    --color-neutral-500: #8a7c6a;
    --color-neutral-600: #a89a87;
    --color-neutral-700: #c3b7a5;
    --color-neutral-800: #ddd2c0;
    --color-neutral-900: #efe5d3;

    --color-accent-100: #37231a;
    --color-accent-200: #4a2e1e;
    --color-accent-300: #6a4024;
    --color-accent-400: #94572f;
    --color-accent-500: #cf8049;
    --color-accent-600: #f0a577;
    --color-accent-700: #f5b890;
    --color-accent-800: #fad0b2;
    --color-accent-900: #fde6d4;

    --color-accent-2-100: #262d1b;
    --color-accent-2-200: #313a23;
    --color-accent-2-300: #46523a;
    --color-accent-2-400: #5f6e4b;
    --color-accent-2-500: #7f9163;
    --color-accent-2-600: #9aad7c;
    --color-accent-2-700: #b3c496;
    --color-accent-2-800: #cbd9b2;
    --color-accent-2-900: #e2edcf;

    --shadow-sm: 0 0 0 1px color-mix(in srgb, #f3e8d6 8%, transparent);
    --shadow-md: 0 0 0 1px color-mix(in srgb, #f3e8d6 10%, transparent), 0 4px 14px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 0 0 1px color-mix(in srgb, #f3e8d6 12%, transparent), 0 12px 32px rgb(0 0 0 / 0.5);

    /* Public logo: black-on-white JPG. Invert it and screen it onto the page instead of multiply. */
    --logo-blend: screen;
    --logo-filter: invert(1) sepia(0.25);
  }
  :root[data-theme="dark"] .input,
  :root[data-theme="dark"] .radio .dot { border-color: var(--color-control-border); }
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #1a1612;
    --color-surface: #261f19;
    --color-text: #f3e8d6;
    --color-accent: #e8935c;
    --color-accent-2: #a3b57f;
    --color-divider: color-mix(in srgb, #f3e8d6 22%, transparent);
    --color-control-border: #8a7d6c;
    --color-on-accent: #1a1612;

    --color-neutral-100: #2d251e;
    --color-neutral-200: #3a3027;
    --color-neutral-300: #4c4034;
    --color-neutral-400: #6b5d4e;
    --color-neutral-500: #8a7c6a;
    --color-neutral-600: #a89a87;
    --color-neutral-700: #c3b7a5;
    --color-neutral-800: #ddd2c0;
    --color-neutral-900: #efe5d3;

    --color-accent-100: #37231a;
    --color-accent-200: #4a2e1e;
    --color-accent-300: #6a4024;
    --color-accent-400: #94572f;
    --color-accent-500: #cf8049;
    --color-accent-600: #f0a577;
    --color-accent-700: #f5b890;
    --color-accent-800: #fad0b2;
    --color-accent-900: #fde6d4;

    --color-accent-2-100: #262d1b;
    --color-accent-2-200: #313a23;
    --color-accent-2-300: #46523a;
    --color-accent-2-400: #5f6e4b;
    --color-accent-2-500: #7f9163;
    --color-accent-2-600: #9aad7c;
    --color-accent-2-700: #b3c496;
    --color-accent-2-800: #cbd9b2;
    --color-accent-2-900: #e2edcf;

    --shadow-sm: 0 0 0 1px color-mix(in srgb, #f3e8d6 8%, transparent);
    --shadow-md: 0 0 0 1px color-mix(in srgb, #f3e8d6 10%, transparent), 0 4px 14px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 0 0 1px color-mix(in srgb, #f3e8d6 12%, transparent), 0 12px 32px rgb(0 0 0 / 0.5);

    --logo-blend: screen;
    --logo-filter: invert(1) sepia(0.25);
  }
  :root:not([data-theme="light"]) .input,
  :root:not([data-theme="light"]) .radio .dot { border-color: var(--color-control-border); }
}
