/* sustaining.quest - Dark-academia reading room meets quest journal */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --cream-page: #f5f0e4;
    --dark-mahogany: #2a1f14;
    --warm-leather: #6b4226;
    --amber-lamp: #d4a54a;
    --sage-leaf: #7a9a6b;
    --margin-tan: #8a7a5e;
    --desk-wood: #3a2a1a;
    --parchment-glow: #ede6d4;
    --connector: #b8a88a;
    --body-text: #3d2e1f;
    --ref-text: #6b5c42;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--desk-wood);
    color: var(--body-text);
    font-family: 'Crimson Text', serif;
    font-size: 17px;
    line-height: 1.8;
    overflow-x: hidden;
}

/* ---- Desk Surface ---- */
.desk-surface {
    max-width: 900px;
    margin: 0 auto;
    background: var(--cream-page);
    box-shadow: 0 2px 20px rgba(42,31,20,0.25), 0 0 60px rgba(42,31,20,0.08);
    position: relative;
    transform: rotate(0.3deg);
}

/* ---- Page Surface ---- */
.page-surface {
    position: relative;
    min-height: 100vh;
    padding: 80px 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.lamp-glow {
    position: absolute;
    top: -50px;
    left: -50px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(212,165,74,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.paper-texture {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.02'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* ---- Journal Header ---- */
.journal-header {
    text-align: center;
    margin-bottom: 40px;
}

.journal-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.02em;
    color: var(--dark-mahogany);
    margin-bottom: 12px;
}

.journal-header h1 span {
    display: inline-block;
    opacity: 0;
    animation: letterReveal 0.3s ease forwards;
}

.journal-header h1 span:nth-child(1) { animation-delay: 0.4s; }
.journal-header h1 span:nth-child(2) { animation-delay: 0.44s; }
.journal-header h1 span:nth-child(3) { animation-delay: 0.48s; }
.journal-header h1 span:nth-child(4) { animation-delay: 0.52s; }
.journal-header h1 span:nth-child(5) { animation-delay: 0.56s; }
.journal-header h1 span:nth-child(6) { animation-delay: 0.6s; }
.journal-header h1 span:nth-child(7) { animation-delay: 0.64s; }
.journal-header h1 span:nth-child(8) { animation-delay: 0.68s; }
.journal-header h1 span:nth-child(9) { animation-delay: 0.72s; }
.journal-header h1 span:nth-child(10) { animation-delay: 0.76s; }
.journal-header h1 span:nth-child(11) { animation-delay: 0.8s; }
.journal-header h1 span:nth-child(12) { animation-delay: 0.84s; }
.journal-header h1 span:nth-child(13) { animation-delay: 0.88s; }
.journal-header h1 span:nth-child(14) { animation-delay: 0.92s; }
.journal-header h1 span:nth-child(15) { animation-delay: 0.96s; }
.journal-header h1 span:nth-child(16) { animation-delay: 1.0s; }

@keyframes letterReveal {
    to { opacity: 1; }
}

.journal-tagline {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 14px;
    color: var(--ref-text);
    opacity: 0;
    animation: fadeIn 0.6s ease forwards 1.4s;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* ---- Margin Notes ---- */
.margin-note {
    position: relative;
    margin-bottom: 24px;
}

.margin-note-1 {
    position: absolute;
    top: 80px;
    right: -180px;
    width: 160px;
}

.margin-date {
    display: block;
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 11px;
    color: var(--ref-text);
    margin-bottom: 2px;
}

.margin-text {
    font-family: 'Caveat', cursive;
    font-size: 14px;
    color: var(--margin-tan);
    line-height: 1.4;
}

.margin-anim {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.margin-anim.visible {
    opacity: 1;
    transform: translateX(0);
}

.dotted-connector {
    position: absolute;
    top: 8px;
    right: -30px;
    width: 30px;
    height: 1px;
    border-top: 1px dashed var(--connector);
    transform: rotate(-15deg);
    transform-origin: right center;
}

/* ---- Chapter Plates ---- */
.chapter-plate {
    padding: 30px 40px;
    text-align: center;
}

.plate-frame {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.frame-draw {
    stroke-dasharray: 1800;
    stroke-dashoffset: 1800;
    transition: stroke-dashoffset 1.2s ease;
}

.chapter-plate.visible .frame-draw {
    stroke-dashoffset: 0;
}

/* ---- Content Sections ---- */
.content-section {
    padding: 40px 40px;
}

.content-with-margin {
    display: flex;
    gap: 40px;
}

.margin-column {
    width: 180px;
    flex-shrink: 0;
    padding-top: 10px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.content-block {
    margin-bottom: 36px;
}

.content-block h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    letter-spacing: 0.02em;
    color: var(--dark-mahogany);
    margin-bottom: 12px;
}

.content-block p {
    margin-bottom: 14px;
}

.content-block em {
    font-style: italic;
    color: var(--warm-leather);
}

.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

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

/* ---- Floating Cards ---- */
.floating-card {
    background: var(--parchment-glow);
    padding: 24px 28px;
    margin: 24px 0;
    box-shadow: 0 4px 16px rgba(42,31,20,0.12), 0 2px 4px rgba(42,31,20,0.08);
    border-left: 3px solid var(--amber-lamp);
    position: relative;
}

.floating-card h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 20px;
    color: var(--warm-leather);
    margin-bottom: 8px;
}

.floating-card p {
    font-size: 15px;
    line-height: 1.7;
}

/* ---- Botanical SVGs ---- */
.botanical-svg {
    width: 80px;
    height: auto;
    margin-top: 24px;
    display: block;
}

.botanical-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease;
}

.botanical-svg.visible .botanical-path {
    stroke-dashoffset: 0;
}

/* ---- Quest Interlude ---- */
.quest-interlude {
    padding: 60px 60px;
    text-align: center;
    background: var(--cream-page);
}

.interlude-inner {
    max-width: 600px;
    margin: 0 auto;
}

.compass-motif {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.compass-draw {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    transition: stroke-dashoffset 1.5s ease;
}

.compass-motif.visible .compass-draw {
    stroke-dashoffset: 0;
}

.interlude-quote {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 24px;
    color: var(--dark-mahogany);
    line-height: 1.6;
    margin-bottom: 12px;
    font-style: italic;
}

.interlude-cite {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 13px;
    color: var(--ref-text);
}

/* ---- Quest Map Footer ---- */
.quest-map-footer {
    background: var(--dark-mahogany);
    color: var(--cream-page);
    padding: 60px 20px 40px;
    text-align: center;
}

.quest-map-footer h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    color: var(--cream-page);
    margin-bottom: 30px;
}

.quest-map-container {
    max-width: 700px;
    margin: 0 auto 30px;
    overflow: hidden;
}

.quest-map {
    width: 100%;
    height: auto;
}

.quest-path {
    transition: stroke-dashoffset 3s ease;
}

.quest-node {
    transition: opacity 0.5s ease;
}

.quest-node-final {
    animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { r: 8; opacity: 0.6; }
    50% { r: 10; opacity: 1; }
}

.footer-text {
    font-family: 'Crimson Text', serif;
    font-size: 15px;
    color: var(--cream-page);
    opacity: 0.7;
    margin-bottom: 8px;
}

.footer-ref {
    font-family: 'Caveat', cursive;
    font-size: 16px;
    color: var(--amber-lamp);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .desk-surface {
        transform: none;
        margin: 0;
    }

    .page-surface {
        padding: 40px 24px;
    }

    .content-section {
        padding: 24px 20px;
    }

    .content-with-margin {
        flex-direction: column;
    }

    .margin-column {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
    }

    .margin-note-1 {
        position: relative;
        top: 0;
        right: 0;
        width: auto;
    }

    .dotted-connector {
        display: none;
    }

    .chapter-plate {
        padding: 20px 16px;
    }

    .quest-interlude {
        padding: 40px 24px;
    }
}
