/* ===========================================
   dilemma.studio — Styles
   Pixel-art pastoral-romantic candlelit scroll
   =========================================== */

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

:root {
    --navy: #0b1229;
    --parchment: #f0e6d2;
    --parchment-mid: #e6d9c0;
    --parchment-dark: #ddd0b8;
    --lamp-black: #1a1a1e;
    --copper: #b87333;
    --gold: #e8a825;
    --rose: #c47d8a;
    --pewter: #8d99ae;
    --indigo: #1d2640;
    --grid: 8px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--navy);
    color: var(--lamp-black);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Candle Glow Overlay --- */
#candle-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 0%, rgba(232, 168, 37, 0.15) 0%, rgba(11, 18, 41, 0) 70%);
    pointer-events: none;
    z-index: 1;
}

/* --- Pixel Rain --- */
#pixel-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.rain-pixel {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--pewter);
    opacity: 0;
    animation: rainFall linear infinite;
}

@keyframes rainFall {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    10% {
        opacity: var(--rain-opacity, 0.15);
    }
    90% {
        opacity: var(--rain-opacity, 0.15);
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

/* --- Navigation --- */
#nav {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 16px 0;
}

.nav-inner {
    display: flex;
    gap: 32px;
    align-items: center;
    background: rgba(11, 18, 41, 0.85);
    padding: 8px 24px;
    border-bottom: 2px solid var(--indigo);
}

.nav-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--pewter);
    transition: color 200ms, text-shadow 200ms;
}

.nav-icon::after {
    content: attr(data-label);
    font-family: 'Silkscreen', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-icon:hover {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(232, 168, 37, 0.5);
}

/* Pixel icons in nav */
.pixel-icon {
    display: block;
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.icon-quill {
    background: linear-gradient(135deg, var(--pewter) 25%, var(--copper) 75%);
    clip-path: polygon(50% 0%, 100% 30%, 80% 100%, 50% 85%, 20% 100%, 0% 30%);
}

.icon-candle {
    background: var(--gold);
    clip-path: polygon(35% 100%, 35% 40%, 25% 35%, 40% 0%, 55% 0%, 75% 35%, 65% 40%, 65% 100%);
}

.icon-compass {
    background: var(--pewter);
    clip-path: polygon(50% 0%, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0% 50%, 35% 35%);
}

.icon-seal {
    background: var(--copper);
    border-radius: 50%;
}

/* --- Parchment Scroll (Main) --- */
#scroll-parchment {
    position: relative;
    width: clamp(320px, 80vw, 720px);
    margin: 0 auto;
    background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-mid) 50%, var(--parchment-dark) 100%);
    z-index: 2;
    opacity: 0;
    animation: scrollFadeIn 800ms ease-out 1.2s forwards;
    box-shadow:
        -4px 0 0 var(--parchment-dark),
        4px 0 0 var(--parchment-dark),
        -8px 0 0 var(--parchment-mid),
        8px 0 0 var(--parchment-mid),
        0 0 80px 20px rgba(232, 168, 37, 0.06);
}

/* Torn pixel edges */
#scroll-parchment::before,
#scroll-parchment::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    z-index: 3;
    pointer-events: none;
}

#scroll-parchment::before {
    left: -8px;
    background: repeating-linear-gradient(
        180deg,
        var(--parchment-dark) 0px,
        var(--parchment-dark) 8px,
        transparent 8px,
        transparent 16px
    );
}

#scroll-parchment::after {
    right: -8px;
    background: repeating-linear-gradient(
        180deg,
        transparent 0px,
        transparent 8px,
        var(--parchment-dark) 8px,
        var(--parchment-dark) 16px
    );
}

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

/* --- Chapters --- */
.chapter {
    padding: 64px 40px;
}

.chapter-content {
    max-width: 640px;
    margin: 0 auto;
}

/* --- Opening Chapter --- */
.opening-chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 120px;
}

.wordmark {
    font-family: 'Rokkitt', 'Rockwell', serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 5.5vw, 4.2rem);
    letter-spacing: 0.02em;
    line-height: 1.12;
    color: var(--copper);
    margin-bottom: 8px;
}

.letter {
    display: inline-block;
    opacity: 0;
    animation: letterAppear 500ms ease-out forwards;
    position: relative;
}

.letter::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 16px;
    background: var(--rose);
    opacity: 0.15;
    filter: blur(12px);
    animation: washBleed 1.5s ease-out forwards;
    animation-delay: inherit;
}

@keyframes letterAppear {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes washBleed {
    from { opacity: 0; transform: scaleY(0.5); }
    to { opacity: 0.15; transform: scaleY(1); }
}

.wordmark-sub {
    font-family: 'Silkscreen', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pewter);
    margin-bottom: 32px;
}

.tagline {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--copper);
    opacity: 0.7;
}

