/**
 * Curtain Overlay Component
 * Театральный занавес для начала/завершения встречи
 * Вариант D: Минималистичный
 */

/* ===== Основной контейнер ===== */
.curtain-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.curtain-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Когда занавес открыт — НЕ блокировать клики под ним */
.curtain-overlay.visible.open {
    pointer-events: none;
}

/* ===== Половинки занавеса ===== */
.curtain-half {
    flex: 1;
    position: relative;
    /* Базовый тёмно-бордовый цвет */
    background: #6b1c1c;
    transition: transform 1.8s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    pointer-events: none;
}

.curtain-half--left {
    transform-origin: left center;
}

.curtain-half--right {
    transform-origin: right center;
}

/* Складки занавеса — repeating-linear-gradient для множества волн */
.curtain-half::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Повторяющиеся складки каждые 40px — как настоящие портьеры */
    background:
        repeating-linear-gradient(90deg,
            /* Тень (глубина складки) */
            rgba(0, 0, 0, 0.35) 0px,
            rgba(0, 0, 0, 0.25) 4px,
            /* Переход к свету */
            rgba(0, 0, 0, 0.1) 8px,
            /* Блик на гребне складки */
            rgba(255, 255, 255, 0.08) 12px,
            rgba(255, 255, 255, 0.12) 16px,
            rgba(255, 255, 255, 0.08) 20px,
            /* Переход обратно к тени */
            rgba(0, 0, 0, 0.1) 24px,
            rgba(0, 0, 0, 0.25) 32px,
            rgba(0, 0, 0, 0.35) 40px
        );
    pointer-events: none;
}

/* Дополнительный слой для объёма и глубины цвета */
.curtain-half::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        /* Вертикальный градиент — светлее сверху, темнее снизу */
        linear-gradient(180deg,
            rgba(255, 200, 200, 0.15) 0%,
            rgba(255, 150, 150, 0.08) 10%,
            transparent 30%,
            transparent 70%,
            rgba(0, 0, 0, 0.2) 90%,
            rgba(0, 0, 0, 0.35) 100%
        ),
        /* Горизонтальный градиент — темнее по краям */
        linear-gradient(90deg,
            rgba(0, 0, 0, 0.25) 0%,
            transparent 15%,
            transparent 85%,
            rgba(0, 0, 0, 0.25) 100%
        );
    pointer-events: none;
}

/* ===== Состояние: открыт ===== */
.curtain-overlay.open .curtain-half--left {
    transform: translateX(-100%);
}

.curtain-overlay.open .curtain-half--right {
    transform: translateX(100%);
}

/* ===== Логотип на закрытом занавесе ===== */
.curtain-logo {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate(-50%, 0);
    z-index: 10;
    text-align: center;
    transition: opacity 0.5s;
    pointer-events: none;
}

.curtain-overlay.open .curtain-logo,
.curtain-overlay.closed .curtain-logo {
    opacity: 0;
}

.curtain-logo img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.5);
    border: 3px solid rgba(212, 175, 55, 0.3);
}

.curtain-logo-text {
    font-family: 'Great Vibes', cursive;
    font-size: 3rem;
    color: #d4af37;
    text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}

/* ===== T405: Единый блок информации о встрече ===== */
.curtain-meeting-info {
    margin-top: 10px; /* было 20px, подняли на ~0.5см */
    text-align: center;
}

/* Название пьесы — белый, изящный */
.curtain-play-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 12px; /* было 16px */
    font-style: italic;
}

/* Имена участников — золотой, изящный */
.curtain-participants {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 12px; /* было 20px, таймер ближе к именам */
}

/* Таймер — золотой, изящный (НЕ моноширинный, НЕ огромный) */
.curtain-timer {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.7rem;
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 16px; /* было 10px, теперь отступ перед фразами */
}

/* Тролинг-фразы — белый, курсив, центрированные */
.curtain-phrase {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-style: italic;
    color: #fff;
    margin-top: 8px; /* было 20px, подняли за счёт убранной подсказки */
    min-height: 3em;
    transition: opacity 0.3s;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
    text-align: center;
    white-space: pre-line; /* Чтобы \n работал как перенос строки */
}

