/* ======================================
   dilemma.studio v2 - Surreal Dreamscape
   ====================================== */

/* --- Custom Properties --- */
:root {
    --twilight-indigo: #2B2D42;
    --magritte-sky: #8ECAE6;
    --paradox-coral: #E07A5F;
    --liminal-gold: #D4A843;
    --dreamfield-cream: #F0EFEB;
    --void-plum: #1B0A2E;
    --dissolve-gray: #8D99AE;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --font-accent: 'Inconsolata', monospace;

    --seam-opacity: 0.8;
    --layer-depth: 0;
    --fork-side: 0;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 1.75;
    color: var(--dreamfield-cream);
    background-color: var(--void-plum);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Dual Shadow System --- */
.dual-shadow,
.fork-inner,
.gallery-card,
.convergence-contact {
    box-shadow:
        8px 8px 24px rgba(43, 45, 66, 0.3),
        -6px -6px 20px rgba(142, 202, 230, 0.2);
}

/* --- The Seam (recurring golden line) --- */
.seam {
    position: absolute;
    background: var(--liminal-gold);
    box-shadow: 0 0 12px var(--liminal-gold), 0 0 24px rgba(212, 168, 67, 0.3);
    animation: seam-pulse 4s ease-in-out infinite;
    z-index: 10;
    pointer-events: none;
}

.seam--vertical {
    width: 2px;
    height: 100%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

.seam--horizontal {
    height: 2px;
    width: 100%;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.seam--diagonal {
    width: 2px;
    height: 140%;
    left: 50%;
    top: -20%;
    transform: translateX(-50%) rotate(7deg);
}

@keyframes seam-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1.0; }
}

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

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

#intro-gradient-warm,
#intro-gradient-cool {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.7s ease;
}

#intro-gradient-warm {
    background: radial-gradient(ellipse at 35% 50%, var(--paradox-coral) 0%, transparent 70%);
    mix-blend-mode: screen;
}

#intro-gradient-cool {
    background: radial-gradient(ellipse at 65% 50%, var(--magritte-sky) 0%, transparent 70%);
    mix-blend-mode: screen;
}

#intro-gradient-warm.visible,
#intro-gradient-cool.visible {
    opacity: 0.7;
}

#intro-title {
    position: relative;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(40px, 8vw, 120px);
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    display: flex;
    gap: 0.3em;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#intro-title.visible {
    opacity: 1;
}

#intro-dilemma {
    transform: translateX(-30px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#intro-studio {
    font-weight: 300;
    font-style: italic;
    transform: translateX(30px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#intro-title.visible #intro-dilemma,
#intro-title.visible #intro-studio {
    transform: translateX(0);
}

#intro-seam {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 0%;
    background: var(--liminal-gold);
    box-shadow: 0 0 12px var(--liminal-gold);
    transform: translateX(-50%);
    transition: height 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 3;
}

#intro-seam.visible {
    height: 100%;
}

/* --- Floating Fragments --- */
#floating-fragments {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.fragment {
    position: absolute;
    left: var(--x-start);
    top: var(--y-start);
    width: 60px;
    height: 60px;
    opacity: 0;
    animation: float-drift var(--duration) var(--delay) ease-in-out infinite;
}

.fragment-triangle {
    background: var(--paradox-coral);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.fragment-circle {
    background: var(--magritte-sky);
    border-radius: 50%;
}

.fragment-rect {
    background: var(--liminal-gold);
    border-radius: 0 12px 0 12px;
    width: 80px;
    height: 40px;
}

@keyframes float-drift {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    8% {
        opacity: 0.08;
    }
    20% {
        transform: translate(25px, -40px) rotate(30deg);
        opacity: 0.07;
    }
    40% {
        transform: translate(-15px, -80px) rotate(75deg);
        opacity: 0.06;
    }
    60% {
        transform: translate(30px, -50px) rotate(150deg);
        opacity: 0.07;
    }
    80% {
        transform: translate(-10px, -20px) rotate(270deg);
        opacity: 0.06;
    }
    92% {
        opacity: 0.08;
    }
    100% {
        transform: translate(0, 0) rotate(360deg);
        opacity: 0;
    }
}

/* --- Escher Grid Overlay --- */
#escher-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    opacity: 1;
}

