/* ==========================================================================
   historical.quest - Archaeological Cross-Section
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #0A0A0A;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Measuring Tape (Fixed Left Edge) --- */
.measuring-tape {
    position: fixed;
    left: calc(50% - min(450px, 45vw));
    top: 0;
    width: 40px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
    transform: translateX(-30px);
}

.measuring-tape.visible {
    opacity: 1;
}

.measuring-tape svg {
    width: 40px;
    height: 100%;
}

#tape-line {
    stroke-dasharray: 6000;
    stroke-dashoffset: 6000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.measuring-tape.visible #tape-line {
    stroke-dashoffset: 0;
}

.tape-tick {
    opacity: 0.4;
}

.tape-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 8px;
    letter-spacing: 0.08em;
    fill: currentColor;
    opacity: 0.5;
}

/* --- Stratum Common Styles --- */
.stratum {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

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

.stratum-content {
    position: relative;
    z-index: 2;
    max-width: 900px;
    width: 100%;
    padding-left: 50px;
    padding-right: 30px;
}

/* --- Stratum Titles --- */
.stratum-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.15;
    margin-bottom: 2rem;
}

.stratum-title.animated {
    animation: titleExpand 0.8s ease-out forwards;
}

@keyframes titleExpand {
    0% { letter-spacing: 0.06em; }
    50% { letter-spacing: 0.12em; }
    100% { letter-spacing: 0.08em; }
}

/* --- Site Title (Surface) --- */
.site-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.8rem, 6vw, 5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.15;
    color: #2A2420;
    text-align: center;
}

.site-subtitle {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    color: #2A2420;
    text-align: center;
    margin-top: 1.5rem;
    opacity: 0.8;
}

/* --- Scroll Chevron --- */
.chevron-container {
    text-align: center;
    margin-top: 3rem;
}

.scroll-chevron {
    animation: chevronPulse 2s ease-in-out infinite;
}

@keyframes chevronPulse {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* ==========================================================================
   STRATUM 1: Surface / Modern - #E8E0D4
   ========================================================================== */
.stratum-surface {
    background: #E8E0D4;
    color: #2A2420;
    min-height: 100vh;
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 93%,
        97% 94%, 93% 92.5%, 88% 95%, 83% 93.5%,
        78% 96%, 73% 94%, 68% 97%, 63% 95%,
        58% 97.5%, 53% 95.5%, 48% 98%, 43% 96%,
        38% 98.5%, 33% 96.5%, 28% 99%, 23% 97%,
        18% 99.5%, 13% 97.5%, 8% 100%, 3% 98%,
        0% 100%
    );
    z-index: 5;
}

.stratum-surface .stratum-content {
    padding: 8vh 6vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Surface accent color: #5B8C5A (living moss) */
.stratum-surface .stratum-content .site-subtitle {
    color: #5B8C5A;
    opacity: 0.9;
}

/* Surface texture: fine-grain noise + horizontal root lines */
.stratum-surface .stratum-texture {
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 47px,
            rgba(42, 36, 32, 0.005) 47px,
            rgba(42, 36, 32, 0.005) 48px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 123px,
            rgba(91, 140, 90, 0.008) 123px,
            rgba(91, 140, 90, 0.008) 124px
        );
    opacity: 0.8;
}

.stratum-surface .stratum-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* ==========================================================================
   STRATUM 2: Upper / Industrial - #B8A089
   ========================================================================== */
.stratum-industrial {
    background: #B8A089;
    color: #1E1A16;
    min-height: 100vh;
    margin-top: -80px;
    clip-path: polygon(
        0% 2%, 3% 0.5%, 8% 3%, 13% 1%, 18% 3.5%,
        23% 1.5%, 28% 4%, 33% 2%, 38% 4.5%,
        43% 2.5%, 48% 5%, 53% 3%, 58% 5.5%,
        63% 3.5%, 68% 6%, 73% 4%, 78% 6.5%,
        83% 4.5%, 88% 7%, 93% 5%, 97% 6.5%, 100% 5%,
        100% 94%, 97% 95.5%, 93% 93%, 88% 96%,
        83% 94%, 78% 97%, 73% 95%, 68% 98%,
        63% 95.5%, 58% 98.5%, 53% 96%, 48% 99%,
        43% 96.5%, 38% 99.5%, 33% 97%, 28% 100%,
        23% 97.5%, 18% 99%, 13% 97%, 8% 99.5%,
        3% 97.5%, 0% 100%
    );
    z-index: 4;
}

