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

:root {
    --deep-burgundy: #5c1a2a;
    --antique-cream: #f5f0e8;
    --molten-gold: #c9a85c;
    --burnt-plum: #3d1520;
    --warm-parchment: #e8ddd0;
    --terracotta: #c44c3f;
    --dusty-teal: #5a8a87;
    --saffron: #e3a832;
    --edge-cream: #e0d5c5;
    --edge-burgundy: #2e0d15;
    --light-x: 50%;
    --light-y: 40%;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    overflow-x: hidden;
    background: var(--deep-burgundy);
}

/* === Split Sections === */
.split-section {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: flex-basis 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel-left {
    background: var(--antique-cream);
    flex-basis: 50%;
}

.panel-right {
    background: var(--deep-burgundy);
    flex-basis: 50%;
}

/* Section ratios */
#section-1.in-view .panel-left { flex-basis: 60%; }
#section-1.in-view .panel-right { flex-basis: 40%; }

#section-2.in-view .panel-left { flex-basis: 40%; }
#section-2.in-view .panel-right { flex-basis: 60%; }

/* Section 4 merged */
.split-section.merged {
    display: flex;
    justify-content: center;
    align-items: center;
}

.panel-merged {
    width: 100%;
    min-height: 100vh;
    background: var(--deep-burgundy);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* === Vignette (candlelight) === */
.panel-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.panel-left .panel-vignette {
    background: radial-gradient(ellipse at var(--light-x) var(--light-y), transparent 30%, rgba(224, 213, 197, 0.6) 100%);
}

.panel-right .panel-vignette {
    background: radial-gradient(ellipse at var(--light-x) var(--light-y), transparent 30%, rgba(46, 13, 21, 0.5) 100%);
}

.panel-merged .panel-vignette {
    background: radial-gradient(ellipse at 50% 50%, transparent 20%, rgba(46, 13, 21, 0.7) 100%);
}

/* === Panel Content === */
.panel-content {
    position: relative;
    z-index: 2;
    padding: 2rem;
}

/* === Section 1: Vertical Stack === */
.vertical-stack {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
    letter-spacing: 0.02em;
}

.karma-text {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5.5vw, 5rem);
    color: var(--deep-burgundy);
}

.badge-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(2.5rem, 5.5vw, 5rem);
    color: var(--antique-cream);
}

/* === Section 2: Scales === */
.scales-container {
    width: 100%;
    max-width: 400px;
}

.scales-svg {
    width: 100%;
    height: auto;
}

.scale-beam {
    transform-origin: 200px 180px;
    animation: tipScale 4s ease-in-out infinite;
}

.scale-pan.pan-left {
    animation: tipScale 4s ease-in-out infinite;
}

.scale-pan.pan-right {
    animation: tipScaleInverse 4s ease-in-out infinite;
}

@keyframes tipScale {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(3deg); }
}

@keyframes tipScaleInverse {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-3deg); }
}

.token {
    animation: floatUp 3s ease-in-out infinite;
}

.token-1 { animation-delay: 0s; }
.token-2 { animation-delay: 0.5s; }
.token-3 { animation-delay: 1s; }
.token-4 { animation-delay: 1.5s; }
.token-5 { animation-delay: 2s; }

@keyframes floatUp {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-15px); opacity: 0.6; }
}

.section-headline {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--antique-cream);
    line-height: 1.05;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--warm-parchment);
    margin-bottom: 1rem;
}

/* === Section 3: Virtues === */
.virtues-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.virtue {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--deep-burgundy);
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

#section-2.in-view .virtue {
    opacity: 1;
    transform: translateX(0);
}

.virtue:nth-child(1) { transition-delay: 0.1s; }
.virtue:nth-child(2) { transition-delay: 0.2s; }
.virtue:nth-child(3) { transition-delay: 0.3s; }
.virtue:nth-child(4) { transition-delay: 0.4s; }
.virtue:nth-child(5) { transition-delay: 0.5s; }
.virtue:nth-child(6) { transition-delay: 0.6s; }
.virtue:nth-child(7) { transition-delay: 0.7s; }

