/* ============================================
   yesang.org - Holographic Divination Chamber
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --void-black: #08080f;
    --obsidian-frost: #161625;
    --spectral-silver: #d0d4e2;
    --prismatic-violet: #9b72cf;
    --oracle-teal: #4dd9c0;
    --forecast-rose: #e07893;
    --prism-white: #f0f2ff;
    --iridescent-gold: #d4b872;

    --font-display: 'Sora', sans-serif;
    --font-body: 'Noto Serif KR', serif;
    --font-mono: 'Space Mono', monospace;

    --glass-bg: rgba(22, 22, 37, 0.55);
    --glass-blur: blur(24px) saturate(1.4);
    --glass-border: 1px solid rgba(212, 184, 114, 0.15);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void-black);
    color: var(--spectral-silver);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* --- Oracle Stack (Scroll Snap Container) --- */
.oracle-stack {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

/* --- Dispersion Lines --- */
.dispersion-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 500vh;
    pointer-events: none;
    z-index: 1;
}

.dispersion-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
    background: var(--spectral-silver);
    opacity: 0.08;
    transition: opacity 0.6s ease;
}

.dispersion-line.dispersing {
    opacity: 0.3;
    height: 3px;
    background: transparent;
    position: relative;
}

.dispersion-line.dispersing::before,
.dispersion-line.dispersing::after,
.dispersion-line.dispersing .split-center {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
}

.dispersion-line.dispersing::before {
    top: -1px;
    background: var(--prismatic-violet);
    opacity: 0.6;
}

.dispersion-line.dispersing::after {
    top: 1px;
    background: var(--forecast-rose);
    opacity: 0.6;
}

/* --- Chambers --- */
.chamber {
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- Light Leaks --- */
.light-leaks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.light-leak {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
}

.leak-violet {
    background: var(--prismatic-violet);
    width: 250%;
    height: 250%;
    top: -75%;
    left: -75%;
    opacity: 0.12;
    animation: leakDrift1 30s ease-in-out infinite;
}

.leak-teal {
    background: var(--oracle-teal);
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    opacity: 0.14;
    animation: leakDrift2 30s ease-in-out infinite;
}

.leak-rose {
    background: var(--forecast-rose);
    width: 180%;
    height: 180%;
    top: -40%;
    left: -40%;
    opacity: 0.12;
    animation: leakDrift3 30s ease-in-out infinite;
}

/* Chamber-specific light leak dominance */
.light-leaks-violet .leak-violet { opacity: 0.18; }
.light-leaks-violet .leak-teal { opacity: 0.10; }
.light-leaks-violet .leak-rose { opacity: 0.08; }

.light-leaks-teal .leak-violet { opacity: 0.10; }
.light-leaks-teal .leak-teal { opacity: 0.18; }
.light-leaks-teal .leak-rose { opacity: 0.10; }

.light-leaks-balanced .leak-violet { opacity: 0.16; }
.light-leaks-balanced .leak-teal { opacity: 0.16; }
.light-leaks-balanced .leak-rose { opacity: 0.16; }

.light-leaks-rose .leak-violet { opacity: 0.10; }
.light-leaks-rose .leak-teal { opacity: 0.08; }
.light-leaks-rose .leak-rose { opacity: 0.18; }

.light-leaks-all .leak-violet { opacity: 0.15; }
.light-leaks-all .leak-teal { opacity: 0.15; }
.light-leaks-all .leak-rose { opacity: 0.15; }

/* Balanced chamber has faster pulsing */
.light-leaks-balanced .leak-violet { animation-duration: 15s; }
.light-leaks-balanced .leak-teal { animation-duration: 15s; }
.light-leaks-balanced .leak-rose { animation-duration: 15s; }

/* Final chamber synchronized pulsing */
.light-leaks-all .leak-violet { animation-duration: 20s; }
.light-leaks-all .leak-teal { animation-duration: 20s; animation-delay: 0s; }
.light-leaks-all .leak-rose { animation-duration: 20s; animation-delay: 0s; }

@keyframes leakDrift1 {
    0%, 100% { transform: translate(0%, 0%); }
    25% { transform: translate(8%, -5%); }
    50% { transform: translate(-5%, 8%); }
    75% { transform: translate(3%, 3%); }
}

@keyframes leakDrift2 {
    0%, 100% { transform: translate(0%, 0%); }
    25% { transform: translate(-6%, 7%); }
    50% { transform: translate(5%, -3%); }
    75% { transform: translate(-3%, -5%); }
}

@keyframes leakDrift3 {
    0%, 100% { transform: translate(0%, 0%); }
    25% { transform: translate(4%, 6%); }
    50% { transform: translate(-7%, -4%); }
    75% { transform: translate(6%, -2%); }
}

/* --- Horizon Line (Chamber I intro) --- */
.horizon-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--spectral-silver);
    opacity: 0;
    z-index: 5;
    transition: opacity 1s ease;
    transform: translateY(-50%);
}

