/* layer-2.quest — Light-Academia Horizontal Scroll */

:root {
    --aged-parchment: #F5ECD7;
    --warm-vellum: #EDE3CC;
    --pale-linen: #F0E4CE;
    --dark-walnut: #3B2F2F;
    --graphite-brown: #7A6B5D;
    --tarnished-brass: #C4A35A;
    --aged-copper: #A67C52;
    --ink-sepia: #8B6914;
    --faded-ruling: #D4C4A8;
    --warm-shadow: #C8B898;
}

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

html, body {
    overflow-x: auto;
    overflow-y: hidden;
    height: 100vh;
}

body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    color: var(--dark-walnut);
    background: var(--aged-parchment);
    line-height: 1.75;
    letter-spacing: 0.01em;
}

/* ---- Progress bar ---- */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--tarnished-brass);
    width: 0;
    z-index: 9999;
    transition: width 0.15s linear;
}

/* ---- Panel counter ---- */
.panel-counter {
    position: fixed;
    bottom: 1.5rem;
    right: 2rem;
    z-index: 100;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--graphite-brown);
}

/* ---- Scroll track ---- */
.scroll-track {
    display: flex;
    width: 700vw;
    height: 100vh;
    scroll-snap-type: x mandatory;
}

/* ---- Panels ---- */
.panel {
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
    padding: 8vh 6vw;
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
}

/* ---- Ruled background ---- */
.ruled-bg {
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 27px,
        rgba(212, 196, 168, 0.08) 27px,
        rgba(212, 196, 168, 0.08) 28px
    );
    pointer-events: none;
}

.ruled-bg-margin::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 12%;
    width: 1px;
    background: rgba(196, 163, 90, 0.06);
}

/* ---- Brass rule ---- */
.brass-rule {
    width: 120px;
    height: 1px;
    background: var(--tarnished-brass);
    margin: 1.5rem 0;
}

/* ---- Reveal animation ---- */
[data-reveal] {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.1, 0.25, 1), transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---- THE FOLIO ---- */
.panel-folio {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--aged-parchment);
}

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

.folio-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw + 0.8rem, 5rem);
    color: var(--dark-walnut);
    letter-spacing: 0.04em;
    line-height: 1.1;
    transform: rotate(-7deg);
    transform-origin: bottom left;
}

.folio-subtitle {
    font-family: 'Source Serif 4', serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    color: var(--graphite-brown);
    font-style: italic;
    margin-top: 1rem;
}

.chevron-decor {
    position: absolute;
    bottom: 10%;
    right: 10%;
    width: 72px;
    height: 40px;
    opacity: 0.4;
}

/* ---- THE DIAGRAM ---- */
.panel-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--warm-vellum);
}

.diagram-svg {
    width: 80%;
    max-width: 800px;
    height: auto;
}

.diagram-label {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 12px;
    fill: var(--dark-walnut);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.diagram-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.2s ease-out;
}

.panel-diagram .diagram-svg.revealed .diagram-path {
    stroke-dashoffset: 0;
}

/* ---- THE MARGIN NOTES ---- */
.panel-margins {
    background: var(--aged-parchment);
    padding-top: 10vh;
}

.margins-grid {
    display: flex;
    gap: 4vw;
    height: 80vh;
}

.margins-body {
    flex: 65%;
    overflow-y: auto;
}

.margins-notes {
    flex: 35%;
    position: relative;
}

.body-text {
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.25rem);
    line-height: 1.75;
    max-width: 38em;
    margin-bottom: 1.5rem;
    text-align: justify;
}

.margin-note {
    position: relative;
    padding: 1rem;
    margin-bottom: 2rem;
}

.mn-1 { transform: rotate(1.5deg); }
.mn-2 { transform: rotate(-2deg); margin-left: 10%; }
.mn-3 { transform: rotate(1deg); }

.note-text {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: var(--graphite-brown);
    line-height: 1.4;
}

/* ---- Panel headings ---- */
.panel-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw + 0.6rem, 2.8rem);
    color: var(--dark-walnut);
    letter-spacing: 0.04em;
    margin-bottom: 2rem;
}

/* ---- THE PROOF ---- */
.panel-proof {
    background: var(--warm-vellum);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.proof-chain {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.proof-step {
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--dark-walnut);
    background: var(--aged-parchment);
}

.step-label {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dark-walnut);
}

.proof-chevron {
    width: 40px;
    height: 30px;
    flex-shrink: 0;
}

.code-block {
    background: var(--pale-linen);
    border: 1px solid var(--faded-ruling);
    padding: 1.5rem 2rem;
    max-width: 500px;
}

.code-block code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--dark-walnut);
    line-height: 1.6;
    white-space: pre;
}

/* ---- THE ARCHIVE ---- */
.panel-archive {
    background: var(--aged-parchment);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.archive-cards {
    display: flex;
    gap: 2rem;
}

.archive-card {
    flex: 1;
    padding: 2rem;
    border: 1px solid var(--faded-ruling);
    background: var(--warm-vellum);
    clip-path: polygon(20px 0, 100% 0, 100% 100%, 0 100%, 0 20px);
    box-shadow: 0 2px 8px rgba(200, 184, 152, 0.3);
}

.card-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--dark-walnut);
    margin-bottom: 0.8rem;
}

.card-text {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--dark-walnut);
}

/* ---- THE CORRESPONDENCE ---- */
.panel-correspondence {
    background: var(--aged-parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lamp-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(196, 163, 90, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    transition: left 0.2s ease, top 0.2s ease;
}

.correspondence-text {
    position: relative;
    z-index: 2;
    max-width: 38em;
}

.body-text-correspondence {
    line-height: 1.85;
    margin-bottom: 1.5rem;
}

.closing {
    margin-top: 2rem;
    text-align: right;
}

/* ---- THE COLOPHON ---- */
.panel-colophon {
    background: var(--warm-vellum);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.colophon-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 4rem);
    color: var(--dark-walnut);
    letter-spacing: 0.04em;
}

.colophon-content .brass-rule {
    margin: 1.5rem auto;
}

.colophon-note {
    font-family: 'Source Serif 4', serif;
    font-size: 0.85rem;
    color: var(--graphite-brown);
}

.chevron-watermark {
    position: absolute;
    bottom: 10%;
    right: 10%;
    width: 400px;
    height: 200px;
}

/* ---- Mobile: vertical fallback ---- */
@media (max-width: 767px) {
    html, body {
        overflow-x: auto;
        overflow-y: auto;
        height: auto;
    }

    .scroll-track {
        flex-direction: column;
        width: 100%;
        height: auto;
    }

    .panel {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 6vh 5%;
    }

    .margins-grid {
        flex-direction: column;
        height: auto;
    }

    .archive-cards {
        flex-direction: column;
    }

    .folio-title {
        transform: none;
    }

    .panel-counter {
        display: none;
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    [data-reveal] {
        opacity: 1;
        transform: translateY(0);
    }

    .diagram-path {
        stroke-dashoffset: 0;
    }
}
