:root {
    --parchment: #F4F0E8;
    --aged-ink: #3B3226;
    --dried-sage: #7C8B6F;
    --lavender-shadow: #9B8EA8;
    --pressed-rose: #B8847C;
    --protocol-green: #4ADE80;
    --terminal-dark: #0C1A0F;
    --faded-graphite: #A69F95;
    --font-body: 'Lora', Georgia, serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--parchment);
    color: var(--aged-ink);
    font-family: var(--font-body);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Pressed-flower texture overlay (subtle botanical paper texture) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 3px 4px at 12% 8%, rgba(184, 132, 124, 0.06) 50%, transparent 50%),
        radial-gradient(ellipse 4px 3px at 35% 22%, rgba(124, 139, 111, 0.05) 50%, transparent 50%),
        radial-gradient(ellipse 2px 5px at 58% 15%, rgba(155, 142, 168, 0.04) 50%, transparent 50%),
        radial-gradient(ellipse 5px 3px at 78% 32%, rgba(184, 132, 124, 0.05) 50%, transparent 50%),
        radial-gradient(ellipse 3px 4px at 22% 45%, rgba(124, 139, 111, 0.04) 50%, transparent 50%),
        radial-gradient(ellipse 4px 6px at 65% 55%, rgba(155, 142, 168, 0.05) 50%, transparent 50%),
        radial-gradient(ellipse 3px 3px at 88% 62%, rgba(184, 132, 124, 0.04) 50%, transparent 50%),
        radial-gradient(ellipse 5px 4px at 42% 72%, rgba(124, 139, 111, 0.05) 50%, transparent 50%),
        radial-gradient(ellipse 3px 5px at 8% 85%, rgba(155, 142, 168, 0.04) 50%, transparent 50%),
        radial-gradient(ellipse 4px 3px at 52% 92%, rgba(184, 132, 124, 0.05) 50%, transparent 50%),
        radial-gradient(circle at 25% 40%, rgba(184, 132, 124, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 75% 60%, rgba(155, 142, 168, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================
   DATA BLEED OPENING OVERLAY
   ============================ */
#data-bleed-overlay {
    position: fixed;
    inset: 0;
    background: var(--terminal-dark);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

#data-bleed-overlay.resolving {
    animation: bleedResolve 800ms ease-out forwards;
}

#data-bleed-overlay.hidden {
    display: none;
}

@keyframes bleedResolve {
    0% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
    15% {
        clip-path: polygon(0 10%, 100% 0, 100% 100%, 0 100%);
    }
    30% {
        clip-path: polygon(0 25%, 100% 15%, 100% 100%, 0 100%);
    }
    50% {
        clip-path: polygon(0 45%, 100% 35%, 100% 100%, 0 100%);
    }
    70% {
        clip-path: polygon(0 65%, 100% 55%, 100% 100%, 0 100%);
    }
    85% {
        clip-path: polygon(0 80%, 100% 75%, 100% 100%, 0 100%);
    }
    100% {
        clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%);
        opacity: 0;
    }
}

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

.data-bleed-hud-ring {
    width: 120px;
    height: 120px;
    border: 1px solid var(--protocol-green);
    border-radius: 50%;
    margin: 0 auto 2rem;
    opacity: 0.3;
    animation: hudSpin 4s linear infinite;
    border-top-color: transparent;
    border-right-color: transparent;
}

@keyframes hudSpin {
    to { transform: rotate(360deg); }
}

#hex-stream {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--protocol-green);
    opacity: 0.6;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 2rem;
    overflow: hidden;
    height: 120px;
    text-align: left;
}

.data-bleed-status {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.data-bleed-status span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--protocol-green);
    letter-spacing: 0.08em;
    opacity: 0.8;
}

/* ============================
   HUD PERIPHERAL ELEMENTS
   ============================ */
.hud-left {
    position: fixed;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hud-left.active {
    opacity: 0.15;
}

.hud-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--protocol-green);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 0.1em;
}

.hud-right {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.6s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.hud-right.active {
    opacity: 0.18;
}

.hud-reticle svg {
    animation: reticleSpin 20s linear infinite;
}

@keyframes reticleSpin {
    to { transform: rotate(360deg); }
}

.hud-block-height,
.hud-timestamp {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--protocol-green);
    letter-spacing: 0.05em;
}

.hud-bottom {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.6s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.hud-bottom.active {
    opacity: 0.12;
}

.hud-tracking-line {
    width: 80px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--protocol-green), transparent);
}

.hud-depth {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--protocol-green);
    letter-spacing: 0.08em;
}

/* ============================
   JOURNAL MAIN COLUMN
   ============================ */
.journal {
    max-width: 640px;
    margin-left: 15%;
    padding: 4rem 2rem 8rem;
    position: relative;
    z-index: 1;
}

/* ============================
   HEADER
   ============================ */
.journal-header {
    padding: 6rem 0 2rem;
}

.journal-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 4vw + 0.5rem, 3.5rem);
    color: var(--aged-ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
    filter: url(#wobble);
}

.journal-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faded-graphite);
    margin-top: 1rem;
    letter-spacing: 0.02em;
}

/* ============================
   WOBBLY DIVIDERS
   ============================ */
.wobbly-divider {
    padding: 2rem 0;
    max-width: 420px;
}

.circuit-divider {
    max-width: 500px;
}

/* ============================
   FIELD ENTRIES
   ============================ */
.field-entry {
    padding: 3rem 0 4rem;
    position: relative;
}

.entry-date {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.9vw + 0.3rem, 0.85rem);
    color: var(--lavender-shadow);
    display: block;
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