/* --- Section 1: Threshold --- */
#threshold {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    isolation: isolate;
}

.threshold-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120%;
    will-change: transform;
}

#threshold-layer-back {
    z-index: 1;
}

#threshold-layer-front {
    z-index: 2;
    mix-blend-mode: difference;
}

.threshold-gradient--warm {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 40%, var(--paradox-coral) 0%, var(--void-plum) 70%);
    opacity: 0.8;
}

.threshold-gradient--cool {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 70% 60%, var(--magritte-sky) 0%, var(--twilight-indigo) 70%);
    opacity: 0.7;
}

#threshold-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    text-align: center;
}

#studio-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(32px, 6vw, 96px);
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.1;
}

.title-dilemma {
    text-shadow:
        3px 3px 12px rgba(43, 45, 66, 0.3),
        -3px -3px 10px rgba(142, 202, 230, 0.2),
        0 0 40px rgba(224, 122, 95, 0.4);
}

.title-studio {
    font-weight: 300;
    font-style: italic;
    text-shadow:
        3px 3px 12px rgba(43, 45, 66, 0.3),
        -3px -3px 10px rgba(142, 202, 230, 0.2),
        0 0 40px rgba(142, 202, 230, 0.4);
}

.studio-tagline {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(14px, 1.1vw, 18px);
    color: var(--dissolve-gray);
    margin-top: 1.5em;
    letter-spacing: 0.05em;
}

#scroll-affordance {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    text-align: center;
    animation: affordance-bob 2.5s ease-in-out infinite;
    cursor: pointer;
}

.affordance-text {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: 14px;
    color: var(--liminal-gold);
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 8px;
}

.affordance-chevron {
    display: flex;
    justify-content: center;
}

@keyframes affordance-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* --- Section 2: Corridor of Forks --- */
#corridor {
    position: relative;
    z-index: 3;
}

.fork-section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    isolation: isolate;
}

.fork-section[data-fork="1"] {
    background: linear-gradient(175deg, var(--void-plum) 0%, var(--twilight-indigo) 100%);
    clip-path: polygon(0 0, 100% 3%, 100% 97%, 0 100%);
}

.fork-section[data-fork="2"] {
    background: linear-gradient(185deg, var(--twilight-indigo) 0%, var(--void-plum) 100%);
    clip-path: polygon(0 3%, 100% 0, 100% 100%, 0 97%);
    margin-top: -40px;
}

.fork-section[data-fork="3"] {
    background: linear-gradient(175deg, var(--void-plum) 0%, var(--twilight-indigo) 100%);
    clip-path: polygon(0 0, 100% 3%, 100% 100%, 0 97%);
    margin-top: -40px;
}

.fork-content {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 100vh;
    align-items: center;
}

.fork-half {
    width: 50%;
    padding: 80px 40px;
    position: relative;
    z-index: 2;
}

/* Fork halves slide in from diagonal directions */
.fork-half--left {
    transform: translate(-60px, -30px);
    opacity: 0;
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.9s ease;
}

.fork-half--right {
    transform: translate(60px, 30px);
    opacity: 0;
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s,
                opacity 0.9s ease 0.2s;
}

.fork-section.in-view .fork-half--left {
    transform: translate(0, 0);
    opacity: 1;
}

.fork-section.in-view .fork-half--right {
    transform: translate(0, 0);
    opacity: 1;
}

/* Asymmetric overlap: elements bleed 15-20% into each other's territory */
.fork-half--left {
    margin-right: -15%;
}

.fork-half--right {
    margin-left: -15%;
}

.fork-inner {
    max-width: 480px;
    padding: 48px;
    background: rgba(27, 10, 46, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 168, 67, 0.1);
    border-radius: 4px;
    position: relative;
}

.fork-half--left .fork-inner {
    margin-left: auto;
}

.fork-half--right .fork-inner {
    margin-right: auto;
}

.fork-label {
    font-family: var(--font-accent);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 16px;
}

.fork-half--left .fork-label {
    color: var(--paradox-coral);
}

.fork-half--right .fork-label {
    color: var(--magritte-sky);
}

.fork-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(24px, 3vw, 44px);
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    margin-bottom: 20px;
    line-height: 1.2;
}

