/* Мишины Игрушки — цвета и темы сайта и Mini App.
   Единственное место, где живут цвета. Слой 1 — палитра (--p-*),
   слой 2 — смысловые токены (--surface, --text, --accent …): их читают компоненты.
   Светлая тема — пастель сайта, тёмная — «Ночная мастерская».
   Семейные цвета магазина (лаванда, мята, персик) — в css/tokens-brand.css рядом.
   Выбор: явный data-theme побеждает; без него работает системная тема.
   ВАЖНО: два тёмных блока (media и [data-theme="dark"]) обязаны совпадать
   объявление в объявление — это проверяет apps/tma/test_theme_tokens.py. */

/* Палитра без темы: эти цвета одинаковы в светлой и тёмной */
:root {
    --p-white: 255 255 255;
    --p-mask: #000000;
    --p-violet-soft-rgb: 167 139 250;
    --p-accent-flare-rgb: 255 220 140;
    --p-ok-deep-solid: #059669;
    --p-confetti-1: #818cf8;
    --p-confetti-2: #a78bfa;
    --p-confetti-3: #fbbf24;
}

/* ---------- Слой 2: смысловые токены (общие для обеих тем) ---------- */
:root {
    --bg: var(--p-bg);
    --bg-deep: var(--p-bg-deep);
    --surface: var(--p-surface);
    --surface-solid: var(--p-surface-solid);
    --surface-high: var(--p-surface-high);
    --surface-high-a60: var(--p-surface-high-a60);
    --glass-to: var(--p-glass-to);
    --toast: var(--p-toast);
    --nav: var(--p-nav);

    --well-a55: rgb(var(--p-well-rgb) / .55);
    --well-a60: rgb(var(--p-well-rgb) / .6);
    --well-a70: rgb(var(--p-well-rgb) / .7);
    --well-a85: rgb(var(--p-well-rgb) / .85);
    --overlay-a35: rgb(var(--p-overlay-rgb) / .35);
    --overlay-a45: rgb(var(--p-overlay-rgb) / .45);
    --overlay-a60: rgb(var(--p-overlay-rgb) / .6);
    --overlay-a75: rgb(var(--p-overlay-rgb) / .75);
    --scrim: var(--p-scrim);
    --hairline: rgb(var(--p-hairline-rgb) / .25);
    --soft-line: rgb(var(--p-hairline-rgb) / .2);

    --line: rgb(var(--p-line-rgb) / .16);
    --line-strong: rgb(var(--p-line-rgb) / .28);
    --line-a035: rgb(var(--p-line-rgb) / .035);
    --line-a06: rgb(var(--p-line-rgb) / .06);
    --line-a10: rgb(var(--p-line-rgb) / .1);
    --line-a12: rgb(var(--p-line-rgb) / .12);
    --line-a14: rgb(var(--p-line-rgb) / .14);
    --line-a20: rgb(var(--p-line-rgb) / .2);
    --line-a22: rgb(var(--p-line-rgb) / .22);

    --text: var(--p-text);
    --muted: var(--p-muted);
    --text-soft: var(--p-text-soft);
    --text-soft-2: var(--p-text-soft-2);
    --brand-ink: var(--p-brand-ink);
    --brand-on: var(--p-brand-on);
    --icon-on-brand: var(--p-icon-on-brand);
    --placeholder: var(--p-placeholder);
    --placeholder-field: var(--p-placeholder-field);

    --accent: var(--p-accent);
    --accent-hot: var(--p-accent-hot);
    --accent-ink: var(--p-accent-ink);
    --accent-light: var(--p-accent-light);
    --accent-deep: var(--p-accent-deep);
    --accent-glow: rgb(var(--p-accent-rgb) / .45);
    /* Альфа-варианты акцента — по два в строке, чтобы файл оставался компактным */
    --accent-a06: rgb(var(--p-accent-rgb) / .06); --accent-a08: rgb(var(--p-accent-rgb) / .08);
    --accent-a10: rgb(var(--p-accent-rgb) / .1); --accent-a12: rgb(var(--p-accent-rgb) / .12);
    --accent-a14: rgb(var(--p-accent-rgb) / .14); --accent-a15: rgb(var(--p-accent-rgb) / .15);
    --accent-a18: rgb(var(--p-accent-rgb) / .18); --accent-a25: rgb(var(--p-accent-rgb) / .25);
    --accent-a28: rgb(var(--p-accent-rgb) / .28); --accent-a30: rgb(var(--p-accent-rgb) / .3);
    --accent-a35: rgb(var(--p-accent-rgb) / .35); --accent-a38: rgb(var(--p-accent-rgb) / .38);
    --accent-a40: rgb(var(--p-accent-rgb) / .4); --accent-a50: rgb(var(--p-accent-rgb) / .5);
    --accent-a55: rgb(var(--p-accent-rgb) / .55); --accent-a60: rgb(var(--p-accent-rgb) / .6);
    --accent-a70: rgb(var(--p-accent-rgb) / .7); --accent-a75: rgb(var(--p-accent-rgb) / .75);
    --accent-a80: rgb(var(--p-accent-rgb) / .8);

    --brand-1: rgb(var(--p-brand-1-rgb));
    --brand-2: rgb(var(--p-brand-2-rgb));
    --brand-a10: rgb(var(--p-brand-1-rgb) / .1); --brand-a30: rgb(var(--p-brand-1-rgb) / .3);
    --brand-a35: rgb(var(--p-brand-1-rgb) / .35); --brand-a40: rgb(var(--p-brand-1-rgb) / .4);
    --brand-a55: rgb(var(--p-brand-1-rgb) / .55);
    --brand-2-a18: rgb(var(--p-brand-2-rgb) / .18); --brand-2-a45: rgb(var(--p-brand-2-rgb) / .45);
    --violet-a35: rgb(var(--p-violet-soft-rgb) / .35);

    --ok: rgb(var(--p-ok-rgb));
    --ok-text: var(--p-ok-text);
    --ok-text-strong: var(--p-ok-text-strong);
    --ok-deep: var(--p-ok-deep);
    --ok-deep-solid: var(--p-ok-deep-solid);
    --ok-a12: rgb(var(--p-ok-rgb) / .12); --ok-a14: rgb(var(--p-ok-rgb) / .14);
    --ok-a16: rgb(var(--p-ok-rgb) / .16); --ok-a18: rgb(var(--p-ok-rgb) / .18);
    --ok-a20: rgb(var(--p-ok-rgb) / .2); --ok-a35: rgb(var(--p-ok-rgb) / .35);
    --ok-a40: rgb(var(--p-ok-rgb) / .4); --ok-a45: rgb(var(--p-ok-rgb) / .45);
    --ok-a50: rgb(var(--p-ok-rgb) / .5); --ok-a70: rgb(var(--p-ok-rgb) / .7);

    --danger: rgb(var(--p-danger-rgb));
    --danger-text: var(--p-danger-text);
    --danger-text-soft: var(--p-danger-text-soft);
    --danger-a12: rgb(var(--p-danger-rgb) / .12); --danger-a15: rgb(var(--p-danger-rgb) / .15);
    --danger-a45: rgb(var(--p-danger-rgb) / .45); --danger-a60: rgb(var(--p-danger-rgb) / .6);

    --metal: var(--p-metal);
    --metal-light: var(--p-metal-light);
    --bubble-from: var(--p-bubble-from);
    --bubble-to: var(--p-bubble-to);
    --sheet-top: var(--p-sheet-top);

    --white: rgb(var(--p-white));
    --white-a06: rgb(var(--p-white) / .06); --white-a20: rgb(var(--p-white) / .2);
    --white-a35: rgb(var(--p-white) / .35); --white-a40: rgb(var(--p-white) / .4);
    --black-a25: rgb(var(--p-black-rgb) / .25); --black-a30: rgb(var(--p-black-rgb) / .3);
    --mask: var(--p-mask);

    --accent-flare: rgb(var(--p-accent-flare-rgb) / .95);
    --accent-flare-2: var(--p-accent-flare-2);
    --confetti-1: var(--p-confetti-1);
    --confetti-2: var(--p-confetti-2);
    --confetti-3: var(--p-confetti-3);

    --shadow-a35: rgb(var(--p-shadow-rgb) / .35);
    --shadow-a50: rgb(var(--p-shadow-rgb) / .5);
    --shadow-a55: rgb(var(--p-shadow-rgb) / .55);
    --shadow-a60: rgb(var(--p-shadow-rgb) / .6);
    --shadow-glow: 0 0 22px var(--accent-glow);
}

