/* ============================================
   dilemma.quest - Styles
   Horizontal moral journey experience
   ============================================ */

/* === CSS Custom Properties === */
:root {
    --molten-amber: #D4A03C;
    --abyssal-violet: #4A2D6B;
    --bone-fog: #E8E0D4;
    --void-ink: #0E0B16;
    --phantom-mist: #7A8594;
    --consequence-red: #C44536;
    --liminal-green: #3A7D5C;
}

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

html {
    overflow: hidden;
    height: 100vh;
    background: var(--void-ink);
}

body {
    height: 100vh;
    overflow: hidden;
    background: var(--void-ink);
    color: var(--bone-fog);
    font-family: 'Cormorant Garamond', serif;
}

/* === Opening Overlay === */
#opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--void-ink);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease;
}

#opening-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#opening-light {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--molten-amber);
    box-shadow: 0 0 40px 20px var(--molten-amber);
    opacity: 0;
    animation: lightAppear 0.5s ease-out 0.2s forwards;
}

@keyframes lightAppear {
    0% {
        width: 4px;
        height: 4px;
        opacity: 0;
    }
    100% {
        width: 80px;
        height: 80px;
        opacity: 1;
    }
}

#opening-corridor {
    position: absolute;
    width: 60%;
    height: 70%;
    opacity: 0;
    animation: corridorAppear 0.7s ease-out 0.7s forwards;
}

@keyframes corridorAppear {
    0% {
        opacity: 0;
        clip-path: circle(2% at 50% 50%);
    }
    100% {
        opacity: 1;
        clip-path: polygon(30% 0%, 70% 0%, 85% 100%, 15% 100%);
    }
}

.corridor-layer {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(212, 160, 60, 0.15);
    opacity: 0;
}

.corridor-layer[data-layer="1"] { animation: layerReveal 0.1s ease 1.2s forwards; inset: 5%; }
.corridor-layer[data-layer="2"] { animation: layerReveal 0.1s ease 1.3s forwards; inset: 10%; }
.corridor-layer[data-layer="3"] { animation: layerReveal 0.1s ease 1.4s forwards; inset: 15%; }
.corridor-layer[data-layer="4"] { animation: layerReveal 0.1s ease 1.5s forwards; inset: 20%; }
.corridor-layer[data-layer="5"] { animation: layerReveal 0.1s ease 1.6s forwards; inset: 25%; }
.corridor-layer[data-layer="6"] { animation: layerReveal 0.1s ease 1.7s forwards; inset: 30%; }

@keyframes layerReveal {
    to { opacity: 1; }
}

#opening-floor-text {
    position: absolute;
    bottom: 25%;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(24px, 4vw, 56px);
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--bone-fog);
    transform: perspective(800px) rotateX(60deg);
    opacity: 0;
    animation: floorTextAppear 0.8s ease 1.4s forwards;
}

@keyframes floorTextAppear {
    to { opacity: 0.7; }
}

#opening-fork {
    position: absolute;
    top: 15%;
    width: 40%;
    height: 30%;
    display: flex;
    gap: 10%;
    opacity: 0;
    animation: forkAppear 0.8s ease 2.0s forwards;
}

@keyframes forkAppear {
    to { opacity: 1; }
}

.fork-left {
    flex: 1;
    background: radial-gradient(ellipse at center, var(--molten-amber), transparent 70%);
    opacity: 0.6;
    animation: forkPulse 3s ease-in-out infinite;
}

.fork-right {
    flex: 1;
    background: radial-gradient(ellipse at center, var(--abyssal-violet), transparent 70%);
    opacity: 0.6;
    animation: forkPulse 3s ease-in-out infinite 1.5s;
}

@keyframes forkPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

#scroll-hint {
    position: absolute;
    bottom: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0;
    animation: hintAppear 1s ease 3.0s forwards;
}

#scroll-hint span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--phantom-mist);
    opacity: 0.6;
    letter-spacing: 0.1em;
}

#scroll-hint svg {
    overflow: visible;
}

#scroll-hint-path {
    animation: drawPath 2s ease 3.2s forwards;
}

@keyframes drawPath {
    to { stroke-dashoffset: 0; }
}

@keyframes hintAppear {
    to { opacity: 1; }
}

/* === Shadow Counter === */
#shadow-counter {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
    background: rgba(14, 11, 22, 0.5);
    border-radius: 8px;
    padding: 6px;
    backdrop-filter: blur(4px);
}

#shadow-counter.visible {
    opacity: 1;
}

#shadow-counter-svg {
    display: block;
}

/* === Progress Bar === */
#progress-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: min(400px, 80vw);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#progress-bar.visible {
    opacity: 1;
}

