/* ============================================
   DREAM IMMERSION ENGINE — Styles
   Non-destructive atmospheric background layer
   ============================================ */

/* ── Root container ── */
#dream-immersion-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
    will-change: transform;
}

/* ── Floating drift layers ── */
.di-layer {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    will-change: transform, opacity;
    pointer-events: none;
}

.di-layer--mist {
    background:
        radial-gradient(ellipse 900px 650px at 20% 30%, rgba(90, 120, 245, 0.50), transparent 70%),
        radial-gradient(ellipse 800px 600px at 75% 60%, rgba(195, 40, 255, 0.45), transparent 70%),
        radial-gradient(ellipse 700px 550px at 50% 80%, rgba(0, 245, 255, 0.35), transparent 70%),
        radial-gradient(ellipse 500px 500px at 40% 50%, rgba(102, 126, 234, 0.22), transparent 60%);
}

.di-layer--nebula {
    background:
        radial-gradient(ellipse 1000px 750px at 60% 20%, rgba(110, 55, 180, 0.42), transparent 65%),
        radial-gradient(ellipse 700px 550px at 30% 70%, rgba(0, 245, 255, 0.32), transparent 65%),
        radial-gradient(ellipse 600px 600px at 80% 80%, rgba(181, 55, 242, 0.28), transparent 60%);
}

.di-layer--veil {
    background:
        radial-gradient(ellipse 800px 600px at 80% 50%, rgba(255, 210, 0, 0.18), transparent 60%),
        radial-gradient(ellipse 750px 600px at 15% 45%, rgba(160, 35, 230, 0.22), transparent 60%),
        radial-gradient(ellipse 600px 500px at 50% 20%, rgba(0, 240, 255, 0.14), transparent 55%);
}

/* ── Atmospheric fog strip ── */
.di-fog {
    position: absolute;
    bottom: 0;
    left: -100%;
    width: 300%;
    height: 35%;
    background: linear-gradient(
        to top,
        rgba(6, 10, 32, 0.45) 0%,
        rgba(10, 16, 36, 0.22) 40%,
        transparent 100%
    );
    opacity: 0.8;
    will-change: transform;
    animation: di-fog-drift 45s linear infinite;
}

.di-fog--upper {
    bottom: auto;
    top: 0;
    height: 22%;
    background: linear-gradient(
        to bottom,
        rgba(6, 10, 32, 0.35) 0%,
        rgba(10, 16, 36, 0.16) 40%,
        transparent 100%
    );
    opacity: 0.7;
    animation: di-fog-drift 60s linear infinite reverse;
}

@keyframes di-fog-drift {
    0%   { transform: translate3d(0, 0, 0); }
    25%  { transform: translate3d(8.33%, 3px, 0); }
    50%  { transform: translate3d(16.67%, 0, 0); }
    75%  { transform: translate3d(25%, -3px, 0); }
    100% { transform: translate3d(33.33%, 0, 0); }
}

/* ── Content stacking: ensure page content sits above atmospheric layers ── */
.dream-page .container,
.dream-page .tarot-container,
.dream-page main,
.dream-page header,
.dream-page .grid,
.dream-page .hero-section,
.dream-page .selection-section,
.dream-page .back-btn,
.dream-page h1,
.dream-page .header-bar {
    position: relative;
    z-index: 2;
}

/* board-section: use isolation to stack above engine without breaking 3D card flips */
.dream-page .board-section {
    position: relative;
    z-index: 2;
}

/* Preserve 3D context through the card hierarchy */
.dream-page .board-section,
.dream-page .cards-layout {
    transform-style: preserve-3d;
}

/* .card class used in dream-interpreter — keep stacking but not on tarot cards */
.dream-page .card:not(.tarot-card):not(.card-face) {
    position: relative;
    z-index: 2;
}

/* Fixed-position UI elements — keep their own positioning, just ensure z-index */
.dream-page .energy-line {
    z-index: 2;
}
.dream-page .dream-engine-badge {
    z-index: 100;
}

/* ── Foreground overlay (particles + vignette above content) ── */
#dream-immersion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 50;
    pointer-events: none;
    overflow: hidden;
}

/* ── Vignette: dark edges for portal-viewing feel ── */
.di-vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(
        ellipse 70% 70% at 50% 50%,
        transparent 30%,
        rgba(5, 2, 20, 0.25) 60%,
        rgba(3, 1, 12, 0.55) 100%
    );
    animation: di-vignette-breathe 8s ease-in-out infinite;
}

@keyframes di-vignette-breathe {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 0.9; }
}

/* ── Floating particles (glowing orbs) ── */
.di-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
}

.di-particle--cyan {
    background: radial-gradient(circle, rgba(0, 240, 255, 1), rgba(0, 240, 255, 0) 65%);
    box-shadow: 0 0 25px 8px rgba(0, 240, 255, 0.6), 0 0 60px rgba(0, 240, 255, 0.3);
}