/* ---------- Светлая палитра: базовая и явный выбор ----------
   Значения одни и те же, поэтому селекторы объединены в один блок:
   так светлая палитра не дублируется. Явный data-theme="light" здесь имеет
   большую специфичность, чем media-запрос тёмной темы ниже. */
:root,
:root[data-theme="light"] {
    color-scheme: light;

    --p-bg: #faf7ff;
    --p-bg-deep: #f3eeff;
    --p-surface: rgba(255, 255, 255, .82);
    --p-surface-solid: #ffffff;
    --p-surface-high: rgba(255, 255, 255, .92);
    --p-surface-high-a60: rgba(255, 255, 255, .94);
    --p-glass-to: rgba(255, 255, 255, .97);
    --p-toast: rgba(255, 255, 255, .98);
    --p-nav: rgba(255, 255, 255, .9);
    --p-well-rgb: 255 255 255;
    --p-overlay-rgb: 236 231 248;
    --p-hairline-rgb: 46 42 71;
    --p-scrim: rgba(46, 42, 71, .28);
    --p-line-rgb: 124 92 240;
    --p-text: #2e2a47;
    --p-muted: #5b5675;
    --p-text-soft: #45405f;
    --p-text-soft-2: #4a4566;
    --p-brand-ink: #2e2a47;
    --p-brand-on: #ffffff;
    --p-icon-on-brand: #2e2a47;
    --p-placeholder: #6b6684;
    --p-placeholder-field: #6b6684;
    --p-accent: #6d4fe0;
    --p-accent-rgb: 109 79 224;
    --p-accent-hot: #5b3fd1;
    --p-accent-ink: #ffffff;
    --p-accent-light: #8a6df0;
    --p-accent-deep: #5b3fd1;
    --p-accent-flare-2: #b9a6ff;
    --p-brand-1-rgb: 106 72 224;
    --p-brand-2-rgb: 91 63 209;
    --p-ok-rgb: 11 122 91;
    --p-ok-text: #0b7a5b;
    --p-ok-text-strong: #065f46;
    --p-ok-deep: rgba(227, 250, 240, .95);
    --p-danger-rgb: 220 38 38;
    --p-danger-text: #b91c1c;
    --p-danger-text-soft: #991b1b;
    --p-metal: #6b6488;
    --p-metal-light: #9a93b8;
    --p-bubble-from: #ffffff;
    --p-bubble-to: #f3eeff;
    --p-sheet-top: #ffffff;
    --p-shadow-rgb: 174 166 210;
    --p-black-rgb: 46 42 71;
}