.entry-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--aged-ink);
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.deep-heading {
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.08);
}

.entry-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw + 0.6rem, 1.25rem);
    line-height: 1.9;
    color: var(--aged-ink);
    margin-bottom: 1.5rem;
}

.entry-body em {
    font-style: italic;
    color: var(--pressed-rose);
}

.entry-body a {
    color: var(--pressed-rose);
    text-decoration: underline;
    text-decoration-color: rgba(184, 132, 124, 0.4);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.3s ease;
}

.entry-body a:hover {
    text-decoration-color: var(--pressed-rose);
}

.entry-body-large {
    font-size: clamp(1.05rem, 1.3vw + 0.6rem, 1.35rem);
    line-height: 2;
}

.field-entry-final {
    padding-bottom: 6rem;
}

/* ============================
   MARGIN NOTES
   ============================ */
.margin-note {
    position: absolute;
    right: -240px;
    top: 50%;
    transform: translateX(200px) translateY(-50%);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
    width: 200px;
}

.margin-note.visible {
    transform: translateX(0) translateY(-50%);
    opacity: 1;
}

.margin-data {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 0.8vw, 0.75rem);
    color: var(--dried-sage);
    opacity: 0.7;
    margin-bottom: 0.3rem;
    line-height: 1.6;
}

/* ============================
   GLITCH INTRUSIONS
   ============================ */
.glitch-intrusion {
    margin: 3rem -1rem;
    padding: 0;
    position: relative;
}

.glitch-overlay {
    background: var(--terminal-dark);
    padding: 2rem 2.5rem;
    border-radius: 2px;
    opacity: 0.92;
    border-left: 2px solid rgba(74, 222, 128, 0.3);
}

.glitch-narrow {
    padding: 1.5rem 2rem;
}

.glitch-inline {
    margin: 2rem 0;
}

.glitch-header {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--protocol-green);
    margin-bottom: 1.2rem;
    letter-spacing: 0.1em;
    opacity: 0.9;
}

.glitch-bracket {
    color: var(--protocol-green);
    opacity: 0.5;
}

.glitch-text {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.9vw + 0.3rem, 0.85rem);
    color: var(--protocol-green);
    line-height: 2;
    letter-spacing: 0.04em;
}

.glitch-active {
    color: var(--protocol-green);
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.glitch-note {
    opacity: 0.5;
    margin-top: 0.8rem;
    font-style: italic;
}

.glitch-bar {
    width: 200px;
    height: 3px;
    background: rgba(74, 222, 128, 0.15);
    margin: 1rem 0;
    border-radius: 1px;
    overflow: hidden;
}

.glitch-bar-fill {
    width: 78%;
    height: 100%;
    background: var(--protocol-green);
    border-radius: 1px;
    animation: barPulse 3s ease-in-out infinite;
}

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

/* ============================
   BOTANICAL ILLUSTRATIONS
   ============================ */
.botanical-illustration {
    margin: 3rem 0;
    padding: 2rem 0;
}

.botanical-svg {
    display: block;
    max-width: 100%;
}

.botanical-label {
    font-family: var(--font-body);
    font-size: 9px;
    fill: var(--dried-sage);
    font-style: italic;
}

.botanical-hash {
    font-family: var(--font-mono);
    font-size: 8px;
    fill: var(--dried-sage);
    text-anchor: middle;
}

.botanical-path {
    stroke: var(--aged-ink);
}

.tech-label {
    font-family: var(--font-mono);
    font-size: 9px;
    fill: var(--protocol-green);
}

.merkle-connection {
    transition: opacity 1s ease;
}

.illustration-caption {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--faded-graphite);
    margin-top: 1.5rem;
    line-height: 1.6;
}

.illustration-caption em {
    font-style: italic;
    color: var(--dried-sage);
}

.pod-glow {
    animation: podPulse 3s ease-in-out infinite;
}

@keyframes podPulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.4; }
}

/* ============================
   BLINKING CURSOR
   ============================ */
.blinking-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--protocol-green);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink 1s steps(1) infinite;
}

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

/* ============================
   FADE REVEAL ANIMATION
   ============================ */
.fade-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s ease-out, transform 0.9s ease-out;
}

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

/* ============================
   GLITCH DATA ROT EFFECT
   ============================ */
.data-rot-active .botanical-svg {
    animation: dataRot 200ms steps(2) 3;
}

@keyframes dataRot {
    0% { filter: none; }
    50% { filter: hue-rotate(80deg) saturate(2) brightness(1.1); }
    100% { filter: none; }
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1400px) {
    .margin-note {
        right: -200px;
        width: 170px;
    }
}

@media (max-width: 1200px) {
    .margin-note {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        opacity: 0.7;
        width: auto;
        margin-top: 1.5rem;
        padding-left: 1rem;
        border-left: 2px solid var(--dried-sage);
    }
    .margin-note.visible {
        transform: none;
    }
}

@media (max-width: 900px) {
    .journal {
        margin-left: 8%;
        margin-right: 5%;
    }
}

@media (max-width: 768px) {
    .journal {
        margin-left: auto;
        margin-right: auto;
        padding: 2rem 1.5rem 4rem;
    }
    .hud-left,
    .hud-right,
    .hud-bottom {
        display: none;
    }
    .journal-header {
        padding: 3rem 0 1.5rem;
    }
    .glitch-intrusion {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .entry-body {
        font-size: 1rem;
        line-height: 1.8;
    }
    .entry-heading {
        font-size: 1.5rem;
    }
    .entry-body-large {
        font-size: 1.05rem;
    }
    .botanical-illustration {
        margin: 2rem -0.5rem;
    }
}