/* Пульсация таймера когда < 1 минуты */
.curtain-timer.pulse {
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes curtainPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Кнопка "Покинуть встречу" ===== */
.curtain-leave-btn {
    position: absolute;
    bottom: 130px; /* выше навигационных точек */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    pointer-events: auto !important;
    padding: 12px 28px;
    background: rgba(180, 60, 60, 0.9);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.curtain-leave-btn:hover {
    background: rgba(200, 70, 70, 0.9);
    border-color: rgba(255, 255, 255, 0.4);
}

.curtain-leave-btn:active {
    transform: translateX(-50%) scale(0.98);
}

/* ===== T236: Кнопка "Пригласить зрителей" ===== */
.curtain-invite-btn {
    margin-top: 20px;
    padding: 10px 24px;
    background: rgba(139, 92, 246, 0.9);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.curtain-invite-btn:hover {
    background: rgba(139, 92, 246, 1);
    border-color: rgba(255, 255, 255, 0.5);
}

.curtain-invite-btn:active {
    transform: scale(0.98);
}

/* ===== T348: Кнопка viewer-ссылки для Р2 ===== */
.curtain-viewer-link-btn {
    margin-top: 24px;
    padding: 12px 28px;
    background: rgba(34, 197, 94, 0.9);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.curtain-viewer-link-btn:hover {
    background: rgba(34, 197, 94, 1);
    border-color: rgba(255, 255, 255, 0.5);
}

.curtain-viewer-link-btn:active {
    transform: scale(0.98);
}

.curtain-viewer-link-info {
    margin-top: 16px;
    text-align: center;
}

.viewer-link-text {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    word-break: break-all;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.viewer-link-copy-btn {
    padding: 8px 20px;
    background: rgba(99, 102, 241, 0.9);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.viewer-link-copy-btn:hover {
    background: rgba(99, 102, 241, 1);
}

.viewer-link-copy-btn.copied {
    background: rgba(34, 197, 94, 0.9);
}

/* ===== Финальный экран (после закрытия) ===== */
.curtain-final {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease 1.5s; /* Задержка на время закрытия занавеса */
    z-index: 20;
}

.curtain-overlay.closed .curtain-final {
    opacity: 1;
}

.curtain-final .mascot-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 24px;
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.6);
    border: 3px solid rgba(212, 175, 55, 0.4);
    animation: mascotPulse 2s ease-in-out infinite;
}

@keyframes mascotPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 50px rgba(212, 175, 55, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 70px rgba(212, 175, 55, 0.8);
    }
}

.curtain-final .thanks-text {
    font-family: 'Great Vibes', cursive;
    font-size: 3rem;
    color: #d4af37;
    text-shadow: 0 2px 30px rgba(0,0,0,0.8);
    animation: thanksAppear 1s ease-out 2s both;
}

@keyframes thanksAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* T405: Старые стили scheduled удалены — теперь используется единый .curtain-meeting-info */

/* ===== Мобильная адаптация ===== */
@media (max-width: 768px) {
    /* T347: На мобильных занавес привязан к экрану Сцены, а не к viewport
       Это позволяет свайпать между экранами — занавес остаётся на Сцене */
    .curtain-overlay {
        position: absolute;
        inset: 0;
        z-index: 100; /* Ниже чем fixed (9999), но выше контента экрана */
        /* JS перемещает элемент внутрь .screen--stage */
    }

    /* Экран Stage не должен обрезать занавес */
    .screen--stage {
        overflow: visible !important;
    }

    .curtain-logo img {
        width: 100px;
        height: 100px;
    }

    .curtain-logo-text {
        font-size: 2.2rem;
    }

    .curtain-final .mascot-img {
        width: 120px;
        height: 120px;
    }

    .curtain-final .thanks-text {
        font-size: 2.5rem;
    }

    /* T405: Мобильная адаптация единого блока */
    .curtain-play-title,
    .curtain-participants,
    .curtain-timer {
        font-size: 1.5rem;
    }

    .curtain-phrase {
        font-size: 1.56rem;
    }

    .curtain-timer-hint {
        font-size: 1.1rem;
    }

    /* T347: На мобильных кнопки внутри занавеса должны иметь соответствующий z-index */
    .curtain-leave-btn {
        z-index: 101;
        bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .curtain-invite-btn {
        z-index: 101;
    }
}