.stratum-industrial .stratum-content {
    padding: 10vh 4vw 6vh;
    padding-left: 50px;
}

.stratum-industrial .stratum-title {
    color: #1E1A16;
}

/* Industrial texture: coarser grain + coal speckles */
.stratum-industrial .stratum-texture {
    background:
        radial-gradient(circle at 15% 25%, rgba(30, 26, 22, 0.06) 1px, transparent 1px),
        radial-gradient(circle at 45% 60%, rgba(30, 26, 22, 0.05) 1.5px, transparent 1.5px),
        radial-gradient(circle at 75% 15%, rgba(30, 26, 22, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 90% 80%, rgba(30, 26, 22, 0.06) 2px, transparent 2px),
        radial-gradient(circle at 30% 90%, rgba(30, 26, 22, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 60% 40%, rgba(30, 26, 22, 0.04) 1.5px, transparent 1.5px),
        radial-gradient(circle at 85% 55%, rgba(30, 26, 22, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 20% 70%, rgba(30, 26, 22, 0.06) 2px, transparent 2px),
        radial-gradient(circle at 50% 10%, rgba(30, 26, 22, 0.04) 1px, transparent 1px),
        radial-gradient(circle at 10% 50%, rgba(30, 26, 22, 0.05) 1.5px, transparent 1.5px);
}

.stratum-industrial .stratum-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Two-column layout for Industrial */
.two-column {
    display: grid;
    grid-template-columns: 65% 35%;
    gap: 0;
    margin: 1rem 0;
}

.col-main {
    padding-right: 2rem;
    border-right: 1px solid rgba(30, 26, 22, 0.15);
}

.col-side {
    padding-left: 2rem;
    font-size: 0.9em;
}

.col-side .annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    line-height: 1.7;
    opacity: 0.75;
}

/* ==========================================================================
   STRATUM 3: Middle / Classical - #9C8B73
   ========================================================================== */
.stratum-classical {
    background: #9C8B73;
    color: #F5EDE0;
    min-height: 110vh;
    margin-top: -80px;
    clip-path: polygon(
        0% 1.5%, 4% 0%, 9% 2.5%, 14% 0.5%, 19% 3%,
        24% 1%, 29% 3.5%, 34% 1.5%, 39% 4%,
        44% 2%, 49% 4.5%, 54% 2.5%, 59% 5%,
        64% 3%, 69% 5.5%, 74% 3.5%, 79% 6%,
        84% 4%, 89% 6.5%, 94% 4.5%, 100% 5.5%,
        100% 95%, 96% 96.5%, 91% 94%, 86% 97%,
        81% 94.5%, 76% 97.5%, 71% 95%, 66% 98%,
        61% 95.5%, 56% 98.5%, 51% 96%, 46% 99%,
        41% 96.5%, 36% 99.5%, 31% 97%, 26% 100%,
        21% 97.5%, 16% 99%, 11% 97%, 6% 99.5%,
        0% 98%
    );
    z-index: 3;
}

.stratum-classical .stratum-content {
    padding: 10vh 4vw 6vh;
    padding-left: 50px;
}

.stratum-classical .stratum-title {
    color: #F5EDE0;
}

/* Classical texture: limestone lamination */
.stratum-classical .stratum-texture {
    background:
        repeating-linear-gradient(
            0deg,
            #9C8B73 0px,
            #9C8B73 3px,
            #A39582 3px,
            #A39582 4px
        );
    opacity: 0.3;
}

.stratum-classical .stratum-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Single column with artifact margins */
.single-column-with-artifacts {
    position: relative;
    max-width: 700px;
    margin: 0 auto;
}

.artifact-margin {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.artifact-margin.artifact-left {
    float: left;
    margin-right: 2rem;
    margin-left: -1rem;
}

.artifact-margin.artifact-right {
    float: right;
    margin-left: 2rem;
    margin-right: -1rem;
}

.artifact-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    opacity: 0.5;
    text-align: center;
    display: block;
    max-width: 80px;
    line-height: 1.3;
}

/* Classical artifact SVG colors */
.stratum-classical .artifact-path {
    stroke: #C49B3C;
    opacity: 0.6;
}

.stratum-classical .fossil-path {
    stroke: #B29058;
}

/* ==========================================================================
   STRATUM 4: Deep / Ancient - #5C4A3A
   ========================================================================== */
.stratum-ancient {
    background: #5C4A3A;
    color: #D9CFC2;
    min-height: 120vh;
    margin-top: -80px;
    clip-path: polygon(
        0% 2%, 5% 0.5%, 10% 3%, 15% 1%, 20% 3.5%,
        25% 1.5%, 30% 4%, 35% 2%, 40% 4.5%,
        45% 2.5%, 50% 5%, 55% 3%, 60% 5.5%,
        65% 3.5%, 70% 6%, 75% 4%, 80% 6.5%,
        85% 4.5%, 90% 7%, 95% 5%, 100% 6%,
        100% 94.5%, 95% 96%, 90% 93.5%, 85% 96.5%,
        80% 94%, 75% 97%, 70% 94.5%, 65% 97.5%,
        60% 95%, 55% 98%, 50% 95.5%, 45% 98.5%,
        40% 96%, 35% 99%, 30% 96.5%, 25% 99.5%,
        20% 97%, 15% 100%, 10% 97.5%, 5% 99%,
        0% 97%
    );
    z-index: 2;
}

.stratum-ancient .stratum-content {
    padding: 10vh 4vw 6vh;
    padding-left: 50px;
}

.stratum-ancient .stratum-title {
    color: #D9CFC2;
}

/* Ancient texture: heavy grain + mineral deposits */
.stratum-ancient .stratum-texture {
    background:
        radial-gradient(circle at 20% 30%, rgba(123, 158, 168, 0.04) 8px, transparent 8px),
        radial-gradient(circle at 65% 55%, rgba(123, 158, 168, 0.03) 12px, transparent 12px),
        radial-gradient(circle at 40% 80%, rgba(123, 158, 168, 0.04) 6px, transparent 6px),
        radial-gradient(circle at 80% 20%, rgba(123, 158, 168, 0.03) 10px, transparent 10px),
        radial-gradient(circle at 10% 65%, rgba(123, 158, 168, 0.04) 9px, transparent 9px),
        radial-gradient(circle at 55% 10%, rgba(123, 158, 168, 0.03) 7px, transparent 7px),
        radial-gradient(circle at 90% 75%, rgba(123, 158, 168, 0.04) 11px, transparent 11px);
}

.stratum-ancient .stratum-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Dense content for Ancient stratum */
.dense-content {
    line-height: 1.75;
}

.dense-content p {
    margin-bottom: 1.2rem;
}

/* Inline artifacts */
.artifact-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 0.5rem 0;
}

.artifact-inline .artifact-label {
    max-width: 120px;
}

/* Ancient artifact SVG colors */
.stratum-ancient .artifact-path {
    stroke: #7B9EA8;
    opacity: 0.6;
}

.stratum-ancient .fossil-path {
    stroke: #7B8A8E;
}

/* ==========================================================================
   STRATUM 5: Bedrock / Mythic - #1A1412
   ========================================================================== */
.stratum-bedrock {
    background: #1A1412;
    color: #A69080;
    min-height: 100vh;
    margin-top: -80px;
    clip-path: polygon(
        0% 3%, 5% 1%, 10% 4%, 15% 1.5%, 20% 4.5%,
        25% 2%, 30% 5%, 35% 2.5%, 40% 5.5%,
        45% 3%, 50% 6%, 55% 3.5%, 60% 6.5%,
        65% 4%, 70% 7%, 75% 4.5%, 80% 7.5%,
        85% 5%, 90% 8%, 95% 5.5%, 100% 7%,
        100% 100%, 0% 100%
    );
    z-index: 1;
}

.stratum-bedrock .stratum-content {
    padding: 12vh 4vw 6vh;
    padding-left: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.stratum-bedrock .stratum-title {
    color: #A69080;
    text-align: center;
}

/* Bedrock texture: vertical fracture lines */
.stratum-bedrock .stratum-texture {
    background:
        repeating-linear-gradient(
            87deg,
            transparent,
            transparent 80px,
            rgba(166, 144, 128, 0.02) 80px,
            rgba(166, 144, 128, 0.02) 81px
        ),
        repeating-linear-gradient(
            88deg,
            transparent,
            transparent 140px,
            rgba(166, 144, 128, 0.015) 140px,
            rgba(166, 144, 128, 0.015) 141px
        ),
        repeating-linear-gradient(
            86deg,
            transparent,
            transparent 200px,
            rgba(166, 144, 128, 0.025) 200px,
            rgba(166, 144, 128, 0.025) 201px
        );
}

.stratum-bedrock .stratum-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Bedrock center content */
.bedrock-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.spiral-container {
    margin: 2rem 0;
}

.spiral-svg {
    opacity: 0.7;
}

.spiral-path {
    stroke: #6B3A5E;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3s ease-out;
}

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

.bedrock-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem; /* per DESIGN.md: IBM Plex Mono at 0.85rem */
    letter-spacing: 0.08em;
    color: #A69080;
    opacity: 0.7;
}

/* ==========================================================================
   End of Record
   ========================================================================== */
.end-of-record {
    background: #0A0A0A;
    min-height: 50vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.end-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.depth-label-final {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #A69080;
    opacity: 0.3;
}

.end-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #A69080;
    opacity: 0.3;
}

/* ==========================================================================
   Boundary Fossils
   ========================================================================== */
.boundary-fossil {
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    opacity: 0.4;
}

/* Fossil colors - midway between adjacent strata accents */
.fossil-ammonite .fossil-path {
    stroke: #738D6E;
}

.fossil-leaf .fossil-path {
    stroke: #B09028;
}

.fossil-trilobite .fossil-path {
    stroke: #A39582;
}

.fossil-cell .fossil-path {
    stroke: #736A4C;
}

.fossil-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-out;
}

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