.di-particle--purple {
    background: radial-gradient(circle, rgba(181, 55, 242, 1), rgba(181, 55, 242, 0) 65%);
    box-shadow: 0 0 25px 8px rgba(181, 55, 242, 0.6), 0 0 60px rgba(181, 55, 242, 0.3);
}

.di-particle--gold {
    background: radial-gradient(circle, rgba(255, 215, 0, 1), rgba(255, 215, 0, 0) 65%);
    box-shadow: 0 0 20px 6px rgba(255, 215, 0, 0.55), 0 0 50px rgba(255, 215, 0, 0.25);
}

.di-particle--white {
    background: radial-gradient(circle, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0) 55%);
    box-shadow: 0 0 15px 5px rgba(255, 255, 255, 0.7), 0 0 40px rgba(255, 255, 255, 0.3);
}

/* ── Ambient glow pulse ── */
.di-ambient-glow {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.di-ambient-glow--center {
    background: radial-gradient(
        ellipse 70% 60% at 50% 50%,
        rgba(102, 126, 234, 0.18),
        rgba(181, 55, 242, 0.10) 40%,
        transparent 70%
    );
    animation: di-glow-pulse 6s ease-in-out infinite;
}

.di-ambient-glow--edge {
    background:
        radial-gradient(ellipse 45% 65% at 0% 50%, rgba(0, 240, 255, 0.14), transparent 60%),
        radial-gradient(ellipse 45% 65% at 100% 50%, rgba(181, 55, 242, 0.14), transparent 60%);
    animation: di-glow-pulse 8s ease-in-out infinite reverse;
}

@keyframes di-glow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.08); }
}

/* ── Portal arrival bloom (transparent, non-blocking) ── */
.di-portal-entrance {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 10000;
    pointer-events: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    animation: di-bloom-container 1.2s ease-out forwards;
}

@keyframes di-bloom-container {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

.di-portal-ring {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(0, 240, 255, 0.35) 0%,
        rgba(102, 126, 234, 0.25) 15%,
        rgba(181, 55, 242, 0.15) 35%,
        transparent 60%
    );
    box-shadow:
        0 0 60px 15px rgba(0, 240, 255, 0.35),
        0 0 120px 30px rgba(181, 55, 242, 0.20),
        inset 0 0 60px 15px rgba(0, 240, 255, 0.15);
    animation: di-portal-expand 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.di-portal-ring--inner {
    animation-delay: 0.08s;
    opacity: 0.6;
    box-shadow:
        0 0 50px 12px rgba(255, 215, 0, 0.25),
        0 0 100px 25px rgba(102, 126, 234, 0.15);
}

@keyframes di-portal-expand {
    0% {
        width: 20vmin; height: 20vmin;
        opacity: 1;
        filter: brightness(1.8);
    }
    40% {
        width: 120vmax; height: 120vmax;
        opacity: 0.8;
        filter: brightness(1.3);
    }
    100% {
        width: 300vmax; height: 300vmax;
        opacity: 0;
        filter: brightness(1);
    }
}

/* ── Portal arrival motes ── */
.di-portal-mote {
    position: absolute;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.9);
    box-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
    animation: di-mote-scatter 1.2s ease-out forwards;
}

@keyframes di-mote-scatter {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }
    25% {
        opacity: 1;
        transform: translate(var(--mx), var(--my)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(var(--mx) * 2.5), calc(var(--my) * 2.5)) scale(0.2);
    }
}

/* ── Symbol-triggered overlays ── */
.di-symbol-fx {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 3;
}

/* Water — horizontal ripple bands */
.di-symbol-fx--water {
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0%,
            rgba(0, 240, 255, 0.04) 4%,
            transparent 8%
        );
}

/* Fire — warm central glow */
.di-symbol-fx--fire {
    background: radial-gradient(
        ellipse 50% 50% at 50% 60%,
        rgba(255, 140, 0, 0.10),
        rgba(255, 60, 0, 0.04) 50%,
        transparent 80%
    );
}

/* Shadow — edge vignette */
.di-symbol-fx--shadow {
    background: radial-gradient(
        ellipse 70% 70% at 50% 50%,
        transparent 30%,
        rgba(10, 5, 25, 0.18) 100%
    );
}

/* Falling — small drifting motes (container, motes are JS-created spans) */
.di-symbol-fx--falling {
    overflow: hidden;
}
.di-symbol-fx--falling .di-mote {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(181, 55, 242, 0.35);
    will-change: transform, opacity;
}

/* Mirror — frosted blur band */
.di-symbol-fx--mirror {
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
}

/* ── Static fallback (low-perf mode) ── */
.di-static-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 60% 50% at 25% 35%, rgba(102, 126, 234, 0.12), transparent),
        radial-gradient(ellipse 55% 45% at 70% 60%, rgba(181, 55, 242, 0.10), transparent);
    opacity: 1;
}

/* ── Reduced motion: disable everything animated ── */
@media (prefers-reduced-motion: reduce) {
    .di-layer,
    .di-fog {
        animation: none !important;
        transform: none !important;
        transition: none !important;
    }
}
