/* ============================================
   dilemma.dev - Styles
   Surreal Decision Theater
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --void-black: #0A0A0F;
    --left-warm: #E8D5B7;
    --right-cool: #B7D5E8;
    --spine-gold: #C9A84C;
    --fog-gray: #7B6F63;
    --deep-indigo: #1A1A3E;
    --ember-rose: #8B3A4A;
    --smoke: #C4B8A8;
    --pure-black: #000000;

    --font-display: 'Instrument Serif', serif;
    --font-body: 'Hanken Grotesk', sans-serif;
    --font-mono: 'Azeret Mono', monospace;

    --spring-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--void-black);
    color: var(--smoke);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    letter-spacing: 0.01em;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Navigation Glyph --- */
#nav-glyph {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#nav-glyph svg {
    animation: glyphRotate 12s ease-in-out infinite;
    transition: transform 0.4s var(--spring-ease);
}

#nav-glyph:hover svg {
    transform: scale(1.2);
}

.nav-label {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fog-gray);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s var(--spring-ease);
    white-space: nowrap;
    pointer-events: none;
}

.nav-label-left {
    right: 60px;
    color: var(--left-warm);
    transform: translateX(10px);
}

.nav-label-right {
    left: 60px;
    color: var(--right-cool);
    transform: translateX(-10px);
}

#nav-glyph:hover .nav-label {
    opacity: 0.8;
    transform: translateX(0);
}

@keyframes glyphRotate {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}

/* --- Global Spine SVG --- */
#spine-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0.15;
}

/* --- Chamber Base --- */
.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--void-black);
}

.chamber:nth-child(even) {
    background-color: var(--deep-indigo);
}

/* Reset for sections (chambers are children of body along with other elements) */
#chamber-1 { background-color: var(--void-black); }
#chamber-2 { background-color: var(--void-black); }
#chamber-3 { background-color: var(--deep-indigo); }
#chamber-4 { background-color: var(--void-black); }
#chamber-5 { background-color: var(--void-black); }

/* --- Background Text (ghostly conjunctions) --- */
.chamber-bg-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 30vw;
    font-weight: 400;
    color: var(--smoke);
    opacity: 0.025;
    pointer-events: none;
    user-select: none;
    line-height: 1;
    z-index: 1;
}

/* --- Moiré Interference Patterns --- */
.moire {
    position: absolute;
    top: -50%;
    width: 150%;
    height: 200%;
    pointer-events: none;
    z-index: 2;
    opacity: 0.08;
}

.moire-left {
    left: -75%;
    background-image:
        repeating-radial-gradient(circle at center, transparent 0px, transparent 3.5px, rgba(201, 168, 76, 0.08) 4px, transparent 4.5px);
}

.moire-right {
    right: -75%;
    left: auto;
    background-image:
        repeating-radial-gradient(circle at center, transparent 0px, transparent 3.5px, rgba(201, 168, 76, 0.08) 4px, transparent 4.5px);
}

.moire-dense {
    opacity: 0.14;
}

/* --- Chamber Content --- */
.chamber-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1400px;
    padding: 0 40px;
}

/* --- Chamber Spine Lines --- */
.chamber-spine {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    z-index: 6;
    pointer-events: none;
}

.spine-thick {
    width: 4px;
}

.spine-thick line {
    animation: spinePulse 3s ease-in-out infinite;
}

@keyframes spinePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================
   CHAMBER 1: Opening
   ============================================ */
.chamber-1-content {
    text-align: center;
    opacity: 0;
    animation: fadeInContent 1.2s ease 0.8s forwards;
}

.title-split {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    margin-bottom: 2rem;
}

.title-left,
.title-right {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.8rem, 8vw, 8rem);
    letter-spacing: -0.02em;
    line-height: 1.0;
}

.title-left {
    color: var(--left-warm);
    animation: breatheLeft 4s ease-in-out infinite;
}

.title-right {
    color: var(--right-cool);
    animation: breatheRight 4s ease-in-out infinite;
}

@keyframes breatheLeft {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.005); }
}

@keyframes breatheRight {
    0%, 100% { transform: scale(1.005); }
    50% { transform: scale(1.0); }
}

.tagline {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    color: var(--fog-gray);
    opacity: 0;
    animation: fadeInTagline 1s ease 2s forwards;
}

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

@keyframes fadeInTagline {
    from { opacity: 0; }
    to { opacity: 0.7; }
}

/* Background fork glyph */
.bg-fork-glyph {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40vw;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Opening spine animation */
#opening-spine {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawSpine 1.5s ease 0.6s forwards;
    filter: drop-shadow(0 0 12px rgba(201, 168, 76, 0.25));
}

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

/* ============================================
   CHAMBER 2: The Fork
   ============================================ */
.chamber-branches {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.branch {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.5s ease;
}

.branch.animate-in {
    stroke-dashoffset: 0;
}

.branch-terminus {
    animation: terminusPulse 2s ease-in-out infinite;
}

@keyframes terminusPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Split content layout */
.split-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 80px;
    width: 100%;
}

.split-left {
    flex: 1;
    max-width: 35vw;
    text-align: right;
    padding-right: 40px;
}

.split-right {
    flex: 1;
    max-width: 35vw;
    text-align: left;
    padding-left: 40px;
}

