/* --- common.css --- */
/* --- Общие Стили --- */
:root {
    --global-font-size: 16px;
    --global-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --app-height: 100vh;
    
    /* --- Светлая тема (Дефолтная) --- */
    --bg-grad-start: #f1f5f9;
    --bg-grad-end: #cbd5e1;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --text-color: #0f172a;
    --bg-color: #ffffff;
    --paper-color: #f8fafc;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --gold-color: #f59e0b;
    --selected-category-bg: color-mix(in srgb, var(--success-color) 15%, transparent);
    --partial-category-bg: color-mix(in srgb, #3b82f6 40%, transparent);
    --selected-theme-bg: color-mix(in srgb, #10b981 30%, transparent);
    --partial-theme-bg: color-mix(in srgb, #3b82f6 30%, transparent);
    --app-bottom-safe: 40px;
    --shadow-color: rgba(15, 23, 42, 0.08);
}

/* --- Классическая уютная тема (Сепия) --- */
[data-theme="sepia"], .theme-sepia {
    --bg-grad-start: #d7c29e;
    --bg-grad-end: #b9a178;
    --accent-color: #5d4037;
    --accent-hover: #4e342e;
    --text-color: #3e2723;
    --bg-color: #fdf5e6;
    --paper-color: #faf3e0;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --gold-color: #FFD700;
    --selected-category-bg: color-mix(in srgb, var(--success-color) 15%, transparent);
    --partial-category-bg: color-mix(in srgb, #87CEEB 40%, transparent);
    --selected-theme-bg: color-mix(in srgb, #90EE90 50%, transparent);
    --partial-theme-bg: color-mix(in srgb, #ADD8E6 50%, transparent);
    --shadow-color: rgba(93, 64, 55, 0.15);
}

/* --- Современная Тёмная тема --- */
[data-theme="dark"], .theme-dark {
    --bg-grad-start: #0f172a;
    --bg-grad-end: #020617;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --text-color: #f8fafc;
    --bg-color: #1e293b;
    --paper-color: #0f172a;
    --success-color: #10b981;
    --danger-color: #f43f5e;
    --gold-color: #fbbf24;
    --selected-category-bg: color-mix(in srgb, var(--success-color) 25%, transparent);
    --partial-category-bg: color-mix(in srgb, #60a5fa 40%, transparent);
    --selected-theme-bg: color-mix(in srgb, #10b981 40%, transparent);
    --partial-theme-bg: color-mix(in srgb, #60a5fa 40%, transparent);
    --shadow-color: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--global-font-family);
    font-size: var(--global-font-size);
    background: linear-gradient(135deg, var(--bg-grad-start), var(--bg-grad-end));
    min-height: var(--app-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    transition: background 0.3s ease, color 0.3s ease, font-size 0.3s, font-family 0.3s;
    color: var(--text-color);
}



.main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 960px;
    position: relative;
    min-height: unset;
    margin-bottom: 40px;
    /* отрыв от низа */
    margin-bottom: var(--app-bottom-safe);
}




.container {
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-color);
    padding: 20px 25px;
    max-width: 900px;
    width: 100%;
    /* animation: fadeIn 0.5s;  <-- ОТКЛЮЧЕНО ПО ПРОСЬБЕ ПОЛЬЗОВАТЕЛЯ (Убрать эффект "появления из пустоты") */
    position: relative;
    overflow: visible;
    margin-top: 10px;
    margin-bottom: 10px;
    transition: max-width 0.4s ease-in-out, background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --- Стили для кнопки "Назад" (используется на стр. Выбора) --- */
.header-controls {
    display: flex;
    width: 100%;
    max-width: 900px;
    /* Совпадает с .container */
    margin-bottom: 10px;
    justify-content: flex-start;
}

.header-controls .button {
    padding: 8px 15px;
    font-size: 0.9em;
    width: auto;
    /* Переопределяем width: 100% */
}

h1 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8em;
    position: relative;
}

h2,
h3 {
    color: var(--accent-hover);
    margin-bottom: 15px;
    margin-top: 10px;
}

.button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 20px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
    width: auto;
    font-weight: 500;
}

.button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.button.secondary {
    background: var(--paper-color);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.button.secondary:hover:not(:disabled) {
    color: white;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #bbb;
    color: #777;
    border-color: #bbb;
    box-shadow: none;
    transform: none;
}

.button.small {
    padding: 6px 15px;
    font-size: 0.9em;
    text-decoration: none !important;
}

.tooltip {
    position: fixed;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    transition: opacity 0.2s, visibility 0s linear 0.2s;
    pointer-events: none;
    white-space: pre-wrap;
    max-width: 300px;
    line-height: 1.4;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.tooltip.visible {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}


/* --- Общая Адаптация --- */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 15px;
        border-radius: 0;
        min-height: calc(var(--app-height) - 10px);
    }

    /* --- Адаптация кнопки "Назад" --- */
    .header-controls {
        margin-bottom: 5px;
        padding: 0 10px;
    }

    h1 {
        font-size: 1.6em;
    }

    .button {
        padding: 12px 20px;
    }
}

/* --- GLOBAL PRELOADER (Обновленный) --- */
#global-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Изменено: полупрозрачный светлый фон (R, G, B, Прозрачность от 0 до 1) */
    background: rgba(245, 245, 235, 0.85);
    z-index: 99999;
    /* Поверх всего */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    backdrop-filter: blur(2px);
    /* Дополнительный эффект размытия фона под прелоадером (работает в современных браузерах) */
}

#global-preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Анимация пульсации для иконки */
.preloader-icon {
    /* Изменено: Размер увеличен в 5 раз (было 4rem) */
    font-size: 20rem;
    animation: brainPulse 500ms infinite ease-in-out;
    /* Чуть медленнее пульсация (2s) */
    margin-bottom: 10px;
    /* Убрал отступ снизу, при таком размере он не нужен */
    line-height: 1;
}

.preloader-text {
    font-family: var(--global-font-family);
    color: var(--accent-color);
    font-size: 3.0rem;
    /* Чуть увеличил текст */
    font-weight: 600;
    opacity: 0.8;
    letter-spacing: 2px;
    margin-top: -10px;
    /* Подтянул текст поближе к огромному мозгу */
}

@keyframes brainPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    /* Изменено: пульсация стала мягче (1.05 вместо 1.1), так как объект огромный */
    40% {
        transform: scale(1.05);
        opacity: 0.9;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Стили для кнопок виджета */
#audio-widget button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    transition: transform 0.2s;
}

#audio-widget button:hover {
    transform: scale(1.2);
}

#audio-widget button.muted {
    opacity: 0.6;
    filter: grayscale(100%);
}


html {
    font-size: 16px;
}

@media (min-height: 900px) {
    body {
        justify-content: center;
    }
}

@media (min-width: 1920px) {
    html {
        font-size: 18px;
        /* ≈ 112–120% */
    }
}

@media (min-width: 2560px) {
    html {
        font-size: 19px;
    }
}


/* --- Cookie Consent Banner --- */
.cookie-consent-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: var(--bg-color);
    /* Используем твой бежевый фон */
    border: 2px solid var(--accent-color);
    /* Твой акцентный коричневый */
    color: var(--text-color);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    /* Поверх всего, даже прелоадера */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: slideUp 0.5s ease-out;
    font-family: var(--global-font-family);
}

.cookie-consent-banner p {
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.cookie-consent-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Анимация появления */
@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Адаптивность для мобилок */
@media (max-width: 480px) {
    .cookie-consent-banner {
        width: 95%;
        bottom: 10px;
        padding: 15px;
    }

    .cookie-consent-actions {
        flex-direction: row;
    }
}

/* --- PREMIUM GLOBAL HEADER BAR SYSTEM --- */
body.themed-body {
  padding-top: 80px;
  box-sizing: border-box;
}

.login-header-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
  transition: background 0.4s ease, border-color 0.4s ease;
}
[data-theme="dark"] .login-header-bar {
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}
[data-theme="sepia"] .login-header-bar {
  background: rgba(244, 228, 205, 0.4);
  border-bottom: 1px solid rgba(93, 64, 55, 0.15);
}
.login-header-logo {
  font-size: 1.4em;
  font-weight: 800;
  color: var(--accent-color);
  letter-spacing: 0.5px;
}
.login-header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}
.theme-switcher-bar {
  display: flex;
  gap: 6px;
  background: rgba(181, 133, 77, 0.1);
  padding: 4px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}
[data-theme="dark"] .theme-switcher-bar {
  background: rgba(139, 92, 246, 0.15);
}
.theme-switch-btn {
  background: none;
  border: none;
  font-size: 1.1em;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.25s ease;
}
.theme-switch-btn:hover {
  background: rgba(181, 133, 77, 0.2);
}
[data-theme="dark"] .theme-switch-btn:hover {
  background: rgba(139, 92, 246, 0.25);
}
.theme-switch-btn.active {
  background: var(--accent-color) !important;
  box-shadow: 0 2px 8px var(--shadow-color);
}

@media (max-width: 600px) {
  body.themed-body {
    padding-top: 70px;
  }
  .login-header-bar {
    padding: 8px 10px;
    flex-direction: row;
    gap: 5px;
    position: fixed;
    justify-content: space-between;
  }
  .login-header-controls {
    flex-grow: 1;
    justify-content: space-between;
    gap: 8px;
  }
  .login-header-logo {
    display: none;
  }
  .container, .themed-container, .menu-container {
    margin-top: 10px;
  }
}

/* --- PREMIUM BACK BUTTON SYSTEM --- */
.back-to-main-btn-premium {
  background: rgba(181, 133, 77, 0.1);
  color: var(--accent-color);
  border: 1px solid var(--border-color);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}
[data-theme="dark"] .back-to-main-btn-premium {
  background: rgba(139, 92, 246, 0.15);
}
.back-to-main-btn-premium:hover {
  background: var(--accent-color);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 15px var(--shadow-color);
}
.back-to-main-btn-premium:active {
  transform: scale(0.95);
}