/* --- Vignettes (Section Dividers) --- */
.vignette {
    width: 100%;
    height: 64px;
    position: relative;
    overflow: hidden;
}

.vignette-pixel-scene {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Candle hill vignette */
.vignette-candle-hill .vignette-pixel-scene {
    background:
        linear-gradient(0deg, #6b7c5e 0%, #6b7c5e 40%, transparent 40%),
        linear-gradient(180deg, transparent 0%, rgba(232, 168, 37, 0.05) 100%);
}

.vignette-candle-hill .vignette-pixel-scene::before {
    content: '';
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 16px;
    background: var(--parchment);
    box-shadow: 0 -6px 0 var(--gold), 0 -6px 16px 4px rgba(232, 168, 37, 0.3);
}

.vignette-candle-hill .vignette-pixel-scene::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background:
        repeating-linear-gradient(90deg,
            #6b7c5e 0px, #6b7c5e 8px,
            #5a6b4e 8px, #5a6b4e 16px
        );
    clip-path: polygon(
        0% 100%, 0% 60%, 5% 50%, 10% 55%, 15% 40%, 20% 45%, 25% 35%, 30% 40%,
        35% 30%, 40% 35%, 45% 25%, 48% 20%, 50% 15%, 52% 20%, 55% 25%,
        60% 35%, 65% 30%, 70% 40%, 75% 35%, 80% 45%, 85% 40%, 90% 55%, 95% 50%, 100% 60%, 100% 100%
    );
}

/* Bridge vignette */
.vignette-bridge .vignette-pixel-scene {
    background: linear-gradient(180deg, rgba(141, 153, 174, 0.1) 0%, rgba(107, 124, 94, 0.2) 100%);
}

.vignette-bridge .vignette-pixel-scene::before {
    content: '';
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 8px;
    background: var(--copper);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    box-shadow: -4px 8px 0 var(--lamp-black), 4px 8px 0 var(--lamp-black);
}

.vignette-bridge .vignette-pixel-scene::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 16px;
    background: repeating-linear-gradient(90deg,
        var(--pewter) 0px, var(--pewter) 8px,
        rgba(141, 153, 174, 0.5) 8px, rgba(141, 153, 174, 0.5) 16px
    );
}

/* Tree vignette */
.vignette-tree .vignette-pixel-scene {
    background: linear-gradient(180deg, transparent 0%, rgba(107, 124, 94, 0.15) 100%);
}

.vignette-tree .vignette-pixel-scene::before {
    content: '';
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 24px;
    background: var(--lamp-black);
}

.vignette-tree .vignette-pixel-scene::after {
    content: '';
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 24px;
    background: var(--lamp-black);
    clip-path: polygon(50% 0%, 15% 40%, 0% 100%, 100% 100%, 85% 40%);
    box-shadow: 0 0 24px 8px rgba(196, 125, 138, 0.15);
}

/* --- Decorated Initial Letters --- */
.decorated-initial-wrap {
    position: relative;
}

.decorated-initial {
    float: left;
    width: 48px;
    height: 48px;
    margin-right: 16px;
    margin-bottom: 8px;
    background: var(--parchment-dark);
    border: 2px solid var(--copper);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    image-rendering: pixelated;
}

.decorated-initial::before {
    content: '';
    position: absolute;
    inset: -8px;
    background: radial-gradient(circle, rgba(232, 168, 37, 0.2) 0%, transparent 70%);
    filter: blur(8px);
    z-index: -1;
}

.decorated-initial::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 1px solid var(--rose);
    opacity: 0.5;
}

.initial-letter {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 28px;
    color: var(--copper);
    line-height: 1;
}

/* --- Body Text --- */
.body-text {
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    color: var(--lamp-black);
    margin-bottom: 24px;
}

.body-text.first-para {
    margin-bottom: 24px;
}

.section-heading {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    letter-spacing: 0.02em;
    line-height: 1.12;
    color: var(--copper);
    margin-bottom: 24px;
}

/* --- Work Grid --- */
.work-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 32px;
}

.work-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 128 / 96;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--indigo);
    background: var(--navy);
}

.thumb-pixels {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    position: relative;
    z-index: 1;
}

/* Pixel art thumbnails via CSS gradients */
#thumb1 {
    background:
        linear-gradient(180deg, #2a3a5c 0%, #2a3a5c 30%, #6b7c5e 30%, #6b7c5e 50%, #5a6b4e 50%, #5a6b4e 70%, #4a5b3e 70%);
}

#thumb2 {
    background:
        linear-gradient(180deg, #1d2640 0%, #1d2640 40%, var(--gold) 40%, var(--gold) 45%, #1d2640 45%);
    box-shadow: inset 0 -20px 30px -10px rgba(232, 168, 37, 0.3);
}

#thumb3 {
    background:
        linear-gradient(180deg, var(--parchment) 0%, var(--parchment) 20%, var(--parchment-mid) 20%, var(--parchment-mid) 80%, var(--parchment-dark) 80%);
}