.choice-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fog-gray);
    margin-bottom: 1.2rem;
}

.split-heading {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.heading-warm { color: var(--left-warm); }
.heading-cool { color: var(--right-cool); }

.split-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
}

.body-warm { color: rgba(200, 184, 168, 0.85); }
.body-cool { color: rgba(200, 184, 168, 0.85); }

/* Split content entrance animations */
.split-left,
.split-right {
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s var(--spring-ease);
}

.split-left {
    transform: translateX(-60px);
}

.split-right {
    transform: translateX(60px);
}

.split-left.animate-in {
    opacity: 1;
    transform: translateX(0);
}

.split-right.animate-in {
    opacity: 1;
    transform: translateX(0);
}

/* Big conjunction (OR, IF, etc.) */
.big-conjunction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 4;
}

.big-or {
    font-size: 12vw;
    color: var(--smoke);
    opacity: 0.06;
    animation: slowRotate 60s linear infinite;
}

.big-if {
    font-size: 40vw;
    color: var(--smoke);
    opacity: 0.02;
}

@keyframes slowRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   CHAMBER 3: The Weight (Inverted)
   ============================================ */
.chamber-inverted .split-left .heading-warm { color: var(--right-cool); }
.chamber-inverted .split-right .heading-cool { color: var(--left-warm); }

.aphorism-list {
    list-style: none;
    padding: 0;
}

.aphorism-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 1.8rem;
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.15vw, 1.1rem);
    line-height: 1.6;
}

.split-left .aphorism-list li {
    justify-content: flex-end;
    text-align: right;
    flex-direction: row-reverse;
}

.aphorism-cool li {
    color: var(--right-cool);
    opacity: 0.85;
}

.aphorism-warm li {
    color: var(--left-warm);
    opacity: 0.85;
}

.aphorism-glyph {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

/* ============================================
   CHAMBER 4: The Recursion
   ============================================ */
.chamber-tree {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.tree-branch {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.2s ease;
}

.tree-branch.animate-in {
    stroke-dashoffset: 0;
}

/* Flip Cards */
.flip-cards-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.flip-card {
    position: absolute;
    left: var(--card-x);
    top: var(--card-y);
    width: 180px;
    height: 240px;
    perspective: 600px;
    pointer-events: auto;
    transform: translateX(-50%) translateY(-50%);
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: cardSpin 20s linear infinite;
    animation-delay: var(--card-delay);
}

@keyframes cardSpin {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: 1px solid var(--spine-gold);
    background: rgba(10, 10, 15, 0.9);
    text-align: center;
}

.flip-card-back {
    transform: rotateY(180deg);
}

.card-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--spine-gold);
    margin-bottom: 12px;
}

.flip-card-front p,
.flip-card-back p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--smoke);
    opacity: 0.9;
}

/* ============================================
   CHAMBER 5: The Resolution That Isn't
   ============================================ */
.chamber-final {
    background: linear-gradient(to bottom, var(--void-black) 0%, var(--pure-black) 100%);
}

.chamber-converge {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.converge-branch {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease;
}

.converge-branch.animate-in {
    stroke-dashoffset: 0;
}

.converge-spine {
    opacity: 0;
    transition: opacity 1s ease 0.8s;
}

.converge-spine.animate-in {
    opacity: 1;
}

.chamber-5-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding-top: 15vh;
}

.closing-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--spine-gold);
    opacity: 0;
    transition: opacity 1.5s ease;
}

.closing-text.animate-in {
    opacity: 0.9;
}

/* Final fade overlay */
.final-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to bottom, transparent, var(--pure-black));
    z-index: 20;
    pointer-events: none;
}

/* ============================================
   Morph Transition Effect (clip-path)
   ============================================ */
.chamber .split-left {
    clip-path: inset(0);
    transition: clip-path 0.6s ease, opacity 0.8s ease, transform 0.8s var(--spring-ease);
}

.chamber .split-right {
    clip-path: inset(0);
    transition: clip-path 0.9s ease, opacity 0.8s ease, transform 0.8s var(--spring-ease);
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 900px) {
    .split-content {
        flex-direction: column;
        gap: 40px;
        align-items: center;
    }

    .split-left,
    .split-right {
        max-width: 85vw;
        text-align: center;
        padding: 0 20px;
    }

    .split-left .aphorism-list li {
        justify-content: center;
        text-align: center;
        flex-direction: row;
    }

    .split-left {
        transform: translateY(-30px);
    }

    .split-right {
        transform: translateY(30px);
    }

    .flip-card {
        width: 140px;
        height: 190px;
    }

    .title-split {
        flex-direction: row;
    }

    .big-or {
        font-size: 20vw;
    }

    .big-if {
        font-size: 50vw;
    }
}

@media (max-width: 600px) {
    .chamber-content {
        padding: 0 20px;
    }

    .flip-card {
        width: 120px;
        height: 160px;
    }

    .flip-card-front p,
    .flip-card-back p {
        font-size: 0.75rem;
    }

    .split-heading {
        font-size: clamp(1.3rem, 5vw, 1.8rem);
    }
}

/* ============================================
   Utility / Global Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Prevent FOUC */
body {
    opacity: 0;
    animation: fadeIn 0.5s ease 0.1s forwards;
}
