/* ============================================
   Ретро-ТВ Лендинг — Основные стили
   Цветовая палитра: пастельные тона (мятный, кремовый, приглушённый оранжевый)
   ============================================ */

/* --- CSS Переменные --- */
:root {
    --color-mint: #b8e8d0;
    --color-mint-dark: #8fcfb8;
    --color-cream: #f5f0e6;
    --color-orange-muted: #e09f7d;
    --color-orange-dark: #c4855f;
    --color-brown-retro: #8b6f47;
    --color-text-dark: #4a4a4a;
    --color-text-light: #6b6b6b;
    --color-shadow: rgba(0, 0, 0, 0.15);
    --color-overlay: rgba(139, 111, 71, 0.1);
    
    --font-main: 'Courier New', Courier, monospace;
    --font-display: Georgia, serif;
    
    --transition-fast: 0.2s ease;
    --transition-medium: 0.4s ease;
    --transition-slow: 0.8s ease;
}

/* --- Сброс и базовые стили --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-cream);
    color: var(--color-text-dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Контейнер страницы --- */
.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Основной контейнер с фоном --- */
.backstage-container {
    position: relative;
    flex: 1;
    display: block;
    padding: 0;
    background-color: var(--color-cream);
    overflow: visible; /* Изменил с hidden на visible */
}

.backstage-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain; /* Гарантирует что всё изображение видно */
    /* Эффект лёгкой состаренности */
    filter: sepia(10%) contrast(95%) brightness(98%);
}

/* --- Контейнер для интерактивных областей (imgmap) --- */
.imgmap_css_container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* --- Интерактивные области --- */
.interactive-area {
    position: absolute;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: filter var(--transition-fast);
    z-index: 10;
    text-decoration: none;
}

.interactive-area em {
    display: none; /* Скрываем пустой em из imgmap */
}

/* TV область имеет свой hover */
.area-tv:hover {
    filter: brightness(1.1);
}

/* Игрушка имеет свой hover */
.area-toy:hover {
    filter: brightness(1.1);
}

.interactive-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* --- Область телевизора --- */
.area-tv {
    /* Позиционирование будет задано через JS в процентах */
    z-index: 20; /* Телевизор выше остальных элементов */
}

/* --- Область игрушки --- */
.area-toy {
    /* Позиционирование будет задано через JS в процентах */
    z-index: 15;
}

.toy-image {
    transition: opacity var(--transition-fast);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- Статичные элементы (джойстик, картридж, консоль) --- */
.static-item {
    /* Без анимации */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Интерактивные области со статичными элементами */
.area-joystick,
.area-cartridge,
.area-console {
    transition: filter var(--transition-fast);
}

.area-joystick:hover,
.area-cartridge:hover,
.area-console:hover {
    filter: brightness(1.15);
}

/* --- Tooltip в стиле комиксов --- */
.interactive-area[data-tooltip] {
    position: relative;
}

.interactive-area[data-tooltip]::before,
.interactive-area[data-tooltip]::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

/* Пузырь комикса */
.interactive-area[data-tooltip]::before {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px) scale(0.8);
    width: 160px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    border: 3px solid #4a4a4a;
    border-radius: 15px;
    box-shadow: 
        5px 5px 0px rgba(0, 0, 0, 0.2),
        inset 0 0 20px rgba(0, 0, 0, 0.05);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: bold;
    color: #4a4a4a;
    text-align: center;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Хвост пузыря */
.interactive-area[data-tooltip]::after {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px) scale(0.8);
    margin-bottom: -8px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #4a4a4a transparent transparent;
    width: 0;
    height: 0;
    background: transparent;
    box-shadow: none;
}

/* Внутренний хвост для белого фона */
.interactive-area[data-tooltip] .tooltip-inner {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: -2px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #fff transparent transparent;
    width: 0;
    height: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 101;
}

/* Показ tooltip при наведении */
.interactive-area[data-tooltip]:hover::before,
.interactive-area[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px) scale(1);
}

/* Контент tooltip */
.interactive-area[data-tooltip]::before {
    content: attr(data-tooltip);
}

/* Дополнительная стилизация для кликабельных элементов */
.area-cartridge {
    cursor: pointer;
}

/* --- Телевизор --- */
.tv-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tv-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Экран телевизора для видео */
.tv-screen {
    position: absolute;
    /* Расчёт на основе tv.png (767×632) - подгоняем под чёрную область экрана */
    top: 12%;     /* Чуть выше для лучшей центровки */
    left: 12%;    /* Сдвигаем для центровки */
    width: 62%;   /* Увеличиваем ширину */
    height: 58%;  /* Увеличиваем высоту */
    background-color: #1a1a1a;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5; /* Экран внутри телевизора */
    /* Добавляем скругление для эффекта старого ТВ */
    border-radius: 10%;
}

