/* ============================================
   dilemma.dev — Styles
   Evolved-minimal + candy-bright + leather texture
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --hot-pink: #FF6B9D;
    --electric-lime: #A8E06C;
    --bubblegum-blue: #6BC5FF;
    --tangerine: #FFB347;
    --deep-charcoal: #1A1A1A;
    --warm-white: #FAFAF7;
    --pencil-gray: #5B5B5B;
    --leather-brown: #8B6347;
    --leather-dark: #6B4A35;
    --leather-light: #A07858;

    --font-display: 'Anybody', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-accent: 'Caveat', cursive;

    --max-content: 720px;
    --max-bifurcation: 840px;
    --section-spacing: clamp(80px, 12vh, 160px);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--warm-white);
    color: var(--deep-charcoal);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

/* --- Central Spine --- */
#central-spine {
    position: fixed;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100vh;
    background-color: var(--hot-pink);
    transform: translateX(-0.5px);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    animation: spineAppear 800ms ease-out 200ms forwards;
}

#central-spine.pulsing {
    animation: spinePulse 3s ease-in-out infinite;
}

@keyframes spineAppear {
    from { opacity: 0; }
    to { opacity: 0.8; }
}

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

/* --- Candy Wrapper Fragments --- */
.candy-wrapper {
    position: absolute;
    width: 16px;
    height: 40px;
    border-radius: 2px 2px 2px 2px;
    z-index: 0;
    pointer-events: auto;
    transition: transform 200ms ease-out;
    cursor: default;
}

.candy-wrapper:hover {
    transform: rotate(var(--hover-rotation)) scale(1.1) !important;
}

.candy-wrapper.pink {
    background: linear-gradient(135deg, #FF6B9D, #FF85B1);
}

.candy-wrapper.lime {
    background: linear-gradient(135deg, #A8E06C, #BBEA89);
}

.candy-wrapper.blue {
    background: linear-gradient(135deg, #6BC5FF, #8AD1FF);
}

.candy-wrapper.tangerine {
    background: linear-gradient(135deg, #FFB347, #FFC46D);
}

/* --- Sections --- */
.section {
    position: relative;
    margin: 0 auto;
    padding: var(--section-spacing) 24px;
    z-index: 2;
}

/* --- Title Section (Opening 0-100vh) --- */
#title-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.leather-border-frame {
    position: relative;
    padding: 60px 48px;
    max-width: 600px;
    width: 100%;
    text-align: center;
    border: 3px solid var(--leather-brown);
    border-radius: 2px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(107, 74, 53, 0.04) 3px,
            rgba(107, 74, 53, 0.04) 4px
        ),
        radial-gradient(
            ellipse at 30% 50%,
            rgba(160, 120, 88, 0.12),
            transparent 70%
        ),
        var(--warm-white);
    box-shadow:
        inset 0 0 30px rgba(107, 74, 53, 0.06),
        0 2px 20px rgba(0, 0, 0, 0.04);
}

.leather-border-frame::before,
.leather-border-frame::after {
    content: '';
    position: absolute;
    height: 8px;
    left: -3px;
    right: -3px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(107, 74, 53, 0.08) 3px,
            rgba(107, 74, 53, 0.08) 4px
        ),
        radial-gradient(
            ellipse at 30% 50%,
            rgba(160, 120, 88, 0.3),
            transparent 70%
        ),
        linear-gradient(
            180deg,
            #8B6347 0%,
            #7A5638 50%,
            #8B6347 100%
        );
    border-radius: 1px;
}

.leather-border-frame::before {
    top: -3px;
}

.leather-border-frame::after {
    bottom: -3px;
}

.title-content {
    position: relative;
    z-index: 2;
}

.title-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-stretch: 125%;
    font-size: clamp(3.5rem, 8vw, 5.5rem);
    color: var(--deep-charcoal);
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin-bottom: 24px;
}

.title-annotation {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 1rem;
    color: var(--pencil-gray);
    transform: rotate(-1.5deg);
    display: inline-block;
    margin-top: 8px;
}

/* --- Annotations (Caveat handwriting) --- */
.annotation {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--pencil-gray);
    line-height: 1.4;
}

.margin-note {
    display: block;
    transform: rotate(var(--note-rotation, 0deg));
    margin-top: 32px;
    padding-left: calc(var(--note-offset, 0px) + 20px);
    position: relative;
}

.margin-note::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 12px;
    height: 1px;
    background: var(--pencil-gray);
    opacity: 0.4;
}

/* --- Single Column Content --- */
.single-column {
    max-width: var(--max-content);
    margin: 0 auto;
    position: relative;
}

/* --- Section Headings --- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-stretch: 125%;
    font-size: clamp(2.8rem, 6vw, 4.2rem);
    color: var(--deep-charcoal);
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin-bottom: 32px;
    text-align: center;
}

/* --- Body Text --- */
.body-text {
    margin-bottom: 24px;
    max-width: var(--max-content);
}

.body-text em {
    font-style: italic;
    font-weight: 600;
}

/* --- Pull Quotes --- */
.pullquote {
    margin: 48px 0;
    padding: 32px 32px 32px 36px;
    border-left: 3px solid var(--tangerine);
    position: relative;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(107, 74, 53, 0.02) 3px,
            rgba(107, 74, 53, 0.02) 4px
        ),
        rgba(139, 99, 71, 0.03);
    border-radius: 0 2px 2px 0;
}