/* ==========================================================================
   Artifact SVGs (Industrial)
   ========================================================================== */
.stratum-industrial .artifact-svg {
    margin-top: 1.5rem;
}

.stratum-industrial .artifact-path {
    stroke: #8B4513;
    opacity: 0.6;
}

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

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

/* ==========================================================================
   Scroll Reveal Animations
   ========================================================================== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Paragraph Spacing
   ========================================================================== */
.stratum p {
    margin-bottom: 1.5rem;
}

.stratum-surface p {
    line-height: 2.0;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 960px) {
    .measuring-tape {
        left: 5px;
    }

    .stratum-content {
        padding-left: 40px;
        padding-right: 20px;
    }

    .two-column {
        grid-template-columns: 1fr;
    }

    .col-main {
        border-right: none;
        border-bottom: 1px solid rgba(30, 26, 22, 0.15);
        padding-right: 0;
        padding-bottom: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .col-side {
        padding-left: 0;
    }

    .artifact-margin.artifact-left,
    .artifact-margin.artifact-right {
        float: none;
        margin: 1.5rem auto;
    }
}

@media (max-width: 600px) {
    .stratum-content {
        padding-left: 30px;
        padding-right: 15px;
    }

    .measuring-tape {
        left: 2px;
        transform: translateX(0);
    }

    .site-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .scroll-reveal {
        opacity: 1;
        transform: none;
        transition: opacity 0.3s ease;
    }

    .scroll-chevron {
        animation: none;
    }

    .stratum-title.animated {
        animation: none;
        letter-spacing: 0.08em;
    }

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

    .fossil-path,
    .artifact-path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }

    #tape-line {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }
}
