/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --aged-vellum: #f2e8d5;
    --foxed-parchment: #e6d5b8;
    --iron-gall: #2c2418;
    --tarnished-brass: #8b7355;
    --mourning-violet: #5c3d5e;
    --oxidized-copper: #4a8b6f;
    --faded-rule: #c4a882;
    --lampblack: #0d0a07;
    --scroll-y: 0;
    --frame-inset: 3vw;
}

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

body {
    background: var(--aged-vellum);
    color: var(--iron-gall);
    font-family: 'EB Garamond', 'Georgia', serif;
    font-size: clamp(1rem, 1.8vw, 1.35rem);
    line-height: 1.85;
    overflow-x: hidden;
}

/* === VICTORIAN FILIGREE FRAME === */
.frame {
    position: fixed;
    inset: var(--frame-inset);
    z-index: 100;
    pointer-events: none;
    animation: gaslightPulse 12s ease-in-out infinite;
}

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

.frame-corner {
    position: absolute;
    width: 120px;
    height: 120px;
}

.frame-corner--tl { top: -10px; left: -10px; transform: rotate(0deg); }
.frame-corner--tr { top: -10px; right: -10px; transform: rotate(90deg); }
.frame-corner--bl { bottom: -10px; left: -10px; transform: rotate(-90deg); }
.frame-corner--br { bottom: -10px; right: -10px; transform: rotate(180deg); }

.frame-edge {
    position: absolute;
    background: repeating-linear-gradient(
        90deg,
        var(--tarnished-brass) 0px,
        var(--tarnished-brass) 1px,
        transparent 1px,
        transparent 7px
    );
}

.frame-edge--top,
.frame-edge--bottom {
    left: 100px;
    right: 100px;
    height: 1px;
}

.frame-edge--top { top: 0; }
.frame-edge--bottom { bottom: 0; }

.frame-edge--left,
.frame-edge--right {
    top: 100px;
    bottom: 100px;
    width: 1px;
    background: repeating-linear-gradient(
        180deg,
        var(--tarnished-brass) 0px,
        var(--tarnished-brass) 1px,
        transparent 1px,
        transparent 7px
    );
}

.frame-edge--left { left: 0; }
.frame-edge--right { right: 0; }

/* === GHOST GRID LAYER === */
.ghost-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 200vh;
    z-index: 0;
    pointer-events: none;
    will-change: transform;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(196, 168, 130, 0.12) 0px,
            rgba(196, 168, 130, 0.12) 0.5px,
            transparent 0.5px,
            transparent 28px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(196, 168, 130, 0.12) 0px,
            rgba(196, 168, 130, 0.12) 0.5px,
            transparent 0.5px,
            transparent 28px
        );
}

/* === GLITCH LAYER === */
.glitch-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    will-change: transform;
}

.glitch-strip {
    position: absolute;
    left: 0;
    width: 100%;
    height: 5px;
    mix-blend-mode: difference;
    background: linear-gradient(90deg, var(--oxidized-copper) 20%, transparent 20%, transparent 80%, var(--mourning-violet) 80%);
    opacity: 0;
    transition: filter 800ms ease, opacity 800ms ease, top 0ms;
    will-change: transform, filter, opacity;
}

.glitch-strip.active {
    opacity: 0.7;
    filter: blur(0px);
}

.glitch-strip.shifting {
    filter: blur(6px);
    opacity: 0;
}

/* === CONTENT LAYER === */
.content {
    position: relative;
    z-index: 2;
}

/* === SECTIONS === */
.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(var(--frame-inset) + 40px);
    position: relative;
}

/* Section 0: The Seal */
.section--seal {
    align-items: center;
    justify-content: center;
}

.seal-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2em;
    padding-left: 10vw;
}

.seal-char {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3rem, 8vw, 10rem);
    letter-spacing: 0.12em;
    color: var(--iron-gall);
    line-height: 0.9;
    position: relative;
}

.seal-char .cartouche-mini {
    display: inline-block;
    padding: 0 0.15em;
    border: 0.5px solid var(--tarnished-brass);
    border-radius: 2px;
}