/* ---------- Тёмная палитра: системная настройка ----------
   Работает, только если человек не выбрал светлую. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --p-bg: #0d1326;
        --p-bg-deep: #090e1d;
        --p-surface: rgba(30, 40, 78, .55);
        --p-surface-solid: #131b35;
        --p-surface-high: rgba(48, 60, 112, .55);
        --p-surface-high-a60: rgba(48, 60, 112, .6);
        --p-glass-to: rgba(19, 27, 53, .75);
        --p-toast: rgba(19, 27, 53, .95);
        --p-nav: rgba(22, 30, 60, .82);
        --p-well-rgb: 9 14 29;
        --p-overlay-rgb: 13 19 38;
        --p-hairline-rgb: 255 255 255;
        --p-scrim: rgba(5, 8, 20, .62);
        --p-line-rgb: 148 163 255;
        --p-text: #eef1ff;
        --p-muted: #9aa3c7;
        --p-text-soft: #d6d9f5;
        --p-text-soft-2: #c9cff0;
        --p-brand-ink: #d6d9f5;
        --p-brand-on: #eef1ff;
        --p-icon-on-brand: #ffc24d;
        --p-placeholder: #6f78a0;
        --p-placeholder-field: #5f6894;
        --p-accent: #f59e0b;
        --p-accent-rgb: 245 158 11;
        --p-accent-hot: #ffc24d;
        --p-accent-ink: #1a1205;
        --p-accent-light: #ffe09a;
        --p-accent-deep: #d97706;
        --p-accent-flare-2: #fff3c4;
        --p-brand-1-rgb: 79 70 229;
        --p-brand-2-rgb: 124 58 237;
        --p-ok-rgb: 16 185 129;
        --p-ok-text: #6ee7b7;
        --p-ok-text-strong: #a7f3d0;
        --p-ok-deep: rgba(6, 78, 59, .85);
        --p-danger-rgb: 239 68 68;
        --p-danger-text: #fca5a5;
        --p-danger-text-soft: #fecaca;
        --p-metal: #3b4675;
        --p-metal-light: #7a86b8;
        --p-bubble-from: #2a3466;
        --p-bubble-to: #1a2246;
        --p-sheet-top: #1a2348;
        --p-shadow-rgb: 3 6 20;
        --p-black-rgb: 0 0 0;
    }
}

/* ---------- Тёмная палитра: явный выбор ----------
   ДОЛЖНА совпадать с блоком выше объявление в объявление. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --p-bg: #0d1326;
    --p-bg-deep: #090e1d;
    --p-surface: rgba(30, 40, 78, .55);
    --p-surface-solid: #131b35;
    --p-surface-high: rgba(48, 60, 112, .55);
    --p-surface-high-a60: rgba(48, 60, 112, .6);
    --p-glass-to: rgba(19, 27, 53, .75);
    --p-toast: rgba(19, 27, 53, .95);
    --p-nav: rgba(22, 30, 60, .82);
    --p-well-rgb: 9 14 29;
    --p-overlay-rgb: 13 19 38;
    --p-hairline-rgb: 255 255 255;
    --p-scrim: rgba(5, 8, 20, .62);
    --p-line-rgb: 148 163 255;
    --p-text: #eef1ff;
    --p-muted: #9aa3c7;
    --p-text-soft: #d6d9f5;
    --p-text-soft-2: #c9cff0;
    --p-brand-ink: #d6d9f5;
    --p-brand-on: #eef1ff;
    --p-icon-on-brand: #ffc24d;
    --p-placeholder: #6f78a0;
    --p-placeholder-field: #5f6894;
    --p-accent: #f59e0b;
    --p-accent-rgb: 245 158 11;
    --p-accent-hot: #ffc24d;
    --p-accent-ink: #1a1205;
    --p-accent-light: #ffe09a;
    --p-accent-deep: #d97706;
    --p-accent-flare-2: #fff3c4;
    --p-brand-1-rgb: 79 70 229;
    --p-brand-2-rgb: 124 58 237;
    --p-ok-rgb: 16 185 129;
    --p-ok-text: #6ee7b7;
    --p-ok-text-strong: #a7f3d0;
    --p-ok-deep: rgba(6, 78, 59, .85);
    --p-danger-rgb: 239 68 68;
    --p-danger-text: #fca5a5;
    --p-danger-text-soft: #fecaca;
    --p-metal: #3b4675;
    --p-metal-light: #7a86b8;
    --p-bubble-from: #2a3466;
    --p-bubble-to: #1a2246;
    --p-sheet-top: #1a2348;
    --p-shadow-rgb: 3 6 20;
    --p-black-rgb: 0 0 0;
}
