:root {
    --parchment: #f4ede4;
    --bone: #e8ddd0;
    --umber: #8a7a65;
    --soot: #3d3429;
    --foxglove: #9b7db8;
    --pressed-leaf: #7a9462;
    --copper-oxide: #5c8a7a;
    --cream: #faf6f0;
    --deep-archive: #2a231c;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.85;
    color: var(--umber);
    background-color: var(--parchment);
    overflow-x: hidden;
}

/* Grain Overlay */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    mix-blend-mode: multiply;
    opacity: 0.04;
}

/* Progress Thermometer */
#progress-thermometer {
    position: fixed;
    right: 20px;
    top: 15vh;
    height: 70vh;
    width: 3px;
    background: var(--bone);
    z-index: 100;
    border-left: 1px solid transparent;
    background-image: repeating-linear-gradient(
        0deg,
        var(--foxglove) 0px,
        var(--foxglove) 4px,
        transparent 4px,
        transparent 8px
    );
    background-size: 1px 200%;
    background-repeat: no-repeat;
    background-position: 0 0;
    animation: dash-crawl-vertical 20s linear infinite;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--foxglove);
    transition: height 0.1s linear;
}

#progress-moth {
    position: absolute;
    left: -9px;
    top: 0;
    transition: top 0.1s linear, transform 0.3s ease;
}

@keyframes dash-crawl-vertical {
    from { background-position: 0 0%; }
    to { background-position: 0 200%; }
}

/* Strata */
.stratum {
    position: relative;
    min-height: 100vh;
}

#stratum-one {
    height: 100vh;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 0 0 15vh min(10vw, 80px);
    background: var(--parchment);
}

#stratum-two {
    min-height: 150vh;
    padding: 15vh 0;
    background: linear-gradient(to bottom, var(--parchment), var(--bone));
}

#stratum-three {
    min-height: 150vh;
    padding: 10vh 0;
    background: var(--bone);
}

#stratum-four {
    min-height: 150vh;
    padding: 15vh 0;
    background: linear-gradient(to bottom, var(--bone), var(--soot));
    color: var(--bone);
}

#stratum-four .datestamp {
    color: var(--copper-oxide);
}

#stratum-four .body-text {
    color: var(--bone);
}

#stratum-five {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10vh 0;
    background: var(--deep-archive);
}

/* Content Column */
.stratum-content {
    width: min(680px, 85vw);
    margin-left: min(10vw, 80px);
}

/* Title Gate */
.halftone-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--umber) 0.5px, transparent 0.5px);
    background-size: 12px 12px;
    opacity: 0.08;
    animation: halftone-drift 30s ease-in-out infinite alternate;
}

@keyframes halftone-drift {
    from { background-position: 0 0; }
    to { background-position: 6px 6px; }
}

.title-gate {
    position: relative;
    z-index: 2;
}

.title-main {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(4rem, 12vw, 9rem);
    letter-spacing: 0.08em;
    color: var(--soot);
    text-transform: uppercase;
    opacity: 0;
    animation: fade-in 1200ms ease 400ms forwards;
}

.title-sub {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 2rem;
    color: var(--umber);
    margin-top: 0.5rem;
    opacity: 0;
    animation: fade-in 1200ms ease 1000ms forwards;
}

.title-rule {
    border: none;
    height: 2px;
    margin-top: 2rem;
    width: 0;
    position: relative;
    animation: rule-expand 2000ms cubic-bezier(0.25, 1, 0.5, 1) 1600ms forwards;
    overflow: visible;
}

.title-rule::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        90deg,
        var(--umber) 0px,
        var(--umber) 8px,
        transparent 8px,
        transparent 16px
    );
    background-size: 200% 2px;
    animation: dash-crawl 20s linear infinite, border-color-cycle 12s ease-in-out infinite;
}

@keyframes fade-in {
    to { opacity: 1; }
}

@keyframes rule-expand {
    to { width: min(400px, 60vw); }
}

@keyframes dash-crawl {
    from { background-position: 0% 100%; }
    to { background-position: 200% 100%; }
}