.horizon-line.visible {
    opacity: 0.5;
}

.horizon-line.dispersed {
    opacity: 0;
}

.horizon-split {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0.5px;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.horizon-violet {
    background: var(--prismatic-violet);
    top: 0;
}

.horizon-teal {
    background: var(--oracle-teal);
    top: 0;
}

.horizon-rose {
    background: var(--forecast-rose);
    top: 0;
}

.horizon-line.split .horizon-violet {
    opacity: 0.7;
    transform: translateY(-2px);
}

.horizon-line.split .horizon-teal {
    opacity: 0.7;
    transform: translateY(0px);
}

.horizon-line.split .horizon-rose {
    opacity: 0.7;
    transform: translateY(2px);
}

/* --- Glass Panels --- */
.glass-panel {
    position: relative;
    width: 70vw;
    height: 60vh;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: 4px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 5rem;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel.visible {
    opacity: 1;
    transform: scale(1);
}

.panel-offset-right {
    margin-left: 5%;
}

.panel-offset-left {
    margin-right: 5%;
}

.panel-large {
    width: 75vw;
    height: 65vh;
}

.panel-small {
    width: 60vw;
    height: 50vh;
}

/* --- Fortune Slip Watermark --- */
.fortune-watermark {
    position: absolute;
    width: 80px;
    height: 240px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
}

/* --- Typography --- */
.chamber-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 8rem);
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--spectral-silver);
    text-align: center;
    margin-bottom: 0.5rem;
    z-index: 1;
    transition: color 0.4s ease;
}

.chamber.active .chamber-title {
    color: var(--prism-white);
}

.chamber-title-final {
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.15em;
}

.chamber-subtitle {
    font-family: var(--font-display);
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 400;
    letter-spacing: 0.3em;
    color: var(--spectral-silver);
    opacity: 0.5;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 2rem;
    z-index: 1;
}

.panel-content {
    z-index: 1;
    text-align: center;
    max-width: 55vw;
}

.oracle-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 300;
    line-height: 2.0;
    color: var(--spectral-silver);
    margin-bottom: 0.5rem;
}

.oracle-text-sub {
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    font-weight: 300;
    line-height: 2.0;
    color: var(--spectral-silver);
    opacity: 0.6;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    font-weight: 300;
    line-height: 2.0;
    color: var(--spectral-silver);
    margin-bottom: 1.5rem;
}

.body-text:last-child {
    margin-bottom: 0;
}

.domain-name {
    font-family: var(--font-display);
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 400;
    letter-spacing: 0.3em;
    color: var(--spectral-silver);
    opacity: 0.3;
    position: absolute;
    bottom: 2rem;
    text-align: center;
    z-index: 1;
}

