/* ============================================
   dilemma.studio - Twilight Bifurcation
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0D0A14;
    color: #E8E0D4;
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    font-feature-settings: 'onum' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Background Atmosphere (z-index: 0) --- */
#bg-atmosphere {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(180deg, #0D0A14 0%, #1A1529 50%, #0D0A14 100%);
    animation: atmosphere-shift 30s ease-in-out infinite alternate;
}

@keyframes atmosphere-shift {
    0% { background: linear-gradient(180deg, #0D0A14 0%, #1A1529 40%, #0D0A14 100%); }
    50% { background: linear-gradient(180deg, #0D0A14 0%, #231A2E 50%, #1A1529 100%); }
    100% { background: linear-gradient(180deg, #1A1529 0%, #0D0A14 50%, #1A1529 100%); }
}

/* --- Noise Layer --- */
#noise-svg {
    position: absolute;
    width: 0;
    height: 0;
}

#noise-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.04;
    filter: url(#noise-filter);
    pointer-events: none;
}

/* --- Pendulum (persistent, fixed) --- */
#pendulum {
    position: fixed;
    top: 0;
    left: 50%;
    transform-origin: top center;
    z-index: 1;
    animation: pendulum-swing 4s ease-in-out infinite;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

#pendulum.scrolled {
    opacity: 0.15;
}

#pendulum-line {
    width: 1px;
    height: 40vh;
    background-color: #5B5B7A;
    opacity: 0.3;
}

@keyframes pendulum-swing {
    0% { transform: rotate(-7.5deg); }
    50% { transform: rotate(7.5deg); }
    100% { transform: rotate(-7.5deg); }
}

/* --- Forking Path SVG (Architecture Plane) --- */
#forking-path {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    height: 600vh;
    z-index: 1;
    pointer-events: none;
}

#forking-path path {
    stroke-dasharray: var(--path-length, 2000);
    stroke-dashoffset: var(--path-length, 2000);
    transition: stroke-dashoffset 0.05s linear;
}

/* Decision diamonds in SVG */
.decision-diamond rect {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.decision-diamond:hover rect {
    transform: rotate(45) scale(1.2);
    filter: drop-shadow(0 0 12px rgba(196, 162, 101, 0.4));
}

/* --- Spine Pulse --- */
#spine-main,
#spine-mid,
#spine-final {
    animation: spine-pulse 6s ease-in-out infinite;
}

@keyframes spine-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Acts (Content Plane) --- */
.act {
    position: relative;
    z-index: 2;
}

/* ==================== ACT I: THE VOID ==================== */
.act-void {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.act-content {
    text-align: center;
    position: relative;
}

#site-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    letter-spacing: 0.08em;
    line-height: 1.08;
    color: #E8E0D4;
    margin-bottom: 2rem;
    font-feature-settings: 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
    position: relative;
}

/* De Chirico shadow for title */
#site-title::after {
    content: 'dilemma.studio';
    position: absolute;
    top: 0;
    left: 0;
    color: #0D0A14;
    opacity: 0.08;
    transform: skewX(-15deg) scaleY(2);
    transform-origin: bottom left;
    z-index: -1;
    offset: 20px 40px;
    margin-left: 20px;
    margin-top: 40px;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    letter-spacing: 0.08em;
    line-height: 1.08;
}

.letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.title-revealed .letter {
    opacity: 1;
}

#provocation {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    color: #B0A8C0;
    max-width: 42ch;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#provocation.provocation-visible {
    opacity: 1;
}

/* ==================== ACT II: THE FIRST FORK ==================== */
.act-first-fork {
    min-height: 150vh;
    padding: 10vh 5vw;
    position: relative;
}

.fork-zone {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
}

.fork-panel {
    background-color: #1A1529;
    padding: 3rem 2.5rem;
    max-width: 38ch;
    position: relative;
    box-shadow: 0 4px 30px rgba(26, 15, 42, 0.3);
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fork-panel p {
    color: #B0A8C0;
    margin-bottom: 1.2rem;
    max-width: 38ch;
}

.fork-panel p:last-of-type {
    margin-bottom: 0;
    font-style: italic;
    color: #E8E0D4;
}

.fork-panel h2 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: #E8E0D4;
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    font-feature-settings: 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
}

