/* ============================================================
   historic.quest — Styles
   ============================================================ */

:root {
    --aged-vellum: #f4ede0;
    --foxed-ivory: #eae2cf;
    --burnt-umber-ink: #3a2a1a;
    --walnut-shell: #6b5442;
    --tarnished-brass: #b08d57;
    --oxidized-copper: #5e8a73;
    --sealing-wax-red: #9b3a2f;
    --faded-graphite: #8a7a6a;
    --panel-bg: #ddd4c0;
    --sand-light: #c4b08a;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--aged-vellum);
    color: var(--burnt-umber-ink);
    font-family: 'Lora', serif;
    font-size: 18px;
    line-height: 1.8;
    overflow-x: hidden;
}

/* Paper-aged texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        rgba(180,141,87,0.03) 0px,
        transparent 0.5px,
        transparent 4px
    );
}

/* ---- Navigation Trigger ---- */
#nav-trigger {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    background: var(--aged-vellum);
    border: 1px solid var(--tarnished-brass);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(58,42,26,0.15);
}

#nav-trigger:hover {
    transform: rotate(45deg);
    box-shadow: 0 4px 16px rgba(58,42,26,0.25);
}

.compass-icon {
    display: block;
}

/* ---- Chapter Index Overlay ---- */
#chapter-index {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--aged-vellum);
    box-shadow: -4px 0 24px rgba(58,42,26,0.2);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 80px 40px 40px;
    overflow-y: auto;
}

#chapter-index.open {
    transform: translateX(0);
}

.chapter-index-title {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.15em;
    color: var(--burnt-umber-ink);
    margin-bottom: 32px;
    border-bottom: 1px solid var(--tarnished-brass);
    padding-bottom: 16px;
}

#chapter-index ul {
    list-style: none;
}

#chapter-index li {
    margin-bottom: 16px;
}

#chapter-index a {
    font-family: 'IM Fell English', serif;
    font-size: 1.1rem;
    color: var(--walnut-shell);
    text-decoration: none;
    display: block;
    padding: 8px 0;
    border-bottom: 1px dashed var(--sand-light);
    transition: color 0.3s ease;
}

#chapter-index a:hover {
    color: var(--oxidized-copper);
}

#chapter-index a[data-chapter]::before {
    content: attr(data-chapter) ". ";
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    color: var(--tarnished-brass);
    margin-right: 8px;
}

/* ---- Section: Archive Door (Hero) ---- */
.section-archive-door {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--aged-vellum);
    position: relative;
    overflow: hidden;
}

.archive-door-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.hero-compass-rose {
    width: clamp(200px, 40vw, 400px);
    height: auto;
    margin: 0 auto 48px;
    display: block;
    opacity: 0;
}

.hero-compass-rose.animate {
    opacity: 1;
}

.hero-compass-rose .compass-line,
.hero-compass-rose .compass-arrow,
.hero-compass-rose .compass-outer,
.hero-compass-rose .compass-mid,
.hero-compass-rose .compass-center {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.hero-compass-rose.animate .compass-line,
.hero-compass-rose.animate .compass-arrow,
.hero-compass-rose.animate .compass-outer,
.hero-compass-rose.animate .compass-mid {
    animation: drawPath 4s ease forwards;
}

.hero-compass-rose.animate .compass-center {
    animation: drawPath 4s ease forwards, fadeIn 1s 3.5s ease forwards;
}

.compass-label {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    fill: var(--walnut-shell);
    letter-spacing: 0.1em;
}

.site-title {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    font-size: clamp(3rem, 6vw, 5rem);
    letter-spacing: 0.25em;
    color: var(--burnt-umber-ink);
    opacity: 0;
}

.site-title.animate {
    opacity: 1;
}

.site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
}

.site-title.animate .letter {
    animation: letterReveal 0.5s ease forwards;
}

.site-tagline {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--walnut-shell);
    margin-top: 24px;
    opacity: 0;
    transition: opacity 1s ease;
}

.site-tagline.animate {
    opacity: 1;
}

@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

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

