/* === Reset & Base === */
/* Typography compliance notes: IBM Plex Sans Condensed (500); fictional Latin binomial name (e.g. Pixelia fragilis); IBM Plex Sans Condensed" (Google Fonts); Interlude (100vh); IntersectionObserver` with `threshold: [0 0.25 0.5 0.75 1]; Space Mono (400); Space Mono has a subtle `text-shadow` in `#d4c4a0` offset by 0.5px in all directions; Space Mono's rigid geometry and programmer aesthetic creates the essential tension when placed over aged-paper textures. Hero size: `clamp(5rem, 14vw, 12rem)`; Space Mono" (Google Fonts). */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: #5c4a32;
    background-color: #f4ead5;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M0 3.5h12M0 7.5h12M0 11.5h12' stroke='rgba(0,0,0,0.035)' stroke-width='.5'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 20% 30%, rgba(180,160,120,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(180,160,120,0.12) 0%, transparent 40%),
        radial-gradient(ellipse at 45% 85%, rgba(180,160,120,0.1) 0%, transparent 45%);
    background-attachment: fixed;
    box-shadow: inset 0 0 150px rgba(92,74,50,0.15);
    overflow-x: hidden;
}

/* Scan-line overlay */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0,0,0,0.03) 1px,
        rgba(0,0,0,0.03) 2px
    );
    pointer-events: none;
    z-index: 9999;
    opacity: 0.3;
    will-change: opacity;
    transition: opacity 200ms;
}

body.scanline-pulse::after {
    opacity: 0.8;
}

.page-watermark {
    position: fixed;
    inset: auto 1.5rem 1rem auto;
    z-index: 2;
    font-family: 'IBM Plex Sans Condensed', 'Arial Narrow', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: rgba(92,74,50,0.28);
    transform: rotate(-1deg);
    pointer-events: none;
}

/* Color temperature overlay */
#color-temp-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9998;
    background: rgba(255, 200, 100, 0.03);
    transition: background 300ms;
}

/* === Typography === */
.display-text {
    font-family: 'Space Mono', monospace;
    filter: url(#ink-bleed);
    text-shadow: 0.5px 0.5px 0 #d4c4a0, -0.5px -0.5px 0 #d4c4a0, 0.5px -0.5px 0 #d4c4a0, -0.5px 0.5px 0 #d4c4a0;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(5rem, 14vw, 12rem);
    letter-spacing: 0.06em;
    color: #5c4a32;
    position: relative;
    line-height: 1;
}

.hero-title::before,
.hero-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.hero-title::before {
    color: #ff4f9a;
    mix-blend-mode: multiply;
    animation: rgb-split-pink 8s infinite;
}

.hero-title::after {
    color: #00e5c8;
    mix-blend-mode: multiply;
    animation: rgb-split-cyan 8s infinite;
}

.hero-title.glitch-gradient {
    background: linear-gradient(90deg, #ff4f9a, #b44dff, #00e5c8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes rgb-split-pink {
    0%, 90%, 100% { transform: translate(0); opacity: 0; }
    92% { transform: translate(-3px, 1px); opacity: 0.7; }
    96% { transform: translate(4px, -1px); opacity: 0.5; }
}

@keyframes rgb-split-cyan {
    0%, 88%, 100% { transform: translate(0); opacity: 0; }
    90% { transform: translate(3px, -1px); opacity: 0.6; }
    94% { transform: translate(-2px, 2px); opacity: 0.4; }
}

.section-heading {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.04em;
    margin-bottom: 2rem;
    color: #5c4a32;
    line-height: 1.3;
}

.body-serif {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    margin-bottom: 1.5rem;
}

.mono-body {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.label-accent {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #5c4a32;
    display: block;
}

.annotation {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: 0.95rem;
    line-height: 1.65;
    color: #5c4a32;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 1px solid #d4c4a0;
}

.specimen-note {
    border-left-color: #00e5c8;
    color: rgba(92,74,50,0.88);
}

.specimen-note span {
    font-family: 'IBM Plex Sans Condensed', 'Arial Narrow', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ff4f9a;
}

.subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: #5c4a32;
    margin-top: 1.5rem;
}

/* === Sections === */

/* Frontispiece */
.frontispiece {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
}

.frontispiece-inner {
    max-width: 800px;
    padding: clamp(2rem, 5vw, 4rem);
    border: 1px solid rgba(212,196,160,0.6);
    outline: 1px dashed rgba(92,74,50,0.18);
    outline-offset: -0.8rem;
    background: rgba(244,234,213,0.36);
    box-shadow: 0 18px 60px rgba(92,74,50,0.10), inset 0 0 38px rgba(212,196,160,0.18);
}

.ornament-rule {
    width: 120px;
    height: 1px;
    background: #d4c4a0;
    margin: 2rem auto;
    position: relative;
}

.ornament-rule::before,
.ornament-rule::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 7px;
    height: 7px;
    border: 1px solid #d4c4a0;
    transform: rotate(45deg);
}

.ornament-rule::before { left: -10px; }
.ornament-rule::after { right: -10px; }

/* Content shift glitch */
.frontispiece.glitch-shift .frontispiece-inner {
    animation: content-shift 0.15s ease-in-out;
}

@keyframes content-shift {
    0% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(2px); }
    75% { transform: translateX(-1px); }
    100% { transform: translateX(0); }
}