.fork-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(15px, 1.1vw, 18px);
    line-height: 1.75;
    color: var(--dissolve-gray);
}

/* Fork Visual Planes */
.fork-visual {
    margin-top: 32px;
    height: 200px;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

.fork-visual--warm {
    background: linear-gradient(135deg, rgba(224, 122, 95, 0.15) 0%, rgba(212, 168, 67, 0.1) 100%);
}

.fork-visual--cool {
    background: linear-gradient(135deg, rgba(142, 202, 230, 0.15) 0%, rgba(43, 45, 66, 0.1) 100%);
}

.visual-plane {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 1px solid;
    transition: transform 0.6s ease;
}

.visual-plane--a {
    border-color: rgba(224, 122, 95, 0.3);
    background: rgba(224, 122, 95, 0.05);
    top: 20%;
    left: 20%;
    transform: rotate(12deg);
    border-radius: 2px;
    box-shadow:
        6px 6px 16px rgba(43, 45, 66, 0.3),
        -4px -4px 12px rgba(142, 202, 230, 0.2);
}

.visual-plane--b {
    border-color: rgba(142, 202, 230, 0.3);
    background: rgba(142, 202, 230, 0.05);
    top: 15%;
    right: 20%;
    transform: rotate(-8deg);
    border-radius: 50%;
    box-shadow:
        6px 6px 16px rgba(43, 45, 66, 0.3),
        -4px -4px 12px rgba(142, 202, 230, 0.2);
}

.fork-visual::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 80%;
    background: var(--liminal-gold);
    opacity: 0.2;
    transform: translate(-50%, -50%) rotate(7deg);
    box-shadow: 0 0 8px rgba(212, 168, 67, 0.2);
}

/* Distortion Zones */
.distortion-zone {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100px;
    z-index: 8;
    pointer-events: none;
    backdrop-filter: blur(var(--distortion-blur, 2px)) saturate(1.3);
    -webkit-backdrop-filter: blur(var(--distortion-blur, 2px)) saturate(1.3);
    mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 30%, black 70%, transparent);
}

.distortion-zone--top {
    top: 0;
}

.distortion-zone--bottom {
    bottom: 0;
}

/* --- Section 3: The Impossible Gallery --- */
#gallery-wrapper {
    position: relative;
    z-index: 3;
    /* Height = gallery viewport height + enough room for horizontal scroll */
    height: 300vh;
    background: linear-gradient(180deg, var(--twilight-indigo) 0%, var(--void-plum) 100%);
}

#gallery {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-header {
    text-align: center;
    padding: 80px 40px 40px;
    flex-shrink: 0;
}

.section-counter {
    font-family: var(--font-accent);
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--liminal-gold);
    display: block;
    margin-bottom: 16px;
}

.gallery-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 64px);
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    margin-bottom: 16px;
}

.gallery-subtitle {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(16px, 1.5vw, 22px);
    color: var(--dissolve-gray);
}

#gallery-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    perspective: 1200px;
}

#gallery-track {
    display: flex;
    gap: 60px;
    padding: 40px 80px 120px;
    width: max-content;
    transform-style: preserve-3d;
    will-change: transform;
    height: 100%;
    align-items: center;
}

.gallery-item {
    flex: 0 0 380px;
    transform: translateZ(var(--z-depth));
    transition: opacity 0.5s ease;
}

.gallery-card {
    background: rgba(27, 10, 46, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 168, 67, 0.12);
    border-radius: 6px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.gallery-card:hover {
    box-shadow:
        12px 12px 32px rgba(43, 45, 66, 0.4),
        -8px -8px 28px rgba(142, 202, 230, 0.25),
        0 0 20px rgba(212, 168, 67, 0.15);
}

.gallery-card-visual {
    width: 100%;
    height: 260px;
    position: relative;
}

.gallery-card-visual::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--liminal-gold);
    box-shadow: 0 0 8px var(--liminal-gold);
    animation: seam-pulse 4s ease-in-out infinite;
}

.gallery-card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    padding: 24px 28px 8px;
}

.gallery-card-desc {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 14px;
    color: var(--dissolve-gray);
    padding: 0 28px 28px;
    line-height: 1.6;
}

/* Gallery progress indicator */
.gallery-progress {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 10;
}