@keyframes letterReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Layout Grid ---- */
.section-grid {
    display: grid;
    grid-template-columns: minmax(80px, 200px) 1fr minmax(60px, 180px);
    max-width: 1200px;
    margin: 0 auto;
    padding: 64px 48px;
    gap: 32px;
}

/* ---- Timeline Spine ---- */
.timeline-spine {
    position: sticky;
    top: 64px;
    align-self: start;
    padding-right: 16px;
    opacity: 0;
    transform: translateX(-100%);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.timeline-spine.visible {
    opacity: 1;
    transform: translateX(0);
}

.timeline-line {
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--tarnished-brass);
}

.timeline-marker {
    position: relative;
    padding-left: 24px;
    margin-bottom: 120px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-dense .timeline-marker {
    margin-bottom: 72px;
}

.marker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--tarnished-brass);
    border: 2px solid var(--aged-vellum);
    position: absolute;
    left: 1px;
    top: 50%;
    transform: translateY(-50%);
    transition: background 0.3s ease, transform 0.3s ease;
}

.marker-dot.active {
    background: var(--sealing-wax-red);
    transform: translateY(-50%) scale(1.2);
}

.marker-label {
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    letter-spacing: 0.1em;
    color: var(--walnut-shell);
    white-space: nowrap;
}

/* Wax Seal Markers */
.wax-seal {
    width: 24px;
    height: 24px;
    border-radius: 47% 53% 49% 51% / 52% 48% 50% 50%;
    background: var(--sealing-wax-red);
    background-image: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.2) 0%, transparent 50%);
    color: var(--aged-vellum);
    font-family: 'Playfair Display SC', serif;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
}

/* ---- Main Panel ---- */
.main-panel {
    position: relative;
}

.chapter-heading {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4rem);
    letter-spacing: 0.2em;
    color: var(--burnt-umber-ink);
    margin-bottom: 48px;
    text-align: center;
}

.chapter-number {
    display: block;
    font-family: 'IM Fell English', serif;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--tarnished-brass);
    margin-bottom: 8px;
}

.two-column-text {
    column-count: 2;
    column-gap: 2.5rem;
    column-rule: 1px solid var(--sand-light);
    hyphens: auto;
    -webkit-hyphens: auto;
}

.two-column-text p {
    margin-bottom: 1.5em;
    text-indent: 1.5em;
}

.two-column-text p:first-child {
    text-indent: 0;
}

.reveal-text p {
    opacity: 0.15;
    transition: opacity 0.8s ease;
}

.reveal-text p.revealed {
    opacity: 1;
}

/* Paper texture for panels */
.main-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(180,141,87,0.06) 0px,
        transparent 0.5px,
        transparent 4px
    );
    z-index: -1;
}

/* ---- Marginal Notes ---- */
.marginal-notes {
    padding-left: 16px;
}

.annotation-card {
    border-left: 1px dashed var(--sand-light);
    padding: 16px;
    margin-bottom: 32px;
    transform: rotate(-0.5deg);
    background: var(--foxed-ivory);
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.annotation-card.revealed {
    opacity: 1;
}

.annotation-text {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--walnut-shell);
}

.annotation-ref {
    display: block;
    font-family: 'Courier Prime', monospace;
    font-size: 0.75rem;
    color: var(--faded-graphite);
    opacity: 0.8;
    margin-top: 8px;
}

/* ---- Fleuron Dividers ---- */
.fleuron-divider {
    max-width: 400px;
    margin: 0 auto 48px;
    opacity: 0.6;
}

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

.fleuron-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.fleuron-path.drawn {
    animation: drawPath 2s ease forwards;
}

/* ---- Section: Artifact Chamber ---- */
.section-artifact {
    padding: 64px 48px;
    max-width: 1200px;
    margin: 0 auto;
}

.artifact-display {
    margin: 48px 0;
}

.artifact-frame {
    border: 3px solid var(--walnut-shell);
    padding: 8px;
    position: relative;
    background: var(--aged-vellum);
    margin-bottom: 32px;
}

.artifact-frame::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid var(--tarnished-brass);
    pointer-events: none;
}