/* --- Navigation Dots --- */
.nav-dots {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 100;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(208, 212, 226, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
    padding: 0;
}

.nav-dot:hover {
    background: rgba(208, 212, 226, 0.5);
}

.nav-dot.active {
    background: rgba(240, 242, 255, 0.6);
    box-shadow: 0 0 12px 3px var(--prismatic-violet),
                0 0 24px 6px var(--oracle-teal),
                0 0 36px 9px rgba(224, 120, 147, 0.3);
    animation: dotPulse 3s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% {
        box-shadow: 0 0 12px 3px var(--prismatic-violet),
                    0 0 24px 6px var(--oracle-teal),
                    0 0 36px 9px rgba(224, 120, 147, 0.3);
    }
    50% {
        box-shadow: 0 0 16px 5px var(--prismatic-violet),
                    0 0 32px 10px var(--oracle-teal),
                    0 0 48px 14px rgba(224, 120, 147, 0.4);
    }
}

/* --- Floating Fragments --- */
.fragment-orbit {
    position: absolute;
    z-index: 15;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.floating-fragment {
    background: rgba(22, 22, 37, 0.4);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid rgba(224, 120, 147, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 800ms ease;
}

.floating-fragment.visible {
    opacity: 1;
}

.fragment-data {
    width: 12vw;
    height: 8vh;
    min-width: 90px;
    min-height: 60px;
    position: relative;
}

.fragment-glyph {
    width: 10vw;
    height: 12vh;
    min-width: 70px;
    min-height: 80px;
    padding: 8px;
}

.fragment-number {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: var(--oracle-teal);
    position: absolute;
    z-index: 2;
}

/* --- Probability Rings --- */
.probability-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
}

.ring-bg {
    fill: none;
    stroke: rgba(208, 212, 226, 0.08);
    stroke-width: 2;
}

.ring-fill {
    fill: none;
    stroke: url(#ringGradient);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 163.36;
    stroke-dashoffset: 163.36;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-fill.animated {
    /* stroke-dashoffset set by JS */
}

/* Gradient definition for rings - added via inline SVG defs */
.fortune-slip {
    width: 100%;
    height: 100%;
}

/* --- Fragment Orbit Positions & Animations --- */

/* Chamber 1 fragments */
.fragment-orbit-1 {
    top: 25%;
    right: 8%;
    animation: orbit1 90s linear infinite;
}

.fragment-orbit-2 {
    bottom: 20%;
    left: 6%;
    animation: orbit2 90s linear infinite;
}

/* Chamber 2 fragments */
.fragment-orbit-3 {
    top: 15%;
    right: 6%;
    animation: orbit3 90s linear infinite;
}

.fragment-orbit-4 {
    bottom: 18%;
    right: 12%;
    animation: orbit1 90s linear infinite reverse;
}

.fragment-orbit-5 {
    top: 50%;
    left: 5%;
    animation: orbit2 90s linear infinite;
}

/* Chamber 3 fragments */
.fragment-orbit-6 {
    top: 12%;
    left: 8%;
    animation: orbit3 90s linear infinite;
}

.fragment-orbit-7 {
    bottom: 15%;
    right: 5%;
    animation: orbit1 90s linear infinite;
}

/* Chamber 4 fragments */
.fragment-orbit-8 {
    top: 20%;
    right: 5%;
    animation: orbit2 90s linear infinite;
}

.fragment-orbit-9 {
    bottom: 22%;
    left: 8%;
    animation: orbit3 90s linear infinite reverse;
}

.fragment-orbit-10 {
    top: 55%;
    right: 10%;
    animation: orbit1 90s linear infinite;
}

/* Chamber 5 fragments */
.fragment-orbit-11 {
    top: 20%;
    right: 10%;
    animation: orbit2 90s linear infinite;
}

.fragment-orbit-12 {
    bottom: 25%;
    left: 10%;
    animation: orbit3 90s linear infinite;
}

/* Drift out effect for final chamber */
.fragment-drift-out.drifting .floating-fragment {
    transition: opacity 3s ease, transform 3s ease;
    opacity: 0 !important;
    transform: scale(1.3) translateY(-30px);
}

@keyframes orbit1 {
    0% { transform: translateX(0px) translateY(0px); }
    25% { transform: translateX(12px) translateY(-8px); }
    50% { transform: translateX(0px) translateY(-15px); }
    75% { transform: translateX(-12px) translateY(-8px); }
    100% { transform: translateX(0px) translateY(0px); }
}

@keyframes orbit2 {
    0% { transform: translateX(0px) translateY(0px); }
    25% { transform: translateX(-10px) translateY(10px); }
    50% { transform: translateX(5px) translateY(18px); }
    75% { transform: translateX(10px) translateY(5px); }
    100% { transform: translateX(0px) translateY(0px); }
}

@keyframes orbit3 {
    0% { transform: translateX(0px) translateY(0px); }
    25% { transform: translateX(8px) translateY(12px); }
    50% { transform: translateX(-5px) translateY(8px); }
    75% { transform: translateX(-10px) translateY(-5px); }
    100% { transform: translateX(0px) translateY(0px); }
}

/* --- SVG Ring Gradient (defined here as fallback, real one in HTML/JS) --- */

/* --- Entrance Animations --- */
.chamber .glass-panel {
    opacity: 0;
    transform: scale(0.92);
}

.chamber.active .glass-panel {
    opacity: 1;
    transform: scale(1);
}

.chamber-2 .glass-panel {
    transform: scale(0.92) translateX(40px);
}

.chamber-2.active .glass-panel {
    transform: scale(1) translateX(0);
}

.chamber-4 .glass-panel {
    transform: scale(0.92) translateX(-40px);
}

.chamber-4.active .glass-panel {
    transform: scale(1) translateX(0);
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .glass-panel {
        width: 90vw;
        height: 70vh;
        padding: 2rem 2.5rem;
    }

    .panel-large {
        width: 92vw;
        height: 75vh;
    }

    .panel-small {
        width: 85vw;
        height: 60vh;
    }

    .panel-offset-right,
    .panel-offset-left {
        margin-left: 0;
        margin-right: 0;
    }

    .panel-content {
        max-width: 80vw;
    }

    .nav-dots {
        right: 0.8rem;
    }

    .fragment-data {
        width: 18vw;
        min-width: 70px;
    }

    .fragment-glyph {
        width: 14vw;
        min-width: 50px;
    }
}

@media (max-width: 480px) {
    .glass-panel {
        padding: 1.5rem 1.5rem;
    }

    .chamber-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .chamber-title-final {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }
}