#progress-svg {
    width: 100%;
    height: 30px;
}

/* === Scroll Container === */
#scroll-container {
    display: flex;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#scroll-container::-webkit-scrollbar {
    display: none;
}

#scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === Panels === */
.panel {
    flex: 0 0 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

.panel-transition {
    flex: 0 0 50vw;
    background: var(--void-ink);
}

/* === Corridor Scene (Opening & Terminal) === */
.corridor-scene {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 800px;
    background: var(--void-ink);
    position: relative;
}

.corridor-depth {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.corridor-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) translateZ(calc(var(--i) * -60px));
    width: calc(90% - var(--i) * 6%);
    height: calc(85% - var(--i) * 5.5%);
    border: 1px solid rgba(212, 160, 60, calc(0.25 - var(--i) * 0.018));
    background: transparent;
    transition: border-color 0.5s ease;
}

.corridor-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 48%,
        rgba(122, 133, 148, 0.05) 48%,
        rgba(122, 133, 148, 0.05) 52%,
        transparent 52%
    );
}

.corridor-floor-text {
    position: absolute;
    bottom: 22%;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(28px, 5vw, 72px);
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--bone-fog);
    transform: perspective(800px) rotateX(60deg);
    opacity: 0.5;
    text-shadow: 0 0 30px rgba(212, 160, 60, 0.3);
}

.corridor-fork-glow {
    position: absolute;
    top: 20%;
    width: 40%;
    height: 25%;
    display: flex;
    gap: 15%;
    z-index: 2;
}

.fork-glow-left {
    flex: 1;
    background: radial-gradient(ellipse at center, rgba(212, 160, 60, 0.4), transparent 70%);
    animation: forkPulse 3s ease-in-out infinite;
}

.fork-glow-right {
    flex: 1;
    background: radial-gradient(ellipse at center, rgba(74, 45, 107, 0.5), transparent 70%);
    animation: forkPulse 3s ease-in-out infinite 1.5s;
}

/* === Terminal Panel === */
.corridor-terminal {
    flex-direction: column;
}

.terminal-ring {
    border-color: rgba(122, 133, 148, calc(0.15 - var(--i) * 0.01)) !important;
}

.terminal-text {
    position: absolute;
    z-index: 5;
    text-align: center;
    max-width: 600px;
    padding: 0 20px;
}

.terminal-message {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(28px, 5vw, 64px);
    font-weight: 600;
    color: var(--bone-fog);
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.terminal-submessage {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(16px, 2.5vw, 24px);
    font-weight: 300;
    font-style: italic;
    color: var(--phantom-mist);
    line-height: 1.5;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.4s, transform 1s ease 0.4s;
}

.panel-terminal.in-view .terminal-message,
.panel-terminal.in-view .terminal-submessage {
    opacity: 1;
    transform: translateY(0);
}

#ghost-forks {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.ghost-fork {
    position: absolute;
    width: 80px;
    height: 120px;
    opacity: 0.15;
}

.ghost-fork svg {
    width: 100%;
    height: 100%;
}

/* === Transition Zones === */
.membrane-layers {
    position: absolute;
    inset: 0;
}

.membrane-layer {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.membrane-layer[style*="--depth:1"] {
    background: linear-gradient(135deg, rgba(74, 45, 107, 0.15), transparent 60%);
}

.membrane-layer[style*="--depth:2"] {
    background: linear-gradient(225deg, rgba(212, 160, 60, 0.1), transparent 60%);
}

.membrane-layer[style*="--depth:3"] {
    background: radial-gradient(ellipse at 30% 70%, rgba(58, 125, 92, 0.12), transparent 60%);
}

.membrane-layer[style*="--depth:4"] {
    background: radial-gradient(ellipse at 70% 30%, rgba(196, 69, 54, 0.08), transparent 60%);
}

.panel-transition.in-view .membrane-layer[style*="--depth:1"] { opacity: 1; transition-delay: 0s; }
.panel-transition.in-view .membrane-layer[style*="--depth:2"] { opacity: 1; transition-delay: 0.1s; }
.panel-transition.in-view .membrane-layer[style*="--depth:3"] { opacity: 1; transition-delay: 0.2s; }
.panel-transition.in-view .membrane-layer[style*="--depth:4"] { opacity: 1; transition-delay: 0.3s; }

.membrane-noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* === Dilemma Panels === */
.panel-dilemma {
    background: var(--void-ink);
}

.dilemma-scene {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fork-visual {
    position: absolute;
    inset: 0;
    z-index: 1;
    opacity: 0.3;
    pointer-events: none;
}

.fork-svg {
    width: 100%;
    height: 100%;
}

/* === Bento Grid === */
.bento-grid {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    width: min(900px, 85vw);
    height: min(600px, 75vh);
    padding: 30px;
}

.bento-scenario {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 32px;
    background: rgba(14, 11, 22, 0.6);
    border: 1px solid rgba(122, 133, 148, 0.15);
    border-radius: 4px;
    backdrop-filter: blur(6px);
}

.dilemma-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(32px, 6vw, 80px);
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--bone-fog);
    margin-bottom: 16px;
}