/* Эффект шума (статический) - золотая рябь при плохом сигнале */
.tv-static {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0;
    pointer-events: none;
    z-index: 19;
    /* Золотистый оттенок через mix-blend-mode */
    mix-blend-mode: screen;
    background-color: rgba(255, 200, 100, 0.3);
}

/* Анимация включения ТВ (при загрузке) - 3 секунды шума */
.tv-screen.tv-loading .tv-static {
    opacity: 0.5;
    animation: tv-static-anim 3s ease-out;
}

.tv-screen.tv-loading .tv-screen-placeholder {
    opacity: 0;
}

@keyframes tv-static-anim {
    0% { opacity: 0.6; }
    50% { opacity: 0.4; }
    100% { opacity: 0; }
}

/* После загрузки - показываем контент */
.tv-screen.tv-loaded .tv-static {
    opacity: 0;
}

.tv-screen.tv-loaded .tv-screen-placeholder {
    opacity: 1;
    transition: opacity 0.5s ease 0.3s;
}

/* Placeholder поверх эффектов */
.tv-screen-placeholder {
    position: relative;
    z-index: 22;
    color: #e0e0e0;
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
    font-family: var(--font-main);
    line-height: 1.8;
}

.tv-screen iframe {
    position: relative;
    z-index: 22;
    width: 100%;
    height: 100%;
    border: none;
}

/* Сообщение на экране телевизора */
.tv-message {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
}

.tv-message-title {
    color: #e0e0e0;
    font-size: 1rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.tv-message-subtitle {
    color: #aaa;
    font-size: 0.85rem;
    margin: 0;
}

.tv-message-hint {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Основной шрифт подсказок — крупный для десктопов */
.hint-item {
    color: #ccc;
    font-size: 1.375rem;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.5;
}

.hint-red {
    color: #ff6b6b;
    font-size: 1.625rem;
}

.hint-blue {
    color: #4dabf7;
    font-size: 1.625rem;
}

.hint-item strong {
    color: #fff;
    font-weight: bold;
}

/* --- Кнопки телевизора --- */
.tv-btn {
    position: absolute;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 30; /* Кнопки поверх всего */
    transition: filter var(--transition-fast);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Transform для центрирования задаётся в JS */
}

.tv-btn:hover {
    filter: brightness(1.15);
}

.tv-btn:active {
    filter: brightness(0.9);
}

.tv-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tv-btn span {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Позиционирование кнопок — через JS функцию positionTVButtons() */
/* Точные координаты из карты: tv.png = 767×632 */
/* Кнопки центрируются через transform: translate(-50%, -50%) */
.tv-btn-youtube,
.tv-btn-vk,
.tv-btn-youtube-alt,
.tv-btn-youtube-alt2 {
    /* Позиционирование задаётся в JS */
}

/* --- Футер --- */
.page-footer {
    background: linear-gradient(180deg, var(--color-mint) 0%, var(--color-cream) 100%);
    border-top: 2px solid var(--color-brown-retro);
    padding: 20px 30px;
    box-shadow: 0 -4px 10px var(--color-shadow);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-dark);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.5);
    transition: all var(--transition-fast);
    border: 1px solid var(--color-mint-dark);
}

.footer-link:hover {
    background-color: var(--color-mint);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--color-shadow);
}

.footer-icon {
    width: 20px;
    height: 20px;
}

.footer-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-btn {
    display: inline-block;
    padding: 10px 24px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: bold;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 25px;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 2px solid transparent;
}

.btn-payment {
    background-color: var(--color-orange-muted);
    color: var(--color-cream);
    border-color: var(--color-orange-dark);
}