@keyframes border-color-cycle {
    0%, 100% { filter: hue-rotate(0deg); }
    33% { filter: hue-rotate(20deg); }
    66% { filter: hue-rotate(-10deg); }
}

/* Index Entries */
.index-entry {
    margin-bottom: 4rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--umber);
}

.datestamp {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: clamp(0.7rem, 1.5vw, 0.95rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--umber);
    display: block;
    margin-bottom: 0.5rem;
}

.index-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--soot);
    margin-bottom: 0.5rem;
}

.index-abstract {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--umber);
}

/* Reveal Animation */
.reveal-block {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 700ms cubic-bezier(0.25, 1, 0.5, 1), transform 700ms cubic-bezier(0.25, 1, 0.5, 1);
}

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

/* Specimen Frames */
.specimen-frame {
    position: relative;
    width: 100%;
    height: 70vh;
    margin-bottom: 8vh;
    padding: 3px;
    background: transparent;
}

.specimen-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px dashed var(--umber);
    animation: specimen-border-color 12s ease-in-out infinite;
}

@keyframes specimen-border-color {
    0%, 100% { border-color: var(--umber); }
    33% { border-color: var(--foxglove); }
    66% { border-color: var(--copper-oxide); }
}

.specimen-frame:hover::before {
    animation-duration: 6s;
    border-color: var(--foxglove);
}

.specimen-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at center, var(--cream) 0%, var(--bone) 70%),
        repeating-radial-gradient(circle at 50% 50%, transparent 0px, transparent 1px, rgba(138,122,101,0.03) 1px, rgba(138,122,101,0.03) 2px);
    box-shadow: inset 0 0 60px rgba(58, 52, 41, 0.15);
}

.specimen-label {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--umber);
}

.moth-corner {
    position: absolute;
    transition: transform 0.8s ease;
}

.moth-tl {
    top: -12px;
    left: -12px;
}

.moth-br {
    bottom: -12px;
    right: -12px;
}

/* Technical Blocks */
.technical-block {
    margin-bottom: 5rem;
}

.body-text {
    margin-top: 1.5rem;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85em;
    letter-spacing: 0.05em;
    color: var(--copper-oxide);
    margin-top: 2rem;
    padding: 1.5rem;
    border-left: 2px solid var(--copper-oxide);
    background: rgba(42, 35, 28, 0.3);
}

/* Annotations */
.annotation {
    color: var(--foxglove);
    cursor: pointer;
    position: relative;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7em;
    padding: 0 2px;
}

.annotation:hover {
    color: var(--pressed-leaf);
}

.annotation-tooltip {
    position: absolute;
    display: none;
    background: var(--cream);
    color: var(--umber);
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 1rem 1.2rem;
    max-width: 300px;
    z-index: 500;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 250ms ease, opacity 250ms ease;
    border: 2px dashed var(--umber);
    animation: specimen-border-color 12s ease-in-out infinite;
}

.annotation-tooltip.show {
    display: block;
    transform: scale(1);
    opacity: 1;
}

/* Colophon */
.colophon-content {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    width: min(680px, 85vw);
}

.colophon-statement {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--bone);
    line-height: 2;
}

.colophon-rule {
    border: none;
    height: 2px;
    width: min(200px, 40vw);
    margin: 3rem auto;
    position: relative;
}

.colophon-rule::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        90deg,
        var(--foxglove) 0px,
        var(--foxglove) 8px,
        transparent 8px,
        transparent 16px
    );
    background-size: 200% 2px;
    animation: dash-crawl 20s linear infinite;
}

.colophon-domain {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--umber);
}

/* Margin Notes */
.margin-note {
    position: absolute;
    pointer-events: none;
}

.margin-right {
    right: min(5vw, 40px);
}

.margin-label {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--umber);
    opacity: 0.5;
    writing-mode: vertical-rl;
}

/* Circuit-Botanical SVGs */
.circuit-botanical {
    opacity: 0.15;
    transition: opacity 800ms ease, filter 800ms ease;
}

.circuit-botanical:hover {
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .margin-note {
        display: none;
    }

    #progress-thermometer {
        right: 10px;
    }

    .stratum-content {
        margin-left: 5vw;
    }

    #stratum-one {
        padding-left: 5vw;
    }
}