.artifact-engraving {
    width: 100%;
    height: auto;
    display: block;
}

.engraving-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.engraving-path.drawn {
    animation: drawPath 3s ease forwards;
}

.hatch-line {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hatch-line.visible {
    opacity: 1;
}

.map-label {
    font-family: 'Playfair Display SC', serif;
    font-size: 12px;
    letter-spacing: 0.3em;
    fill: var(--walnut-shell);
}

.zoom-artifact {
    transform: scale(0.92);
    transition: transform 0.8s ease;
}

.zoom-artifact.zoomed {
    transform: scale(1);
}

.pull-quote {
    border-left: 3px solid var(--tarnished-brass);
    padding: 24px 32px;
    margin: 32px 0;
    background: var(--foxed-ivory);
}

.typewriter-text {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--burnt-umber-ink);
}

.quote-attribution {
    display: block;
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    color: var(--faded-graphite);
    margin-top: 16px;
    opacity: 0.8;
}

/* ---- Section: Deep Archive ---- */
.section-deep-archive {
    position: relative;
    background: var(--panel-bg);
    background-image: repeating-linear-gradient(
        0deg,
        rgba(180,141,87,0.08) 0px,
        transparent 0.5px,
        transparent 3px
    );
    padding: 64px 0;
}

.deep-grid {
    position: relative;
    z-index: 2;
}

.contour-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.magnetic-panel {
    transition: transform 0.1s ease;
}

/* ---- Section: Discovery ---- */
.section-discovery {
    padding: 64px 48px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.discovery-content {
    position: relative;
    text-align: center;
}

.timeline-terminus {
    display: flex;
    justify-content: center;
    margin-bottom: 48px;
}

.wax-seal-large {
    width: 48px;
    height: 48px;
    border-radius: 47% 53% 49% 51% / 52% 48% 50% 50%;
    background: var(--sealing-wax-red);
    background-image: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.25) 0%, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sealPulse 2s ease-in-out infinite;
}

.seal-letter {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    color: var(--aged-vellum);
    font-size: 1.2rem;
}

@keyframes sealPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.discovery-text {
    max-width: 800px;
    margin: 0 auto;
    text-align: left;
}

.discovery-text p {
    margin-bottom: 1.5em;
    text-indent: 1.5em;
}

.discovery-text p:first-child {
    text-indent: 0;
}

.watermark-compass {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    opacity: 0.06;
    pointer-events: none;
    animation: slowRotate 120s linear infinite;
}

@keyframes slowRotate {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.ripple-border {
    position: relative;
    height: 4px;
    margin-top: 64px;
    overflow: hidden;
}

.ripple-border::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        var(--tarnished-brass) 0px,
        transparent 20px,
        var(--tarnished-brass) 40px
    );
    animation: rippleWave 3s linear infinite;
}

@keyframes rippleWave {
    to { transform: translateX(-50%); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .section-grid {
        grid-template-columns: 1fr;
        padding: 32px 24px;
    }

    .timeline-spine {
        position: relative;
        top: 0;
        display: flex;
        overflow-x: auto;
        gap: 0;
        padding-bottom: 16px;
        transform: none;
        opacity: 1;
    }

    .timeline-spine.visible {
        transform: none;
    }

    .timeline-line {
        display: none;
    }

    .timeline-marker {
        padding-left: 0;
        margin-bottom: 0;
        flex-direction: column;
        align-items: center;
        min-width: 80px;
    }

    .timeline-dense .timeline-marker {
        margin-bottom: 0;
    }

    .marker-dot {
        position: static;
        transform: none;
    }

    .marker-dot.active {
        transform: scale(1.2);
    }

    .wax-seal {
        position: static;
        transform: none;
    }

    .two-column-text {
        column-count: 1;
    }

    .marginal-notes {
        padding-left: 0;
    }

    .annotation-card {
        transform: none;
    }

    .section-artifact {
        padding: 32px 24px;
    }

    .section-discovery {
        padding: 32px 24px;
    }

    .chapter-heading {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .watermark-compass {
        width: 300px;
        height: 300px;
    }
}
