/**
 * Voidlust — desktop site chat visuals only
 * Scope: crave-site-mode + crave-desktop-ui, not PWA / not mobile
 * Loaded only from chat.html
 */

@media (min-width: 769px) {
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) {
        --vl-chat-ivory: rgba(245, 238, 226, 0.9);
        --vl-chat-panel-border: rgba(216, 168, 91, 0.16);
        --vl-chat-panel-glow: 0 28px 80px rgba(0, 0, 0, 0.55), 0 0 42px rgba(120, 18, 32, 0.14);
        --vl-chat-choice-glow: 0 22px 62px rgba(0, 0, 0, 0.5), 0 0 32px rgba(160, 20, 38, 0.16);
        --vl-chat-head: max(64px, calc(env(safe-area-inset-top) + 52px));
        --vl-chat-foot: max(10px, env(safe-area-inset-bottom));
        --vl-chat-choices: 200px;
        overflow: hidden !important;
        height: 100vh !important;
        min-height: 100vh;
        max-height: 100vh;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .app {
        height: 100vh;
        min-height: 100vh;
        overflow: hidden;
    }

    /* ── Background: darker hero, vignette, ambient glow ── */
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-background-layer.chat-bg {
        filter: blur(9px) brightness(0.62) saturate(0.92);
        -webkit-filter: blur(9px) brightness(0.62) saturate(0.92);
        transform: translateX(-50%) scale(1.08);
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-background-layer::after {
        background:
            radial-gradient(ellipse 88% 78% at 50% 48%, transparent 24%, rgba(0, 0, 0, 0.78) 100%),
            radial-gradient(ellipse 70% 42% at 50% 100%, rgba(120, 18, 32, 0.22), transparent 72%),
            radial-gradient(ellipse 55% 28% at 50% 100%, rgba(216, 168, 91, 0.08), transparent 68%),
            linear-gradient(
                to bottom,
                rgba(0, 0, 0, 0.58) 0%,
                rgba(0, 0, 0, 0.22) 34%,
                rgba(0, 0, 0, 0.32) 58%,
                rgba(0, 0, 0, 0.72) 100%
            );
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .character-background .chat-overlay {
        background: rgba(4, 3, 6, 0.3) !important;
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
    }

    /* ── Header polish ── */
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-top-bar {
        padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
        background: linear-gradient(180deg, rgba(6, 4, 8, 0.82) 0%, rgba(6, 4, 8, 0.45) 72%, transparent 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-top-brand {
        font-size: 0.62rem;
        letter-spacing: 0.32em;
        color: rgba(169, 163, 154, 0.72);
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-character-name--bar {
        font-size: clamp(1rem, 1.4vw, 1.28rem);
        letter-spacing: 0.16em;
        margin-top: 4px;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-font-aa-btn,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-crystal-compact {
        border-color: rgba(216, 168, 91, 0.14);
        background: rgba(8, 6, 10, 0.55);
        transition: border-color 0.28s ease, box-shadow 0.28s ease, background 0.28s ease;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-font-aa-btn:hover,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-crystal-compact:hover {
        border-color: rgba(216, 168, 91, 0.32);
        box-shadow: 0 0 18px rgba(120, 18, 32, 0.18);
        background: rgba(12, 8, 10, 0.72);
    }

    /* ── Viewport layout: dialogue fills down, answers at bottom ── */
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-main {
        position: relative !important;
        display: block !important;
        height: 100vh !important;
        min-height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
        padding: 0 !important;
        box-sizing: border-box;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-main > .character-background {
        z-index: 0;
        pointer-events: none;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-story-area {
        position: fixed !important;
        top: var(--vl-chat-head) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: calc(var(--vl-chat-foot) + var(--vl-chat-choices)) !important;
        transform: none !important;
        z-index: 5;
        width: min(780px, calc(100% - 48px)) !important;
        max-width: 780px;
        min-height: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start !important;
        align-items: stretch;
        padding: 8px 24px 6px !important;
        border-top: none;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        scrollbar-width: thin;
        scrollbar-color: rgba(72, 14, 18, 0.32) transparent;
        box-sizing: border-box;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-story-area::-webkit-scrollbar {
        width: 3px;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-story-area::-webkit-scrollbar-thumb {
        background: rgba(72, 14, 18, 0.32);
        border-radius: 4px;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box.text-block {
        flex: 1 1 auto !important;
        max-width: 760px;
        width: 100%;
        min-height: 100% !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 auto !important;
        align-self: stretch;
        display: flex;
        flex-direction: column;
        overflow: visible !important;
        padding: 34px 38px 32px;
        border-radius: 26px;
        background:
            linear-gradient(180deg, rgba(14, 10, 12, 0.82), rgba(5, 4, 6, 0.94));
        border: 1px solid var(--vl-chat-panel-border);
        box-shadow: var(--vl-chat-panel-glow);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        animation: vlChatSceneIn 0.58s ease-out both;
        box-sizing: border-box;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box::-webkit-scrollbar,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box.text-block::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-content {
        flex: 1 1 auto;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-content,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .message-container {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-content .message-text,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box .message-text,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .message-text {
        max-width: 42rem;
        margin: 0 auto;
        font-family: 'Cormorant Garamond', 'Libre Baskerville', Georgia, serif;
        font-size: calc(1.28rem * var(--chat-font-scale, 1)) !important;
        line-height: 1.82 !important;
        color: var(--vl-chat-ivory);
        text-shadow: 0 1px 18px rgba(0, 0, 0, 0.45);
        letter-spacing: 0.01em;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .user-message .message-text {
        color: rgba(232, 220, 208, 0.82);
        font-style: italic;
    }

    /* ── Answer panel: attached to scene ── */
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-choice-panel {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: var(--vl-chat-foot) !important;
        top: auto !important;
        transform: none !important;
        flex: none !important;
        z-index: 32;
        width: min(680px, calc(100% - 48px)) !important;
        max-width: 680px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: 18px 18px 16px !important;
        border-radius: 24px !important;
        background:
            linear-gradient(
                180deg,
                rgba(18, 10, 12, 0.9) 0%,
                rgba(10, 6, 8, 0.88) 12%,
                rgba(4, 3, 5, 0.96) 100%
            ) !important;
        border: 1px solid rgba(170, 20, 38, 0.22) !important;
        box-shadow:
            0 -10px 32px rgba(120, 18, 32, 0.1),
            0 -2px 14px rgba(216, 168, 91, 0.06),
            0 22px 62px rgba(0, 0, 0, 0.5),
            0 0 28px rgba(160, 20, 38, 0.12) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(216, 168, 91, 0.14) !important;
        animation: vlChatChoicesIn 0.62s ease-out 0.14s both;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-choice-panel::before {
        content: '';
        position: absolute;
        top: 0;
        left: 14%;
        right: 14%;
        height: 1px;
        background: linear-gradient(
            90deg,
            transparent 0%,
            rgba(216, 168, 91, 0.28) 22%,
            rgba(160, 20, 38, 0.38) 50%,
            rgba(216, 168, 91, 0.28) 78%,
            transparent 100%
        );
        pointer-events: none;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choices-grid.choices {
        gap: 12px !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choices-slots,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choices-slots.slots-4 {
        gap: 12px !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque-premium-hook {
        min-height: 52px !important;
        max-height: none !important;
        padding: 14px 16px !important;
        border-radius: 14px !important;
        background: linear-gradient(165deg, rgba(14, 10, 12, 0.92), rgba(8, 6, 8, 0.96)) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: rgba(240, 232, 220, 0.92) !important;
        font-size: 0.94rem !important;
        line-height: 1.38 !important;
        transition:
            transform 0.28s ease,
            border-color 0.28s ease,
            box-shadow 0.28s ease,
            background 0.28s ease !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque.is-selected,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque.active {
        border-color: rgba(216, 168, 91, 0.48) !important;
        background: linear-gradient(165deg, rgba(22, 12, 14, 0.96), rgba(10, 6, 8, 0.98)) !important;
        box-shadow: 0 0 24px rgba(160, 20, 38, 0.22), inset 0 0 0 1px rgba(216, 168, 91, 0.12) !important;
        animation: vlChatChoicePulse 2.4s ease-in-out infinite;
    }

    /* ── “Свой ответ” — secondary action ── */
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) #customAnswerBtn {
        max-width: 220px !important;
        min-height: 46px !important;
        margin: 4px auto 0 !important;
        padding: 10px 14px !important;
        gap: 8px;
        background: rgba(8, 6, 8, 0.72) !important;
        border: 1px solid rgba(216, 168, 91, 0.14) !important;
        color: rgba(210, 198, 184, 0.78) !important;
        font-size: 0.86rem !important;
        letter-spacing: 0.06em;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) #customAnswerBtn .plaque-lock-icon {
        width: 14px;
        height: 14px;
        opacity: 0.72;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) #customAnswerBtn:hover,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) #customAnswerBtn:focus-visible {
        color: rgba(245, 238, 226, 0.9) !important;
        border-color: rgba(216, 168, 91, 0.34) !important;
        background: rgba(14, 10, 12, 0.88) !important;
        box-shadow: 0 0 20px rgba(216, 168, 91, 0.1) !important;
        transform: translateY(-1px) !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .custom-input-row {
        margin-top: 12px;
        gap: 10px;
        padding-top: 4px;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .custom-input {
        min-height: 48px;
        padding: 12px 16px;
        border-radius: 14px;
        background: rgba(6, 4, 6, 0.88);
        border: 1px solid rgba(216, 168, 91, 0.14);
        color: var(--vl-chat-ivory);
        font-size: 1rem;
        transition: border-color 0.28s ease, box-shadow 0.28s ease;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .custom-input::placeholder {
        color: rgba(200, 188, 174, 0.45);
        font-style: italic;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .custom-input:focus {
        outline: none;
        border-color: rgba(216, 168, 91, 0.42);
        box-shadow: 0 0 0 1px rgba(216, 168, 91, 0.18), 0 0 24px rgba(120, 18, 32, 0.2);
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .send-btn-paid {
        border-radius: 14px;
        min-height: 48px;
        border: 1px solid rgba(179, 0, 0, 0.38);
        background: linear-gradient(165deg, rgba(100, 10, 16, 0.92), rgba(48, 6, 10, 0.96));
        transition: border-color 0.28s ease, box-shadow 0.28s ease, transform 0.28s ease;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .send-btn-paid:hover {
        border-color: rgba(216, 168, 91, 0.32);
        box-shadow: 0 0 22px rgba(160, 20, 38, 0.28);
        transform: translateY(-1px);
    }

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

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

    @keyframes vlChatChoicePulse {
        0%, 100% {
            box-shadow: 0 0 20px rgba(160, 20, 38, 0.18), inset 0 0 0 1px rgba(216, 168, 91, 0.1);
        }
        50% {
            box-shadow: 0 0 28px rgba(160, 20, 38, 0.28), inset 0 0 0 1px rgba(216, 168, 91, 0.16);
        }
    }
}

@media (min-width: 769px) and (hover: hover) {
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque:hover,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque:focus-visible,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque-premium-hook:hover,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque-premium-hook:focus-visible {
        transform: translateY(-2px) !important;
        border-color: rgba(216, 168, 91, 0.42) !important;
        background: linear-gradient(165deg, rgba(18, 12, 14, 0.96), rgba(10, 7, 9, 0.98)) !important;
        box-shadow: 0 0 24px rgba(216, 168, 91, 0.12), 0 8px 28px rgba(0, 0, 0, 0.42) !important;
    }

    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque-paid:hover,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque-paid:focus-visible {
        transform: translateY(-1px) scale(1) !important;
        box-shadow: 0 0 18px rgba(216, 168, 91, 0.1) !important;
    }
}

@media (min-width: 769px) and (prefers-reduced-motion: reduce) {
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .story-box.text-block,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .chat-choice-panel,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque.is-selected,
    body.chat-page.crave-site-mode.crave-desktop-ui:not(.crave-pwa-mode) .choice-plaque.active {
        animation: none !important;
    }
}