.dilemma-description {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(16px, 2vw, 22px);
    font-weight: 300;
    font-style: italic;
    line-height: 1.6;
    color: var(--bone-fog);
    opacity: 0.85;
}

/* === Choice Cards === */
.bento-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 28px;
    border-radius: 4px;
    cursor: pointer;
    transition:
        transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 200ms ease,
        filter 200ms ease,
        border-color 300ms ease;
    border: 1px solid rgba(122, 133, 148, 0.2);
    background: rgba(14, 11, 22, 0.5);
    backdrop-filter: blur(4px);
}

.choice-left {
    border-left: 3px solid var(--molten-amber);
}

.choice-right {
    border-right: 3px solid var(--abyssal-violet);
}

.bento-choice:hover {
    transform: scale(1.03);
}

.bento-choice.dimmed {
    opacity: 0.4;
    filter: saturate(0.3);
}

.choice-label {
    font-family: 'Anybody', sans-serif;
    font-size: clamp(18px, 2.5vw, 28px);
    font-weight: 600;
    color: var(--bone-fog);
    margin-bottom: 10px;
    line-height: 1.3;
}

.choice-left .choice-label {
    color: var(--molten-amber);
}

.choice-right .choice-label {
    color: #8B6DB5;
    text-shadow: 0 0 20px rgba(74, 45, 107, 0.5);
}

.choice-subtext {
    font-family: 'Anybody', sans-serif;
    font-size: clamp(13px, 1.5vw, 16px);
    font-weight: 400;
    color: var(--phantom-mist);
    line-height: 1.5;
}

/* === Consequence Orbs === */
.consequence-orb {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: min(320px, 30vw);
    height: min(320px, 30vw);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 600ms ease, transform 600ms ease;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.choice-left .consequence-orb {
    background: radial-gradient(circle at center, rgba(196, 69, 54, 0.25), transparent 70%);
    mix-blend-mode: screen;
}

.choice-right .consequence-orb {
    background: radial-gradient(circle at center, rgba(196, 69, 54, 0.25), transparent 70%);
    mix-blend-mode: screen;
}

.bento-choice.orb-visible .consequence-orb {
    opacity: 1;
    transform: translate(-50%, -120%);
}

.orb-inner {
    max-width: 75%;
    text-align: center;
}

.consequence-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(14px, 1.5vw, 18px);
    font-weight: 300;
    font-style: italic;
    color: var(--consequence-red);
    line-height: 1.6;
}

/* === Choice Counter (JetBrains Mono) === */
.choice-counter-label {
    position: fixed;
    bottom: 50px;
    right: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    color: var(--phantom-mist);
    opacity: 0.6;
    z-index: 100;
    letter-spacing: 0.05em;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 12px;
        padding: 16px;
        width: 92vw;
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .bento-scenario {
        padding: 16px 20px;
    }

    .bento-choice {
        padding: 18px 20px;
    }

    .consequence-orb {
        width: min(250px, 70vw);
        height: min(250px, 70vw);
    }

    .corridor-floor-text {
        bottom: 15%;
    }

    #shadow-counter {
        top: 10px;
        right: 10px;
    }

    #shadow-counter-svg {
        width: 50px;
        height: 50px;
    }

    .terminal-text {
        padding: 0 30px;
    }
}

@media (max-width: 480px) {
    .dilemma-title {
        font-size: clamp(24px, 8vw, 40px);
    }

    .dilemma-description {
        font-size: 15px;
    }

    .choice-label {
        font-size: 16px;
    }

    .choice-subtext {
        font-size: 13px;
    }
}

/* === Entrance Animations for Dilemma Panels === */
.panel-dilemma .bento-scenario,
.panel-dilemma .bento-choice {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.panel-dilemma.in-view .bento-scenario {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}

.panel-dilemma.in-view .choice-left {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.3s;
}

.panel-dilemma.in-view .choice-right {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.5s;
}

.panel-dilemma.in-view .choice-left.dimmed {
    opacity: 0.4;
}

.panel-dilemma.in-view .choice-right.dimmed {
    opacity: 0.4;
}

/* Ensure hover still works after in-view */
.panel-dilemma.in-view .bento-choice:hover {
    transform: scale(1.03);
}