#thumb4 {
    background:
        repeating-linear-gradient(90deg, var(--lamp-black) 0px, var(--lamp-black) 8px, var(--indigo) 8px, var(--indigo) 16px),
        linear-gradient(180deg, var(--navy) 0%, var(--indigo) 100%);
    background-size: 16px 100%, 100% 100%;
}

.thumb-wash {
    position: absolute;
    inset: -16px;
    z-index: 0;
    filter: blur(24px);
    opacity: 0.3;
    transition: opacity 200ms;
}

#thumb1 ~ .thumb-wash { background: var(--rose); }

.work-thumb:nth-child(1) .thumb-wash { background: var(--rose); }
.work-thumb:nth-child(2) .thumb-wash { background: var(--gold); }
.work-thumb:nth-child(3) .thumb-wash { background: var(--copper); }
.work-thumb:nth-child(4) .thumb-wash { background: var(--pewter); }

.work-thumb:hover .thumb-wash {
    opacity: 0.6;
}

.work-thumb:hover {
    box-shadow: 0 0 32px 8px rgba(232, 168, 37, 0.15);
}

.thumb-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-family: 'Silkscreen', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--parchment);
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* --- Timeline (Process) --- */
.timeline {
    position: relative;
    padding: 32px 0;
    margin-top: 24px;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(
        180deg,
        var(--pewter) 0px,
        var(--pewter) 4px,
        transparent 4px,
        transparent 8px
    );
}

.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    margin-bottom: 48px;
    gap: 24px;
}

.timeline-node[data-side="left"] {
    flex-direction: row;
    padding-right: calc(50% + 24px);
}

.timeline-node[data-side="right"] {
    flex-direction: row-reverse;
    padding-left: calc(50% + 24px);
    text-align: right;
}

.node-candle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 24px;
    background: var(--parchment);
    z-index: 2;
}

.node-candle::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 8px;
}

.candle-flame {
    display: block;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 8px;
    background: var(--gold);
    clip-path: polygon(50% 0%, 100% 60%, 80% 100%, 20% 100%, 0% 60%);
    animation: flicker 800ms steps(1) infinite;
    box-shadow: 0 -4px 12px 4px rgba(232, 168, 37, 0.3);
}

@keyframes flicker {
    0%, 100% {
        clip-path: polygon(50% 0%, 100% 60%, 80% 100%, 20% 100%, 0% 60%);
        height: 8px;
    }
    50% {
        clip-path: polygon(50% 5%, 95% 55%, 75% 100%, 25% 100%, 5% 55%);
        height: 7px;
    }
}

.node-content {
    flex: 1;
}

.node-title {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 1.33rem;
    color: var(--copper);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.node-text {
    font-size: clamp(0.9rem, 1vw, 1rem);
    line-height: 1.72;
    color: var(--lamp-black);
}

/* --- Dissolution --- */
#dissolution {
    text-align: center;
    position: relative;
    padding-bottom: 200px;
    overflow: visible;
}

.dissolution-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.candle-body-large {
    width: 12px;
    height: 48px;
    background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
    margin: 0 auto;
}

.large-flame {
    position: relative;
    display: block;
    width: 12px;
    height: 16px;
    margin: 0 auto -4px;
    background: var(--gold);
    clip-path: polygon(50% 0%, 100% 55%, 80% 100%, 20% 100%, 0% 55%);
    animation: flicker 800ms steps(1) infinite;
    box-shadow: 0 -8px 32px 8px rgba(232, 168, 37, 0.3);
}

.dissolution-text {
    font-family: 'Silkscreen', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pewter);
    opacity: 0.8;
}

#dissolve-pixels {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    pointer-events: none;
    overflow: visible;
}

.dissolve-px {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--parchment-dark);
    animation: dissolvefall 3s ease-in infinite;
}

@keyframes dissolvefall {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(80px);
    }
}

/* --- Wax Seal --- */
#wax-seal {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--copper);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
    box-shadow: 0 0 16px 4px rgba(184, 115, 51, 0.2);
    transition: box-shadow 200ms;
}

#wax-seal:hover {
    box-shadow: 0 0 24px 8px rgba(232, 168, 37, 0.4);
}

.seal-letter {
    font-family: 'Rokkitt', serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--parchment);
    line-height: 1;
}

/* --- Reveal animations (scroll triggered) --- */
.reveal-section {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

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

/* --- Responsive --- */
@media (max-width: 600px) {
    .chapter {
        padding: 48px 24px;
    }

    .work-grid {
        grid-template-columns: 1fr;
    }

    .timeline-node[data-side="left"],
    .timeline-node[data-side="right"] {
        padding-left: calc(50% + 16px);
        padding-right: 0;
        flex-direction: row-reverse;
        text-align: left;
    }

    .nav-inner {
        gap: 16px;
        padding: 8px 16px;
    }
}