.gallery-progress-bar {
    width: 120px;
    height: 2px;
    background: rgba(141, 153, 174, 0.3);
    border-radius: 1px;
    overflow: hidden;
}

.gallery-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--liminal-gold);
    box-shadow: 0 0 6px rgba(212, 168, 67, 0.4);
    transition: width 0.3s ease;
}

/* --- Section 4: The Convergence --- */
#convergence {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    isolation: isolate;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.convergence-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 1.2s ease, background 1.2s ease;
}

#convergence-layer-warm {
    background: radial-gradient(ellipse at 35% 50%, var(--paradox-coral) 0%, transparent 60%);
    opacity: 0.4;
    z-index: 1;
}

#convergence-layer-cool {
    background: radial-gradient(ellipse at 65% 50%, var(--magritte-sky) 0%, transparent 60%);
    opacity: 0.4;
    mix-blend-mode: screen;
    z-index: 2;
}

#convergence-content {
    position: relative;
    z-index: 5;
    text-align: center;
    max-width: 700px;
    padding: 40px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
}

#convergence.in-view #convergence-content {
    opacity: 1;
    transform: translateY(0);
}

.convergence-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 60px);
    letter-spacing: 0.03em;
    color: var(--dreamfield-cream);
    margin-bottom: 48px;
    line-height: 1.3;
    text-shadow:
        4px 4px 16px rgba(43, 45, 66, 0.3),
        -3px -3px 12px rgba(142, 202, 230, 0.2);
}

.convergence-contact {
    background: rgba(27, 10, 46, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 168, 67, 0.15);
    border-radius: 6px;
    padding: 48px;
    margin-bottom: 48px;
}

.contact-line {
    margin-bottom: 24px;
}

.contact-line:last-child {
    margin-bottom: 0;
}

.contact-label {
    display: block;
    font-family: var(--font-accent);
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--liminal-gold);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.contact-link {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(20px, 2.5vw, 32px);
    color: var(--paradox-coral);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    position: relative;
    display: inline-block;
}

.contact-link:hover {
    color: var(--dreamfield-cream);
    text-shadow: 0 0 20px rgba(224, 122, 95, 0.5);
}

.contact-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--liminal-gold);
    box-shadow: 0 0 8px var(--liminal-gold);
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.contact-link:hover::after {
    width: 100%;
}

.contact-value {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(16px, 1.5vw, 22px);
    color: var(--dissolve-gray);
}

.convergence-footer {
    font-family: var(--font-accent);
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--dissolve-gray);
    display: flex;
    justify-content: center;
    gap: 16px;
    align-items: center;
}

.footer-seam {
    color: var(--liminal-gold);
    opacity: 0.5;
}

/* --- Convergence Merge Animation --- */
#convergence.merging #convergence-layer-warm {
    opacity: 0.7;
    background: radial-gradient(ellipse at 50% 50%, var(--paradox-coral) 0%, transparent 60%);
}

#convergence.merging #convergence-layer-cool {
    opacity: 0.7;
    background: radial-gradient(ellipse at 50% 50%, var(--magritte-sky) 0%, transparent 60%);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .fork-content {
        flex-direction: column;
    }

    .fork-half {
        width: 100%;
        padding: 40px 24px;
    }

    .fork-half--left,
    .fork-half--right {
        margin-left: 0;
        margin-right: 0;
    }

    .fork-half--left .fork-inner,
    .fork-half--right .fork-inner {
        margin: 0 auto;
        max-width: 100%;
    }

    .fork-inner {
        padding: 32px 24px;
    }

    #gallery-track {
        padding: 40px 24px 80px;
        gap: 30px;
    }

    .gallery-item {
        flex: 0 0 300px;
    }

    .gallery-header {
        padding: 60px 24px 30px;
    }

    .convergence-contact {
        padding: 32px 24px;
    }

    .fork-section[data-fork="1"],
    .fork-section[data-fork="2"],
    .fork-section[data-fork="3"] {
        clip-path: none;
        margin-top: 0;
    }

    #gallery-wrapper {
        height: 200vh;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(212, 168, 67, 0.3);
    color: var(--dreamfield-cream);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--void-plum);
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 67, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 168, 67, 0.5);
}