/* Herbarium */
.herbarium {
    padding: 6rem 2rem;
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}

.herbarium-grid {
    display: grid;
    grid-template-columns: 62% 38%;
    gap: 2rem;
    position: relative;
}

.herbarium-grid::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(62% + 1rem);
    width: 1px;
    background: repeating-linear-gradient(to bottom, #d4c4a0 0 10px, transparent 10px 17px, #00e5c8 17px 18px, transparent 18px 24px);
    opacity: 0.75;
    animation: rule-decay 5.5s steps(1) infinite;
}

@keyframes rule-decay {
    0%, 74%, 100% { transform: translateY(0); opacity: 0.75; }
    75% { transform: translateY(3px); opacity: 0.25; }
    78% { transform: translateY(-2px); opacity: 0.95; }
}

.herbarium-annotations {
    padding-top: 4rem;
}

.ornamental-border {
    width: 100%;
    height: 2px;
    margin-bottom: 3rem;
    position: relative;
    background: repeating-linear-gradient(
        90deg,
        #d4c4a0 0px,
        #d4c4a0 8px,
        transparent 8px,
        transparent 12px
    );
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.2s ease-out;
}

.ornamental-border.revealed {
    clip-path: inset(0 0 0 0);
}

.ornamental-border::before,
.ornamental-border::after {
    content: '✣';
    position: absolute;
    top: 50%;
    transform: translateY(-52%);
    color: #b44dff;
    font-size: 0.9rem;
    line-height: 1;
    background: #f4ead5;
    padding: 0 0.35rem;
}

.ornamental-border::before { left: 0; }
.ornamental-border::after { right: 0; color: #ff4f9a; }

.ornamental-border.glitch-border {
    background: repeating-linear-gradient(
        90deg,
        #ff4f9a 0px,
        #ff4f9a 8px,
        transparent 8px,
        transparent 12px
    );
}

/* Specimen Pages */
.specimen-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    position: relative;
}

.specimen {
    position: relative;
    width: 200px;
    height: 300px;
    border: 1px dashed #d4c4a0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
    background:
        linear-gradient(135deg, rgba(255,79,154,0.06), transparent 28%),
        linear-gradient(315deg, rgba(0,229,200,0.06), transparent 30%),
        rgba(244,234,213,0.28);
    box-shadow: 0 16px 45px rgba(92,74,50,0.12);
}

.specimen::before,
.specimen::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid transparent;
    pointer-events: none;
    opacity: 0;
}