.pullquote-text {
    font-family: var(--font-body);
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 400;
    font-style: italic;
    line-height: 1.65;
    color: var(--deep-charcoal);
    margin-bottom: 12px;
}

.pullquote-attribution {
    transform: rotate(var(--note-rotation, 0deg));
    display: inline-block;
}

/* --- Wave Transitions --- */
.wave-transition {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 2;
}

.wave-transition svg {
    width: 100%;
    height: 30px;
    display: block;
}

/* --- Bifurcation Zones --- */
.bifurcation-zone {
    max-width: var(--max-bifurcation);
    margin-left: auto;
    margin-right: auto;
}

.bifurcation-header {
    text-align: center;
    margin-bottom: 32px;
}

.bifurcation-annotation {
    display: inline-block;
    transform: rotate(var(--note-rotation, 0deg));
    margin-top: 8px;
}

/* --- Fork SVG --- */
.fork-svg-container {
    max-width: 400px;
    margin: 0 auto 24px;
    position: relative;
    z-index: 2;
}

.fork-svg {
    width: 100%;
    height: auto;
    display: block;
}

.fork-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1200ms ease-out;
}

.fork-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Bifurcation Panels --- */
.bifurcation-panels {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 0;
    position: relative;
    z-index: 2;
}

.panel {
    flex: 0 1 380px;
    padding: 0 20px;
    opacity: 0;
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.panel-left {
    transform: translateX(0);
    text-align: left;
}

.panel-left.revealed {
    opacity: 1;
    transform: translateX(-40px);
}

.panel-right {
    transform: translateX(0);
    text-align: left;
}

.panel-right.revealed {
    opacity: 1;
    transform: translateX(40px);
}

.panel-left.revealed ~ .panel-right {
    transition-delay: 200ms;
}

.panel-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-stretch: 125%;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    letter-spacing: -0.01em;
    line-height: 1.15;
    margin-bottom: 16px;
}

.panel-note {
    display: inline-block;
    transform: rotate(var(--note-rotation, 0deg));
    margin-top: 12px;
}

/* --- Decision Diagrams --- */
.decision-diagram {
    flex: 0 0 80px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
    position: relative;
    z-index: 2;
}

.diagram-svg {
    width: 80px;
    height: 200px;
}

.diagram-element {
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.diagram-element.drawn {
    opacity: 1;
}

/* --- Convergence Band --- */
.convergence-band {
    margin-top: 48px;
    text-align: center;
    opacity: 0;
    transition: opacity 500ms ease-out;
}

.convergence-band.revealed {
    opacity: 1;
}

.convergence-note {
    display: inline-block;
    transform: rotate(var(--note-rotation, 0deg));
    margin-top: 16px;
}

/* --- Leather Band Texture --- */
.leather-band {
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(107, 74, 53, 0.08) 3px,
            rgba(107, 74, 53, 0.08) 4px
        ),
        radial-gradient(
            ellipse at 30% 50%,
            rgba(160, 120, 88, 0.3),
            transparent 70%
        ),
        linear-gradient(
            180deg,
            #8B6347 0%,
            #7A5638 50%,
            #8B6347 100%
        );
    height: 8px;
    border-radius: 1px;
    max-width: var(--max-content);
    margin: 0 auto;
    position: relative;
}

/* Stitch marks on leather band */
.leather-band::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 10%;
    right: 10%;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        var(--tangerine),
        var(--tangerine) 4px,
        transparent 4px,
        transparent 12px
    );
    opacity: 0.5;
}

/* --- Spine Terminus --- */
#spine-terminus {
    padding: 80px 24px 120px;
    position: relative;
    z-index: 2;
}

/* --- Scroll-Triggered Fade-In --- */
.fade-in-section {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Link Styles --- */
a {
    color: var(--hot-pink);
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--hot-pink);
    transition: width 300ms ease-out;
}

a:hover::after {
    width: 100%;
}

/* --- Closing Annotation --- */
.closing-annotation {
    text-align: center;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    margin-top: 48px;
    padding-left: 0;
}

.closing-annotation::before {
    display: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .bifurcation-panels {
        flex-direction: column;
        align-items: center;
    }

    .panel {
        flex: 0 1 auto;
        max-width: 480px;
        width: 100%;
    }

    .panel-left.revealed {
        transform: translateX(0);
    }

    .panel-right.revealed {
        transform: translateX(0);
    }

    .decision-diagram {
        order: -1;
        padding: 16px 0;
    }

    .diagram-svg {
        height: 140px;
    }

    .leather-border-frame {
        padding: 40px 24px;
    }

    .title-heading {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }
}

@media (max-width: 480px) {
    .section {
        padding-left: 16px;
        padding-right: 16px;
    }

    .panel {
        padding: 0 12px;
    }

    .bifurcation-header {
        padding: 0 8px;
    }
}

/* --- Prefers Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .fade-in-section {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .panel {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .panel-left.revealed {
        transform: translateX(-40px);
    }

    .panel-right.revealed {
        transform: translateX(40px);
    }

    .convergence-band {
        opacity: 1;
        transition: none;
    }

    .fork-path {
        stroke-dashoffset: 0;
        transition: none;
    }

    .diagram-element {
        opacity: 1;
        transition: none;
    }

    #central-spine {
        animation: none;
        opacity: 0.8;
    }

    .candy-wrapper {
        transition: none;
    }
}
