/* ============================================================
   dilemma.studio - Styles
   Forest-green generative dreamscape
   Font: Commissioner (Google Fonts)
   ============================================================ */

/* --- CSS Variables / Palette --- */
:root {
    --midnight-canopy: #0B1A0F;
    --forest-floor: #142A1B;
    --living-emerald: #2D7A4F;
    --phosphor-moss: #5CB97A;
    --amber-spore: #C4A24E;
    --lichen-white: #E4EDE6;
    --mist-pale: #A8C5B0;
    --dilemma-rose: #8B3A4A;
    --card-back-dark: #0F2316;

    --font-family: 'Commissioner', sans-serif;
    --column-max: 680px;
    --column-narrow: 400px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--midnight-canopy);
    color: var(--lichen-white);
    overflow-x: hidden;
    position: relative;
}

/* --- Noise Overlay --- */
.noise-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
}

/* --- Generative Branch Canvas --- */
.branch-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* --- Abstract Floating Shapes --- */
.abstract-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -2;
    overflow: hidden;
}

.abstract-shape {
    position: absolute;
    background: var(--forest-floor);
    opacity: 0.18;
    border-radius: 50%;
    animation: shapeDrift linear infinite;
}

@keyframes shapeDrift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(30px, -20px) rotate(5deg);
    }
    50% {
        transform: translate(-20px, 15px) rotate(-3deg);
    }
    75% {
        transform: translate(15px, 25px) rotate(7deg);
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* --- Progress Vine --- */
.progress-vine-container {
    position: fixed;
    left: 24px;
    top: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-vine {
    width: 20px;
    height: 100vh;
}

.progress-label {
    font-family: var(--font-family);
    font-weight: 100;
    font-size: 0.65rem;
    color: var(--mist-pale);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.08em;
    margin-top: 8px;
    opacity: 0.6;
}

/* --- Scenes (shared) --- */
.scene {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.scene-content {
    max-width: var(--column-max);
    width: 90%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ===================== SCENE 1: THE CANOPY ===================== */
.scene-canopy {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--midnight-canopy) 0%, #0D1F12 100%);
}

.hero-title {
    font-family: var(--font-family);
    font-weight: 200;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    line-height: 1.08;
    color: var(--lichen-white);
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: fadeInUp 2s ease-out 0.5s forwards;
}

.hero-subtitle {
    font-family: var(--font-family);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    letter-spacing: 0.02em;
    line-height: 1.75;
    color: var(--mist-pale);
    text-align: center;
    opacity: 0;
    animation: fadeInUp 2s ease-out 1.2s forwards;
}

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

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation: breathe 2s ease-in-out infinite;
    z-index: 1;
}

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

/* ===================== SCENE 2: FIRST PASSAGE ===================== */
.scene-passage {
    background: transparent;
}

.passage-narrow {
    min-height: 60vh;
}

.passage-compressed {
    min-height: 40vh;
}

.passage-breathing {
    min-height: 60vh;
}

.passage-content {
    max-width: var(--column-max);
}

.passage-content-narrow {
    max-width: var(--column-narrow);
    text-align: center;
}

.body-text {
    font-family: var(--font-family);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    letter-spacing: 0.02em;
    line-height: 1.75;
    color: var(--lichen-white);
    margin-bottom: 1.5em;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.body-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.ethereal-text {
    color: var(--mist-pale);
}

.passage-question {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.06em;
    line-height: 1.25;
    color: var(--lichen-white);
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.passage-question.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===================== DECISION NODES ===================== */
.scene-decision {
    min-height: 100vh;
    padding: 80px 0;
}

.decision-content {
    max-width: var(--column-max);
}

.section-header {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.06em;
    line-height: 1.25;
    color: var(--lichen-white);
    text-align: center;
    margin-bottom: 2.5rem;
}

/* --- Sonar Rings --- */
.sonar-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    pointer-events: none;
    z-index: 0;
}

.sonar-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    margin-left: -40px;
    margin-top: -40px;
    border: 1px solid var(--living-emerald);
    border-radius: 50%;
    opacity: 0;
    transform: scale(1);
}

.sonar-rings.active .sonar-ring {
    animation: sonarPulse 2.5s ease-out forwards;
}

.sonar-rings.active .sonar-ring:nth-child(1) {
    animation-delay: 0s;
}
.sonar-rings.active .sonar-ring:nth-child(2) {
    animation-delay: 0.3s;
}
.sonar-rings.active .sonar-ring:nth-child(3) {
    animation-delay: 0.6s;
}

/* Double sonar inner rings */
.sonar-double.active .sonar-ring-inner {
    animation: sonarPulseInner 2.5s ease-out forwards;
}
.sonar-double.active .sonar-ring-inner:nth-child(4) {
    animation-delay: 0.15s;
}
.sonar-double.active .sonar-ring-inner:nth-child(5) {
    animation-delay: 0.45s;
}
.sonar-double.active .sonar-ring-inner:nth-child(6) {
    animation-delay: 0.75s;
}

@keyframes sonarPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes sonarPulseInner {
    0% {
        transform: scale(0.5);
        opacity: 0.4;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* --- Card Flip --- */
.card-flip-container {
    perspective: 1200px;
    margin: 2rem 0;
    cursor: pointer;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.card-flip-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.card-stagger-2.visible {
    transition-delay: 0.2s;
}

.card-flip {
    position: relative;
    width: 100%;
    min-height: 280px;
    transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

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

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 280px;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-front {
    background: var(--forest-floor);
    border: 1px solid rgba(45, 122, 79, 0.3);
    color: var(--lichen-white);
}

.card-back {
    background: var(--card-back-dark);
    border: 1px solid rgba(139, 58, 74, 0.4);
    color: var(--mist-pale);
    transform: rotateY(180deg);
}

.card-back-rose {
    border-color: rgba(139, 58, 74, 0.4);
}

.card-back-amber {
    border-color: rgba(196, 162, 78, 0.4);
}

.card-label {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--mist-pale);
    margin-bottom: 1rem;
}

.card-label-back {
    color: var(--dilemma-rose);
}

.card-back-amber .card-label-back {
    color: var(--amber-spore);
}

.card-title {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.06em;
    line-height: 1.25;
    color: var(--lichen-white);
    margin-bottom: 1rem;
}

.card-title-back {
    color: var(--mist-pale);
}

.card-title-rose {
    color: var(--dilemma-rose);
}

.card-title-amber {
    color: var(--amber-spore);
}

.card-body p {
    font-family: var(--font-family);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    letter-spacing: 0.02em;
    line-height: 1.75;
}

.card-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--amber-spore);
    animation: indicatorPulse 2s ease-in-out infinite;
}

.card-indicator-resolved {
    animation: none;
    opacity: 1;
}

.card-flip.flipped .card-indicator {
    animation: none;
}

@keyframes indicatorPulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* --- Branching Text (2-column micro-layout) --- */
.branching-text {
    display: flex;
    gap: 0;
    margin-top: 2.5rem;
    align-items: stretch;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.branching-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.branch-left,
.branch-right {
    flex: 1;
    padding: 0 1.5rem;
}

.branch-left p,
.branch-right p {
    font-family: var(--font-family);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.4vw, 1rem);
    letter-spacing: 0.02em;
    line-height: 1.75;
    color: var(--mist-pale);
}

.branch-divider {
    width: 1px;
    background: var(--living-emerald);
    opacity: 0.5;
    flex-shrink: 0;
}

/* ===================== SCENE 7: CONVERGENCE ===================== */
.scene-convergence {
    min-height: 100vh;
    padding: 80px 0;
}

.convergence-content {
    max-width: var(--column-max);
    text-align: center;
}

.convergence-title {
    font-family: var(--font-family);
    font-weight: 200;
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.08;
    color: var(--lichen-white);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.convergence-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.convergence-subtitle {
    font-family: var(--font-family);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    letter-spacing: 0.02em;
    line-height: 1.75;
    color: var(--mist-pale);
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease-out 0.3s, transform 1s ease-out 0.3s;
}

.convergence-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

.convergence-closing {
    font-family: var(--font-family);
    font-weight: 200;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--mist-pale);
    margin-top: 3rem;
    opacity: 0.5;
}

.convergence-point {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--living-emerald);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    opacity: 0;
    transition: opacity 1s ease-out;
}

.convergence-point.visible {
    opacity: 1;
    box-shadow: 0 0 20px var(--phosphor-moss), 0 0 40px rgba(45, 122, 79, 0.3);
}

/* ===================== TERMINAL NODE PULSES (Branch tips) ===================== */
@keyframes terminalPulse {
    0%, 100% {
        r: 2;
        opacity: 0.3;
    }
    50% {
        r: 3.5;
        opacity: 0.6;
    }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .progress-vine-container {
        display: none;
    }

    .branching-text {
        flex-direction: column;
    }

    .branch-divider {
        width: 60%;
        height: 1px;
        margin: 1.5rem auto;
    }

    .branch-left,
    .branch-right {
        padding: 0;
    }

    .card-face {
        padding: 1.5rem 1.2rem;
    }

    .sonar-rings {
        width: 250px;
        height: 250px;
    }

    .scene-content {
        width: 92%;
    }
}

@media (max-width: 480px) {
    .hero-title {
        letter-spacing: 0.08em;
    }

    .card-face {
        min-height: 240px;
        padding: 1.2rem 1rem;
    }
}