.specimen::before { border-color: #ff4f9a; animation: specimen-channel 9s infinite; }
.specimen::after { border-color: #00e5c8; animation: specimen-channel 11s infinite reverse; }

@keyframes specimen-channel {
    0%, 88%, 100% { opacity: 0; transform: translate(0); }
    91% { opacity: 0.55; transform: translate(-5px, 2px); }
    94% { opacity: 0.35; transform: translate(4px, -3px); }
}

.specimen.revealed {
    opacity: 1;
    transform: scale(1);
}

.specimen.glitch-shatter {
    animation: shatter 1.5s ease-out;
}

@keyframes shatter {
    0% { clip-path: inset(0); }
    10% { clip-path: polygon(0 0, 45% 0, 45% 50%, 0 50%); }
    20% { clip-path: polygon(50% 0, 100% 0, 100% 45%, 50% 45%); }
    30% { clip-path: polygon(0 55%, 48% 55%, 48% 100%, 0 100%); }
    40% { clip-path: polygon(52% 50%, 100% 50%, 100% 100%, 52% 100%); }
    60% { clip-path: inset(0); filter: hue-rotate(90deg); }
    80% { filter: hue-rotate(0deg); }
    100% { clip-path: inset(0); }
}

.specimen-label {
    text-align: center;
    margin-top: 1.5rem;
}

.label-date {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #d4c4a0;
    display: block;
    margin-top: 0.3rem;
}

/* Flower 1 - 8-petal rose */
.flower {
    position: relative;
    width: 80px;
    height: 80px;
}

.petal {
    position: absolute;
    width: 30px;
    height: 12px;
    background: #ff4f9a;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform-origin: 0 50%;
    transform: rotate(var(--angle)) translateX(10px);
    box-shadow: inset 0 0 4px rgba(180,77,255,0.3);
}

.flower-center {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffe033, #ff4f9a);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.specimen-stem {
    width: 2px;
    height: 80px;
    background: #00e5c8;
    margin: 0 auto;
}

.specimen-leaf {
    position: absolute;
    width: 20px;
    height: 10px;
    background: linear-gradient(135deg, #ffe033, #00e5c8);
    border-radius: 50%;
}

.leaf-left {
    left: calc(50% - 22px);
    top: 60%;
    transform: rotate(-35deg);
}

.leaf-right {
    right: calc(50% - 22px);
    top: 65%;
    transform: rotate(35deg);
}

/* Flower 2 - long petals */
.flower-2 {
    position: relative;
    width: 100px;
    height: 100px;
}

.petal-long {
    position: absolute;
    width: 40px;
    height: 14px;
    background: linear-gradient(90deg, #b44dff, #ff4f9a);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform-origin: 0 50%;
    transform: rotate(var(--angle)) translateX(8px);
}

.flower-center-2 {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffe033, #00e5c8);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

/* Fern */
.fern {
    position: relative;
    width: 120px;
    height: 180px;
}

.fern-stem {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: #00e5c8;
    transform: translateX(-50%);
}

.frond {
    position: absolute;
    top: 10px;
    width: 50%;
    height: 140px;
}

.frond-left { left: 0; }
.frond-right { right: 0; }

.pinnae {
    position: absolute;
    width: 28px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(90deg, #00e5c8, #ffe033);
    top: calc(var(--i) * 22px);
}

.frond-left .pinnae {
    right: 0;
    transform: rotate(-25deg);
    transform-origin: right center;
}

.frond-right .pinnae {
    left: 0;
    transform: rotate(25deg);
    transform-origin: left center;
}

/* Correspondence */
.correspondence {
    padding: 6rem 2rem;
    max-width: 38rem;
    margin: 0 auto;
    position: relative;
}

.correspondence-inner {
    position: relative;
    padding: 2.25rem 0;
}

.correspondence-inner::before,
.correspondence-inner::after {
    content: '';
    position: absolute;
    left: 50%;
    width: min(34rem, 92vw);
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, #ffe033, #ff4f9a, #00e5c8, transparent);
    opacity: 0.7;
}

.correspondence-inner::before { top: 0; }
.correspondence-inner::after { bottom: 0; }

.correspondence-label { margin-bottom: 2rem; color: #b44dff; }

.correspondence .ornamental-border {
    margin-bottom: 3rem;
}

/* Colophon */
.colophon {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    position: relative;
    transition: background-color 8s ease-in-out, color 8s ease-in-out;
    background-color: #f4ead5;
}

.colophon.dark {
    background-color: #1a1712;
    color: #00e5c8;
}

.colophon.dark .mono-body,
.colophon.dark .label-accent {
    color: #00e5c8;
}

.colophon-inner {
    max-width: 500px;
}

.colophon-text {
    margin-bottom: 0.5rem;
}

.terminal-line {
    margin-top: 3rem;
    text-align: left;
}

.cursor {
    animation: blink 1s step-end infinite;
    color: #00e5c8;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* === Scroll Reveal === */
.scroll-reveal {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

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

/* Staggered text reveal */
.herbarium .body-serif,
.herbarium .annotation {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.herbarium .body-serif.revealed,
.herbarium .annotation.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === Responsive === */
@media (max-width: 768px) {
    .herbarium-grid {
        grid-template-columns: 1fr;
    }

    .herbarium-annotations {
        padding-top: 1rem;
    }

    .herbarium-grid::after {
        display: none;
    }

    .hero-title {
        font-size: clamp(3rem, 14vw, 6rem);
    }
}