.panel-label {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #7A6F8E;
    opacity: 0.7;
    display: block;
    margin-bottom: 1rem;
    transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fork-panel:hover .panel-label {
    opacity: 1;
}

.fork-left {
    border-left: 3px solid #8B4A3A;
    margin-left: 5%;
    transform: translateX(-20px);
}

.fork-right {
    border-left: 3px solid #3A5A8B;
    margin-left: auto;
    margin-right: 5%;
    margin-top: 60px;
    transform: translateX(20px);
}

.fork-panel.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* ==================== ACT III: THE THRESHOLD ==================== */
.act-threshold {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.threshold-panel {
    width: 100vw;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: repeating-linear-gradient(
        180deg,
        #1A1529 0px,
        #1A1529 8px,
        #231A2E 8px,
        #231A2E 16px
    );
    background-size: 100% 16px;
    animation: threshold-shimmer 20s linear infinite;
}

@keyframes threshold-shimmer {
    0% { background-position: 0 0; }
    100% { background-position: 0 160px; }
}

.threshold-text {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #E8E0D4;
    text-align: center;
    max-width: 20ch;
    line-height: 1.08;
    letter-spacing: -0.02em;
    font-feature-settings: 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
    position: relative;
    z-index: 2;
    padding: 2rem;
}

/* De Chirico shadow for threshold text */
.threshold-text::after {
    content: attr(data-shadow);
    position: absolute;
    top: 40px;
    left: 20px;
    color: #0D0A14;
    opacity: 0.08;
    transform: skewX(-15deg) scaleY(2);
    transform-origin: bottom left;
    z-index: -1;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    max-width: 20ch;
}

/* Blur-Focus animation */
.blur-focus {
    filter: blur(8px);
    opacity: 0.3;
    transition: filter 0.8s ease, opacity 0.8s ease;
}

.blur-focus.focused {
    filter: blur(0);
    opacity: 1;
}

/* Impossible Columns */
.impossible-column {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 300px;
    z-index: 1;
}

.col-left {
    left: 3vw;
}

.col-right {
    right: 3vw;
}

.col-face {
    position: absolute;
    width: 100%;
    height: 100%;
}

.col-front {
    background-color: #1A1529;
    border: 1px solid #5B5B7A;
    clip-path: polygon(10% 0%, 90% 0%, 80% 100%, 20% 100%);
}

.col-side {
    background-color: rgba(26, 21, 41, 0.6);
    border: 1px solid #5B5B7A;
    clip-path: polygon(90% 0%, 100% 10%, 90% 100%, 80% 90%);
    transform: perspective(600px) rotateY(30deg);
    transform-origin: left center;
}

.col-twist {
    background-color: rgba(26, 21, 41, 0.3);
    border: 1px solid rgba(91, 91, 122, 0.4);
    clip-path: polygon(20% 100%, 80% 100%, 60% 50%, 40% 50%);
    transform: perspective(400px) rotateX(15deg) rotateY(-15deg);
}

/* ==================== ACT IV: THE DEEP FORK ==================== */
.act-deep-fork {
    min-height: 190vh;
    padding: 10vh 5vw;
    position: relative;
}

.fork-zone-2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4rem;
}

.deep-left {
    transform: translateX(-20px) rotate(-1deg);
    align-self: flex-start;
    margin-left: 8%;
}

.deep-center {
    border-left: 3px solid #5B5B7A;
    align-self: center;
    transform: translateY(20px);
}

.deep-right {
    transform: translateX(20px) rotate(1deg);
    align-self: flex-end;
    margin-right: 8%;
}

.deep-left.revealed {
    transform: translateX(0) rotate(-1deg);
}

.deep-center.revealed {
    transform: translateY(0);
}

.deep-right.revealed {
    transform: translateX(0) rotate(1deg);
}

/* Diamond Cascade */
.diamond-cascade {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-top: 6rem;
    padding-bottom: 4rem;
}

.cascade-diamond {
    width: 8px;
    height: 8px;
    background-color: #C4A265;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
}

.cascade-diamond.glowing {
    opacity: 1;
    box-shadow: 0 0 12px 4px rgba(196, 162, 101, 0.4);
    transform: rotate(45deg) scale(1.2);
    animation: diamond-glow-cascade 1.5s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes diamond-glow-cascade {
    0%, 100% { box-shadow: 0 0 12px 4px rgba(196, 162, 101, 0.2); }
    50% { box-shadow: 0 0 20px 8px rgba(196, 162, 101, 0.6); }
}

/* ==================== ACT V: THE ETERNAL RETURN ==================== */
.act-eternal-return {
    min-height: 100vh;
    padding: 10vh 5vw;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spiral-zone {
    position: relative;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spiral-text {
    max-width: 38ch;
    margin-bottom: 3rem;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease, font-size 0.8s ease;
}

.spiral-text.revealed {
    opacity: 1;
}

.spiral-text p {
    color: #B0A8C0;
}

.spiral-text-1 {
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    transform: translateX(-30px);
    text-align: left;
    align-self: flex-start;
}

.spiral-text-1.revealed {
    transform: translateX(0);
}

.spiral-text-2 {
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    transform: translateX(30px);
    text-align: right;
    align-self: flex-end;
}

.spiral-text-2.revealed {
    transform: translateX(0);
}

.spiral-text-3 {
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    text-align: center;
    align-self: center;
    transform: scale(0.95);
}

.spiral-text-3.revealed {
    transform: scale(1);
}

/* Return Diamond (Pulse) */
.pulse-diamond {
    margin-top: 4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.diamond-shape {
    width: 20px;
    height: 20px;
    background-color: #C4A265;
    transform: rotate(45deg);
    animation: pulse-attention 2s ease-in-out infinite;
    transition: box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.pulse-diamond:hover .diamond-shape {
    box-shadow: 0 0 20px 8px rgba(196, 162, 101, 0.5);
    transform: rotate(45deg) scale(1.3);
}

@keyframes pulse-attention {
    0%, 100% {
        transform: rotate(45deg) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: rotate(45deg) scale(1.15);
        opacity: 1;
    }
}

/* --- Utility / Global --- */

/* Selection color */
::selection {
    background-color: rgba(196, 162, 101, 0.3);
    color: #E8E0D4;
}

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

::-webkit-scrollbar-track {
    background: #0D0A14;
}

::-webkit-scrollbar-thumb {
    background: #5B5B7A;
    border-radius: 2px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .fork-left,
    .fork-right {
        margin-left: 5%;
        margin-right: 5%;
        max-width: 90%;
    }

    .fork-right {
        margin-top: 40px;
    }

    .deep-left,
    .deep-right {
        margin-left: 5%;
        margin-right: 5%;
        max-width: 90%;
        align-self: center;
    }

    .impossible-column {
        display: none;
    }

    .threshold-text {
        padding: 2rem 1.5rem;
    }

    #pendulum-line {
        height: 30vh;
    }
}

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

    #site-title {
        letter-spacing: 0.04em;
    }
}