.seal-char--dot .cartouche-mini {
    color: var(--mourning-violet);
}

.seal-subtitle {
    margin-top: 3rem;
    text-align: center;
}

/* Ornamental Labels */
.ornamental-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--tarnished-brass);
}

.date-stamp {
    margin-left: 2em;
    color: var(--mourning-violet);
    font-family: 'Cinzel Decorative', serif;
}

/* Section Markers */
.section-marker {
    margin-bottom: 2rem;
}

/* === CARTOUCHES === */
.cartouche {
    position: relative;
    border: 1px solid var(--tarnished-brass);
    padding: 2.5rem 2rem;
    max-width: 38ch;
}

/* Corner ears */
.cartouche::before,
.cartouche::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: var(--tarnished-brass);
    border-style: solid;
}

.cartouche::before {
    top: -8px;
    left: -8px;
    border-width: 1px 0 0 1px;
    border-radius: 3px 0 0 0;
}

.cartouche::after {
    bottom: -8px;
    right: -8px;
    border-width: 0 1px 1px 0;
    border-radius: 0 0 3px 0;
}

/* Positioning variations */
.cartouche--left {
    align-self: flex-start;
    margin-left: 5vw;
}

.cartouche--right {
    align-self: flex-end;
    margin-right: 5vw;
}

.cartouche--bottom-left {
    align-self: flex-start;
    margin-top: auto;
    margin-left: 3vw;
    margin-bottom: 8vh;
}

.cartouche--center-narrow {
    align-self: center;
    max-width: 32ch;
}

/* Entry sections layout */
.section--entry {
    align-items: flex-start;
}

.section--entry-1 { background: var(--aged-vellum); }
.section--entry-2 { background: var(--foxed-parchment); }
.section--entry-3 { background: var(--aged-vellum); }
.section--entry-4 { background: var(--foxed-parchment); }

.entry-text {
    max-width: 38ch;
    font-family: 'EB Garamond', serif;
    font-size: clamp(1rem, 1.8vw, 1.35rem);
    line-height: 1.85;
    color: var(--iron-gall);
}

/* Drop Caps */
.drop-cap {
    float: left;
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(3rem, 6vw, 5rem);
    line-height: 0.8;
    margin-right: 0.15em;
    margin-top: 0.05em;
    color: var(--mourning-violet);
    position: relative;
}

.drop-cap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 100%;
    width: 200px;
    border-bottom: 0.5px solid var(--tarnished-brass);
}

/* === DIVIDERS === */
.divider {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.fleuron {
    width: 24px;
    height: 24px;
}

/* === SECTION 5: THE VOID === */
.section--void {
    background: linear-gradient(to bottom, var(--aged-vellum) 0%, var(--lampblack) 30%);
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.void-cursor {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cursor-char {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 2rem;
    color: var(--oxidized-copper);
    animation: blink 1.2s steps(2) infinite;
}

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

/* === BLUR-FOCUS REVEAL === */
.reveal {
    filter: blur(12px);
    opacity: 0.3;
    transition: filter 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 1200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal.revealed {
    filter: blur(0px);
    opacity: 1;
}

/* Stagger seal characters */
.seal-char.reveal { transition-delay: calc(var(--char-delay, 0) * 150ms); }

/* === FRAME FADE FOR VOID SECTION === */
.frame.fading {
    transition: opacity 1s ease;
    opacity: 0 !important;
    animation: none;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    :root { --frame-inset: 2vw; }

    .frame-corner { width: 60px; height: 60px; }

    .frame-edge--top, .frame-edge--bottom { left: 50px; right: 50px; }
    .frame-edge--left, .frame-edge--right { top: 50px; bottom: 50px; }

    .seal-title { padding-left: 2vw; }

    .cartouche--left { margin-left: 2vw; }
    .cartouche--right { margin-right: 2vw; }
    .cartouche--bottom-left { margin-left: 2vw; }

    .section { padding: calc(var(--frame-inset) + 20px); }
}