.btn-payment:hover {
    background-color: var(--color-orange-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(224, 159, 125, 0.4);
}

.btn-terms {
    background-color: transparent;
    color: var(--color-text-dark);
    border-color: var(--color-brown-retro);
}

.btn-terms:hover {
    background-color: var(--color-brown-retro);
    color: var(--color-cream);
    transform: translateY(-2px);
}

/* --- Адаптивность (Mobile First) --- */
@media (max-width: 768px) {
    .backstage-container {
        padding: 10px;
    }
    
    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .footer-buttons {
        justify-content: center;
    }
    
    .footer-btn {
        padding: 8px 20px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .footer-link {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .footer-icon {
        width: 16px;
        height: 16px;
    }

    /* Адаптивный шрифт подсказок для телефонов */
    .hint-item {
        font-size: 0.85rem;
        gap: 6px;
    }

    .hint-red,
    .hint-blue {
        font-size: 1rem;
    }

    .tv-message-title {
        font-size: 0.9rem;
    }

    .tv-message-subtitle {
        font-size: 0.75rem;
    }
}

/* --- Планшеты (768px и меньше) --- */
@media (max-width: 768px) {
    /* Адаптивный шрифт подсказок для планшетов */
    .hint-item {
        font-size: 0.95rem;
        gap: 8px;
    }

    .hint-red,
    .hint-blue {
        font-size: 1.1rem;
    }

    .tv-message-title {
        font-size: 1rem;
    }

    .tv-message-subtitle {
        font-size: 0.8rem;
    }
}

/* --- Эффект старого телевизора (опционально) --- */
@keyframes tv-flicker {
    0%, 100% { opacity: 1; }
    5% { opacity: 0.95; }
    10% { opacity: 1; }
    15% { opacity: 0.98; }
    20% { opacity: 1; }
}

.tv-screen.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    animation: tv-flicker 0.3s infinite;
}

/* --- Виньетка для ретро-эффекта --- */
.backstage-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.1) 100%
    );
    pointer-events: none;
}

/* АНИМАЦИЯ ИГРУШКИ */
@keyframes toy-spiral {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(10px, -10px) rotate(90deg); }
    50% { transform: translate(20px, -20px) rotate(180deg); }
    75% { transform: translate(25px, -25px) rotate(270deg); }
    100% { transform: translate(30px, -30px) rotate(360deg); }
}

@keyframes toy-return {
    0% { transform: translate(30px, -30px) rotate(360deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.toy-spiral { animation: toy-spiral 1.5s ease-out forwards; }
.toy-return { animation: toy-return 1s ease-in forwards; }

/* ============================================
   МОДАЛЬНОЕ ОКНО "УСЛОВИЯ"
   ============================================ */

/* Затемнение фона */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* Окно модального окна */
.modal-window {
    position: relative;
    width: 68%;
    max-width: 900px;
    max-height: 85vh;
    background: linear-gradient(135deg, #f5f0e6 0%, #e8e4d8 100%);
    border: 3px solid var(--color-brown-retro);
    border-radius: 15px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(139, 111, 71, 0.1);
    overflow: hidden;
    animation: modal-slide-in 0.4s ease-out;
}

@keyframes modal-slide-in {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Кнопка закрытия */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, var(--color-orange-muted) 0%, var(--color-orange-dark) 100%);
    border: 2px solid var(--color-brown-retro);
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-cream);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.modal-close:hover {
    background: linear-gradient(135deg, var(--color-orange-dark) 0%, #a87050 100%);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(224, 159, 125, 0.4);
}

.modal-close:active {
    transform: scale(0.95);
}

/* Контент модального окна */
.modal-content {
    padding: 40px 50px 40px 50px;
    overflow-y: auto;
    max-height: 85vh;
}

/* Заголовок */
.modal-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-brown-retro);
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--color-mint-dark);
}

/* Текст */
.modal-text {
    font-family: var(--font-main);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text-dark);
}

.modal-text p {
    margin-bottom: 15px;
}

.modal-text ul {
    margin: 20px 0;
    padding-left: 30px;
}

.modal-text li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Предупреждение */
.modal-warning {
    background-color: rgba(255, 107, 107, 0.1);
    border-left: 4px solid #ff6b6b;
    padding: 15px 20px;
    margin: 25px 0;
    font-weight: bold;
    color: #c44;
}

/* Финальная фраза */
.modal-final {
    text-align: center;
    font-size: 1.2rem;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--color-mint-dark);
}

/* Адаптивность для планшетов */
@media (max-width: 768px) {
    .modal-window {
        width: 85%;
    }

    .modal-content {
        padding: 30px 35px;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .modal-text {
        font-size: 0.9rem;
    }
}

/* Адаптивность для телефонов */
@media (max-width: 480px) {
    .modal-window {
        width: 92%;
        max-height: 90vh;
    }

    .modal-content {
        padding: 25px 20px;
    }

    .modal-title {
        font-size: 1.3rem;
    }

    .modal-close {
        width: 30px;
        height: 30px;
        font-size: 1.3rem;
        top: 10px;
        right: 10px;
    }

    .modal-text {
        font-size: 0.85rem;
    }

    .modal-warning {
        padding: 12px 15px;
        font-size: 0.85rem;
    }
}