/* === Badge Rosette === */
.badge-rosette {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.rosette-svg {
    width: 100%;
    height: auto;
}

.rosette-ring {
    opacity: 0;
    transform-origin: 150px 150px;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#section-2.in-view .ring-1 { opacity: 1; transform: rotate(0deg); transition-delay: 0.2s; }
#section-2.in-view .ring-2 { opacity: 1; transform: rotate(0deg); transition-delay: 0.4s; }
#section-2.in-view .ring-3 { opacity: 1; transform: rotate(0deg); transition-delay: 0.6s; }
#section-2.in-view .ring-4 { opacity: 1; transform: rotate(0deg); transition-delay: 0.8s; }
#section-2.in-view .ring-5 { opacity: 1; transform: rotate(0deg); transition-delay: 1.0s; }

.ring-1 { transform: rotate(-90deg); }
.ring-2 { transform: rotate(90deg); }
.ring-3 { transform: rotate(-180deg); }
.ring-4 { transform: rotate(180deg); }
.ring-5 { transform: scale(0); }

#section-2.in-view .ring-5 { transform: scale(1); }

/* === Section 4: Final === */
.merged-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.final-badge {
    width: 200px;
    height: 200px;
    animation: breathe 4s ease-in-out infinite;
}

.final-rosette-svg {
    width: 100%;
    height: auto;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.9; }
}

.final-narrative {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--antique-cream);
    margin-top: 2rem;
    opacity: 0;
    transition: opacity 1s ease;
}

.final-narrative.active {
    opacity: 1;
}

/* === Narrative Lines === */
.narrative-line {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--molten-gold);
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 3;
}

.split-section.in-view .narrative-line {
    opacity: 1;
}

/* === Spine Navigation === */
.spine {
    position: fixed;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 60px;
    pointer-events: none;
    transition: left 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.spine-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--molten-gold);
    animation: spineBreath 4s ease-in-out infinite;
}

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

.spine-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--molten-gold);
    position: relative;
    z-index: 2;
    cursor: pointer;
    pointer-events: all;
    transition: transform 0.3s ease;
}

.spine-dot.active {
    transform: scale(1.5);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 92, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(201, 168, 92, 0); }
}

/* === Floating Shapes === */
.floating-shapes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.floating-shape {
    position: absolute;
    width: 30px;
    height: 30px;
    opacity: 0.7;
}

.floating-shape.triangle {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 26px solid var(--terracotta);
}

.floating-shape.circle {
    border-radius: 50%;
    background: var(--dusty-teal);
}

.floating-shape.zigzag {
    width: 40px;
    height: 20px;
    background: linear-gradient(135deg, var(--saffron) 25%, transparent 25%) -10px 0,
                linear-gradient(225deg, var(--saffron) 25%, transparent 25%) -10px 0,
                linear-gradient(315deg, var(--saffron) 25%, transparent 25%),
                linear-gradient(45deg, var(--saffron) 25%, transparent 25%);
    background-size: 20px 20px;
    background-color: transparent;
}

/* === Spine position per section === */
body.section-active-1 .spine { left: 60%; }
body.section-active-2 .spine { left: 40%; }
body.section-active-3 .spine { left: -20px; opacity: 0; }

/* === Mobile === */
@media (max-width: 768px) {
    .split-section {
        flex-direction: column;
    }
    .panel-left, .panel-right {
        flex-basis: 50% !important;
        min-height: 50vh;
    }
    .spine {
        display: none;
    }
    .vertical-stack {
        flex-direction: row;
        gap: 0.2em;
    }
}

/* Mobile candlelight drift */
@media (hover: none) {
    .panel-vignette {
        animation: candleDrift 20s ease-in-out infinite;
    }
    @keyframes candleDrift {
        0%, 100% { --light-x: 45%; --light-y: 35%; }
        25% { --light-x: 55%; --light-y: 45%; }
        50% { --light-x: 55%; --light-y: 35%; }
        75% { --light-x: 45%; --light-y: 45%; }
    }
}
