/*
 * Design tokens. <html> carries data-theme (dark | light | karneval | weihnachten)
 * and data-accent (green | blue | red | yellow). Theme previews in the settings
 * set both attributes on their own element, so every token is re-derived there.
 */

/* Raw accent values for the dark and the light theme. */
:root, [data-accent="green"] { --accent-d: #43e28b; --on-accent-d: #07160e; --accent-l: #12914b; --on-accent-l: #ffffff; }
[data-accent="blue"] { --accent-d: #5aaeff; --on-accent-d: #04111f; --accent-l: #1d6ae5; --on-accent-l: #ffffff; }
[data-accent="red"] { --accent-d: #ff5f6d; --on-accent-d: #22060a; --accent-l: #d42c3c; --on-accent-l: #ffffff; }
[data-accent="yellow"] { --accent-d: #f6c945; --on-accent-d: #1c1503; --accent-l: #d99a00; --on-accent-l: #1a1200; }

:root, [data-theme="dark"] {
  color-scheme: dark;
  --accent: var(--accent-d);
  --on-accent: var(--on-accent-d);
  --accent-deep: color-mix(in oklab, var(--accent) 36%, #050807);
  --accent-text-mix: 42%;
  --accent-ink-mix: 100%;
  --bg: color-mix(in oklab, var(--accent) 3%, #0d110f);
  --bg-glow: color-mix(in oklab, var(--accent) 10%, #101512);
  --panel: color-mix(in oklab, var(--accent) 2%, #0a0d0b);
  --surface: color-mix(in oklab, var(--accent) 4%, #131815);
  --surface-2: color-mix(in oklab, var(--accent) 4%, #161b18);
  --surface-high: color-mix(in oklab, var(--accent) 4%, #1e2320);
  --control: color-mix(in oklab, var(--accent) 5%, #1f2521);
  --control-hover: color-mix(in oklab, var(--accent) 6%, #29302c);
  --line: color-mix(in oklab, var(--accent) 5%, #282e2a);
  --line-strong: color-mix(in oklab, var(--accent) 7%, #353c38);
  --modal-bg: color-mix(in oklab, var(--accent) 4%, #141916);
  --text: #e7ece9;
  --text-strong: #f5f8f6;
  --text-2: #c6cfc9;
  --muted: #9ba59f;
  --faint: #7a847e;
  --fainter: #5c6560;
  --hover-tint: rgba(255, 255, 255, .1);
  --overlay: rgba(3, 7, 5, .72);
  --shadow: 0 24px 60px rgba(0, 0, 0, .22);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, .6);
  --warn: #f0d68a;
  --warn-2: #e0c779;
  --warn-solid: #55481f;
  --warn-line: #5a4c26;
  --warn-bg: rgba(85, 72, 31, .2);
  --danger: #ff7777;
  --danger-text: #ffaaaa;
  --danger-muted: #d4b3b3;
  --needle: #ff535b;
  --on-needle: #18090a;
  --info: #9cc3ff;
  --info-bg: #1b2a3d;
}

[data-theme="light"] {
  color-scheme: light;
  --accent: var(--accent-l);
  --on-accent: var(--on-accent-l);
  --accent-deep: color-mix(in oklab, var(--accent) 82%, #000);
  --accent-text-mix: 80%;
  --accent-ink-mix: 74%;
  --bg: color-mix(in oklab, var(--accent) 3%, #f2f4f3);
  --bg-glow: color-mix(in oklab, var(--accent) 12%, #f2f4f3);
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-high: color-mix(in oklab, var(--accent) 4%, #f0f2f1);
  --control: color-mix(in oklab, var(--accent) 4%, #e9edeb);
  --control-hover: color-mix(in oklab, var(--accent) 7%, #dfe4e1);
  --line: color-mix(in oklab, var(--accent) 5%, #e0e5e2);
  --line-strong: color-mix(in oklab, var(--accent) 7%, #c8d0cb);
  --modal-bg: #ffffff;
  --text: #1a221d;
  --text-strong: #0b110d;
  --text-2: #3a443e;
  --muted: #5e6963;
  --faint: #848e88;
  --fainter: #a8b0ab;
  --hover-tint: rgba(0, 0, 0, .06);
  --overlay: rgba(24, 34, 28, .32);
  --shadow: 0 18px 50px rgba(20, 40, 30, .09);
  --shadow-strong: 0 30px 80px rgba(20, 40, 30, .22);
  --warn: #8a6100;
  --warn-2: #8a6a10;
  --warn-solid: #f6e2a2;
  --warn-line: #e6cf85;
  --warn-bg: rgba(240, 190, 60, .14);
  --danger: #d43b3b;
  --danger-text: #c0392b;
  --danger-muted: #9b6b6b;
  --needle: #e5383f;
  --on-needle: #ffffff;
  --info: #2f6fd0;
  --info-bg: #e3edfb;
}

/* Karneval (11.11.): red and white. */
[data-theme="karneval"] {
  color-scheme: dark;
  --accent: #ff4d5a;
  --on-accent: #ffffff;
  --accent-deep: #a3161f;
  --accent-text-mix: 40%;
  --accent-ink-mix: 100%;
  --bg: #140d0e;
  --bg-glow: #3a1418;
  --panel: #110a0b;
  --surface: #1c1415;
  --surface-2: #1f1617;
  --surface-high: #2a1e20;
  --control: #2a1e20;
  --control-hover: #3a2a2c;
  --line: #3a2a2c;
  --line-strong: #4a3436;
  --modal-bg: #1c1314;
  --text: #f3eaea;
  --text-strong: #fff7f7;
  --text-2: #dcc8ca;
  --muted: #b3a0a2;
  --faint: #9a8486;
  --fainter: #6e5c5e;
  --hover-tint: rgba(255, 255, 255, .1);
  --overlay: rgba(10, 3, 4, .74);
  --shadow: 0 24px 60px rgba(0, 0, 0, .25);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, .6);
  --warn: #ffd27a; --warn-2: #f0c060; --warn-solid: #5a4220; --warn-line: #6a4c24; --warn-bg: rgba(90, 66, 32, .22);
  --danger: #ff8a8a; --danger-text: #ffb3b3; --danger-muted: #d4b3b3;
  --needle: #ff4d5a; --on-needle: #ffffff;
  --info: #9cc3ff; --info-bg: #1f2638;
  --karneval-red: #e8333f;
}

/* Weihnachten (1.–26.12.): pine green, warm gold and Christmas red. */
[data-theme="weihnachten"] {
  color-scheme: dark;
  --accent: #f2c45a;
  --on-accent: #1d1503;
  --accent-deep: #9b2431;
  --accent-text-mix: 45%;
  --accent-ink-mix: 100%;
  --bg: #0b1512;
  --bg-glow: #1b3a2b;
  --panel: #08100d;
  --surface: #101c17;
  --surface-2: #13211b;
  --surface-high: #1a2a23;
  --control: #1a2a23;
  --control-hover: #24382e;
  --line: #23362d;
  --line-strong: #30483c;
  --modal-bg: #0f1b16;
  --text: #eef3ef;
  --text-strong: #fbfdfb;
  --text-2: #cbd8d0;
  --muted: #a1b3a9;
  --faint: #7d9186;
  --fainter: #587064;
  --hover-tint: rgba(255, 255, 255, .1);
  --overlay: rgba(3, 9, 6, .74);
  --shadow: 0 24px 60px rgba(0, 0, 0, .25);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, .6);
  --warn: #f6d98e; --warn-2: #e6c472; --warn-solid: #574820; --warn-line: #5f4f26; --warn-bg: rgba(87, 72, 32, .22);
  --danger: #ff8080; --danger-text: #ffb0b0; --danger-muted: #d8b8b8;
  --needle: #ff5a5f; --on-needle: #ffffff;
  --info: #a6c8ff; --info-bg: #1a2a3c;
  --xmas-red: #d93a48;
  --xmas-green: #2f9e5c;
}

/* Tokens derived from the ones above; re-declared wherever a theme is set. */
:root, [data-theme] {
  --accent-hover: color-mix(in oklab, var(--accent) 84%, var(--text-strong));
  --accent-press: color-mix(in oklab, var(--accent) 62%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 30%, var(--panel));
  --accent-surface: color-mix(in oklab, var(--accent) 13%, var(--surface));
  --accent-text: color-mix(in oklab, var(--accent) var(--accent-text-mix), var(--text-strong));
  --focus-ring: color-mix(in srgb, var(--accent) 55%, transparent);
  --accent-ink: color-mix(in oklab, var(--accent) var(--accent-ink-mix), #000);
  /* Legacy names used by older stylesheets. */
  --green: var(--accent);
  --green-dark: var(--accent-deep);
}

/* Theme switches cross-fade when the View Transitions API is missing. */
.theme-fading, .theme-fading *, .theme-fading *::before, .theme-fading *::after {
  transition: background-color 320ms ease, color 320ms ease, border-color 320ms ease, fill 320ms ease, box-shadow 320ms ease !important;
}
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal 560ms cubic-bezier(.3, .7, .2, 1) both; }
@keyframes theme-reveal { from { clip-path: circle(0 at var(--reveal-x, 50%) var(--reveal-y, 0%)); } to { clip-path: circle(var(--reveal-r, 150vmax) at var(--reveal-x, 50%) var(--reveal-y, 0%)); } }

/* "Keine Übergänge und Animationen" switches every animation off. */
[data-motion="off"] *, [data-motion="off"] *::before, [data-motion="off"] *::after,
[data-motion="off"]::view-transition-group(*), [data-motion="off"]::view-transition-new(*), [data-motion="off"]::view-transition-old(*) {
  scroll-behavior: auto !important;
  transition: none !important;
  animation: none !important;
}
