/* Темы портала KEAT FAMQ (см. DESIGN.md).
   Каждая тема задаёт один и тот же набор токенов; контраст пар: текст ≥ 4.5:1,
   рамки полей ≥ 3:1. По умолчанию — Monochrome (чёрный, серый, белый). */

:root,
:root[data-theme="mono"] {
    --bg: #0a0a0a;
    --bg-rgb: 10, 10, 10;
    --surface: #141414;
    --surface-2: #1f1f1f;
    --line: #333333;
    --field-line: #7a7a7a;
    --text: #f2f2f2;
    --text-2: #cccccc;
    --muted: #9e9e9e;
    --accent: #ffffff;
    --accent-rgb: 255, 255, 255;
    --accent-text: #ffffff;
    --accent-fill: linear-gradient(135deg, #ffffff, #bdbdbd);
    --on-accent: #0a0a0a;
    --signal: #c8c8c8;
    --signal-rgb: 200, 200, 200;
    --danger: #ff6b78;
    --warning: #ffa502;
    --horizon: linear-gradient(90deg, transparent, rgba(255, 255, 255, .4) 22%, rgba(255, 255, 255, .4) 78%, transparent);
}

:root[data-theme="ocean"] {
    --bg: #0a0e1a;
    --bg-rgb: 10, 14, 26;
    --surface: #10152a;
    --surface-2: #1a1f3a;
    --line: #2d3548;
    --field-line: #6b7590;
    --text: #e8e6e3;
    --text-2: #c9d1d9;
    --muted: #9aa1b0;
    --accent: #d4af37;
    --accent-rgb: 212, 175, 55;
    --accent-text: #d4af37;
    --accent-fill: linear-gradient(135deg, #d4af37, #f4d03f);
    --on-accent: #0a0e1a;
    --signal: #00d4ff;
    --signal-rgb: 0, 212, 255;
    --danger: #ff6b78;
    --warning: #ffa502;
    --horizon: linear-gradient(90deg, transparent, rgba(212, 175, 55, .55) 22%, rgba(212, 175, 55, .55) 78%, transparent);
}

:root[data-theme="crimson"] {
    --bg: #1a0a0a;
    --bg-rgb: 26, 10, 10;
    --surface: #221010;
    --surface-2: #2d1515;
    --line: #4a2626;
    --field-line: #8a6262;
    --text: #f0e6e6;
    --text-2: #d4c0c0;
    --muted: #b8a0a0;
    --accent: #e04848;
    --accent-rgb: 224, 72, 72;
    --accent-text: #ff6b6b;
    --accent-fill: linear-gradient(135deg, #e04848, #ff6b6b);
    --on-accent: #1a0a0a;
    --signal: #ff9f9f;
    --signal-rgb: 255, 159, 159;
    --danger: #ff6b78;
    --warning: #ffa502;
    --horizon: linear-gradient(90deg, transparent, rgba(224, 72, 72, .6) 22%, rgba(224, 72, 72, .6) 78%, transparent);
}

:root[data-theme="emerald"] {
    --bg: #0a1a0f;
    --bg-rgb: 10, 26, 15;
    --surface: #102215;
    --surface-2: #152d1a;
    --line: #1f4a2b;
    --field-line: #5c8a68;
    --text: #e6f0e8;
    --text-2: #c0d4c5;
    --muted: #93ad9a;
    --accent: #32dc64;
    --accent-rgb: 50, 220, 100;
    --accent-text: #32dc64;
    --accent-fill: linear-gradient(135deg, #32dc64, #6bff9e);
    --on-accent: #0a1a0f;
    --signal: #6bff9e;
    --signal-rgb: 107, 255, 158;
    --danger: #ff6b78;
    --warning: #ffa502;
    --horizon: linear-gradient(90deg, transparent, rgba(50, 220, 100, .5) 22%, rgba(50, 220, 100, .5) 78%, transparent);
}

:root[data-theme="void"] {
    --bg: #0f0a1a;
    --bg-rgb: 15, 10, 26;
    --surface: #171023;
    --surface-2: #1f152d;
    --line: #3a2452;
    --field-line: #7d64a0;
    --text: #ece6f0;
    --text-2: #d0c0d4;
    --muted: #a898b8;
    --accent: #9632dc;
    --accent-rgb: 150, 50, 220;
    --accent-text: #c06bff;
    --accent-fill: linear-gradient(135deg, #c06bff, #d49bff);
    --on-accent: #0f0a1a;
    --signal: #c06bff;
    --signal-rgb: 192, 107, 255;
    --danger: #ff6b78;
    --warning: #ffa502;
    --horizon: linear-gradient(90deg, transparent, rgba(192, 107, 255, .55) 22%, rgba(192, 107, 255, .55) 78%, transparent);
}

/* ---------- Переключатель тем (в шапке) ---------- */

.theme-switcher { position: relative; }
.theme-toggle {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font: 600 13px var(--body);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.theme-toggle:hover, .theme-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }
.theme-toggle .theme-swatch { width: 14px; height: 14px; border-width: 1px; }
.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    min-width: 230px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
}
.theme-dropdown[hidden] { display: none; }
.theme-header { padding: 6px 10px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.theme-option {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: 500 14px var(--body);
    text-align: left;
    cursor: pointer;
}
.theme-option:hover { background: var(--surface-2); }
.theme-option[aria-checked="true"] { border-color: var(--accent); }
.theme-option[aria-checked="true"]::after { margin-left: auto; color: var(--accent-text); content: '✓'; }
.theme-swatch { width: 20px; height: 20px; flex: 0 0 auto; border: 2px solid rgba(255, 255, 255, .25); border-radius: 50%; }

@media (max-width: 760px) {
    .theme-toggle .theme-label { display: none; }
    .theme-dropdown { position: fixed; top: 64px; right: 16px; left: 16px; }
}

/* Тона для законов (и других разделов, где нужно различать категории): шесть цветов под каждую
   тему. В моно — приглушённая пастель, чтобы не спорить с ч/б; в цветных темах тона сдвинуты
   к палитре темы (золото и бирюза в Ocean, тёплые в Crimson, зелень в Emerald, фиолет в Void). */
:root, :root[data-theme="mono"] {
    --tone-red: #f28b82; --tone-amber: #e6c07b; --tone-blue: #8ab4f8;
    --tone-violet: #c3a6ff; --tone-teal: #7fd6c8; --tone-green: #a6d9a0; --tone-pink: #f0a6c8;
}
:root[data-theme="ocean"] {
    --tone-red: #ff7a85; --tone-amber: #f4d03f; --tone-blue: #00d4ff;
    --tone-violet: #a29bff; --tone-teal: #3fe0c5; --tone-green: #7be0a0; --tone-pink: #ff9ecb;
}
:root[data-theme="crimson"] {
    --tone-red: #ff6b6b; --tone-amber: #ffb35c; --tone-blue: #93b4ff;
    --tone-violet: #e08cff; --tone-teal: #6fd6c0; --tone-green: #b5d97a; --tone-pink: #ff9fb8;
}
:root[data-theme="emerald"] {
    --tone-red: #ff8080; --tone-amber: #f2d45c; --tone-blue: #5ccfff;
    --tone-violet: #b99bff; --tone-teal: #32dcb4; --tone-green: #6bff9e; --tone-pink: #ff9ed2;
}
:root[data-theme="void"] {
    --tone-red: #ff6b9a; --tone-amber: #ffc56b; --tone-blue: #7aa8ff;
    --tone-violet: #c06bff; --tone-teal: #5ee0d0; --tone-green: #8be08b; --tone-pink: #ff8ee6;
}
