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

:root {
    --inkwell: #0e0b07;
    --parchment: #f5efe6;
    --gilt: #c9a84c;
    --oxblood: #8b1a1a;
    --verdigris: #2d3a2e;
    --leather: #6b5b4a;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--inkwell);
    color: var(--parchment);
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    line-height: 1.75;
    overflow-x: hidden;
    cursor: default;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* === NOISE & VIGNETTE OVERLAYS === */
.noise-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 200;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.vignette-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 150;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(14,11,7,0.6) 100%);
}

/* === HUD FRAME === */
.hud-top, .hud-bottom, .hud-left, .hud-right {
    position: fixed;
    z-index: 100;
    background: var(--inkwell);
}

.hud-top {
    top: 0; left: 0; right: 0;
    height: 40px;
    border-bottom: 1px solid rgba(201,168,76,0.3);
}

.hud-bottom {
    bottom: 0; left: 0; right: 0;
    height: 40px;
    border-top: 1px solid rgba(201,168,76,0.3);
}

.hud-left {
    top: 0; left: 0; bottom: 0;
    width: 40px;
    border-right: 1px solid rgba(201,168,76,0.3);
}

.hud-right {
    top: 0; right: 0; bottom: 0;
    width: 40px;
    border-left: 1px solid rgba(201,168,76,0.3);
}

.hud-top svg, .hud-bottom svg, .hud-left svg, .hud-right svg {
    display: block;
}

/* === HUD NAVIGATION === */
.hud-nav {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 40px;
    display: flex;
    align-items: center;
    gap: 2rem;
    z-index: 101;
}

.nav-tab {
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--parchment);
    text-decoration: none;
    letter-spacing: 0.05em;
    opacity: 0.6;
    transition: opacity 0.3s, color 0.3s;
    cursor: pointer;
    white-space: nowrap;
}

.nav-tab:hover, .nav-tab.active {
    opacity: 1;
    color: var(--gilt);
}

/* === CORNER ORNAMENTS === */
.corner {
    position: fixed;
    z-index: 101;
    pointer-events: none;
    opacity: 0.8;
}

.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; }
.corner-bl { bottom: 0; left: 0; }
.corner-br { bottom: 0; right: 0; }

/* === MARGINALIA GUTTER === */
.marginalia-gutter {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 40px;
    z-index: 90;
    pointer-events: none;
}

.marginalia-left {
    left: 0;
}

.marginalia-right {
    right: 0;
}

.margin-note {
    position: absolute;
    font-family: 'Fira Code', monospace;
    font-size: 0.6rem;
    font-weight: 300;
    color: var(--gilt);
    opacity: 0;
    transition: opacity 1.5s ease;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.marginalia-left .margin-note {
    left: 5px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.marginalia-right .margin-note {
    right: 5px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.margin-note.visible {
    opacity: 0.5;
}

/* === MAIN VIEWPORT === */
.viewport {
    padding: 50px;
    position: relative;
    z-index: 1;
}

/* === PLATES === */
.plate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    opacity: 0;
    filter: blur(4px) saturate(0);
    transform: translateY(20px);
    transition: opacity 800ms ease-out, filter 800ms ease-out, transform 800ms ease-out;
}

.plate.revealed {
    opacity: 1;
    filter: blur(0) saturate(1);
    transform: translateY(0);
}

.plate.glitch-enter {
    animation: glitch-resolve 200ms ease-out;
}

.plate-alt {
    background: rgba(45,58,46,0.15);
}

.plate-content {
    max-width: 1100px;
    width: 100%;
}

.plate-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* === INTRO PLATE === */
.wordmark {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.12em;
    color: var(--gilt);
    text-shadow: 0 0 8px rgba(201,168,76,0.3), 0 0 30px rgba(201,168,76,0.1);
    margin-bottom: 0.25em;
}

.wordmark-sub {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--parchment);
    opacity: 0.7;
    letter-spacing: 0.3em;
    margin-bottom: 2rem;
}

.intro-text {
    max-width: 600px;
    color: var(--parchment);
    margin-bottom: 3rem;
    opacity: 0.85;
}

.scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
}

.scroll-hint .fira {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gilt);
}

.scroll-arrow {
    font-size: 1.5rem;
    color: var(--gilt);
    animation: bounce-arrow 2s ease-in-out infinite;
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* === SECTION DIVIDERS === */
.section-divider {
    margin: 1rem 0;
    display: flex;
    justify-content: center;
}

/* === GRIMOIRE SPREAD === */
.grimoire-spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.spread-visual {
    position: relative;
}

/* === GLITCH BLOCK === */
.glitch-block {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    border: 1px solid rgba(201,168,76,0.2);
    cursor: crosshair;
}

.glitch-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.glitch-red {
    background: linear-gradient(135deg, var(--oxblood) 0%, rgba(139,26,26,0.3) 40%, transparent 70%);
    transform: translate(-2px, 1px);
    animation: chromatic-red 6s ease-in-out infinite;
}

.glitch-green {
    background: linear-gradient(225deg, var(--verdigris) 0%, rgba(45,58,46,0.4) 40%, transparent 70%);
    transform: translate(1px, -1px);
    animation: chromatic-green 6s ease-in-out infinite;
}

.glitch-cream {
    background: linear-gradient(45deg, transparent 30%, rgba(245,239,230,0.15) 50%, transparent 70%);
    transform: translate(1px, 2px);
    animation: chromatic-cream 6s ease-in-out infinite;
}

@keyframes chromatic-red {
    0%, 100% { transform: translate(-2px, 1px); }
    25% { transform: translate(-3px, 0px); }
    50% { transform: translate(-1px, 2px); }
    75% { transform: translate(-2px, -1px); }
}

@keyframes chromatic-green {
    0%, 100% { transform: translate(1px, -1px); }
    25% { transform: translate(2px, -2px); }
    50% { transform: translate(0px, -1px); }
    75% { transform: translate(3px, 0px); }
}

@keyframes chromatic-cream {
    0%, 100% { transform: translate(1px, 2px); }
    25% { transform: translate(0px, 3px); }
    50% { transform: translate(2px, 1px); }
    75% { transform: translate(1px, 3px); }
}

.scan-lines {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(14,11,7,0.15) 2px,
        rgba(14,11,7,0.15) 4px
    );
    pointer-events: none;
}

.corruption-strip {
    position: absolute;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, 
        var(--oxblood) 0%, 
        var(--gilt) 15%, 
        var(--verdigris) 30%, 
        transparent 50%, 
        var(--parchment) 70%, 
        var(--leather) 85%, 
        var(--inkwell) 100%
    );
    opacity: 0.4;
    animation: corruption-drift 8s linear infinite;
}

@keyframes corruption-drift {
    0% { transform: translateX(-10%); }
    100% { transform: translateX(10%); }
}

/* === ROMAN NUMERALS === */
.roman-numeral {
    position: absolute;
    top: -1rem;
    left: -1rem;
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 500;
    color: var(--gilt);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.6;
}

/* === GAME TEXT === */
.game-title {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 3rem);
    letter-spacing: 0.08em;
    color: var(--gilt);
    text-shadow: 0 0 8px rgba(201,168,76,0.3);
    margin-bottom: 0.5rem;
}

.game-desc {
    margin-bottom: 1rem;
    color: var(--parchment);
    opacity: 0.9;
}

.drop-cap {
    float: left;
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: 3.5em;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.05em;
    color: var(--gilt);
    text-shadow: 0 0 8px rgba(201,168,76,0.3), 1px 1px 0 rgba(201,168,76,0.15);
}

.footnote-mark {
    color: var(--oxblood);
    font-weight: 700;
    cursor: crosshair;
}

.margin-annotation {
    font-family: 'Caveat', cursive;
    font-size: 0.9em;
    color: var(--leather);
    font-style: italic;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(201,168,76,0.2);
}

.game-meta {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 300;
    color: var(--leather);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 1rem;
}

.fira {
    font-family: 'Fira Code', monospace;
}

/* === COLOPHON === */
.colophon-title {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 400;
    font-size: clamp(1.5rem, 4vw, 3rem);
    letter-spacing: 0.08em;
    color: var(--gilt);
    text-shadow: 0 0 8px rgba(201,168,76,0.3);
    margin: 1rem 0 2rem;
}

.colophon-text {
    max-width: 550px;
    margin-bottom: 2rem;
    opacity: 0.85;
}

.colophon-members {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2rem;
}

.member-name {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 400;
    font-size: 1.2rem;
    color: var(--parchment);
    letter-spacing: 0.1em;
}

.member-divider {
    color: var(--gilt);
    opacity: 0.5;
}

.colophon-closing {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--parchment);
    margin: 1rem 0;
    opacity: 0.8;
}

.colophon-year {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    font-weight: 300;
    color: var(--gilt);
    letter-spacing: 0.2em;
    opacity: 0.5;
    margin-top: 1rem;
}

/* === GLITCH RESOLVE ANIMATION === */
@keyframes glitch-resolve {
    0% { clip-path: inset(20% 0 30% 0); opacity: 0.4; }
    15% { clip-path: inset(0 0 60% 0); opacity: 0.7; }
    30% { clip-path: inset(40% 0 0 0); opacity: 0.5; }
    50% { clip-path: inset(10% 0 10% 0); opacity: 0.8; }
    70% { clip-path: inset(0 0 5% 0); opacity: 0.9; }
    100% { clip-path: inset(0); opacity: 1; }
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .grimoire-spread {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .margin-annotation {
        background: rgba(14,11,7,0.8);
        padding: 0.8rem 1rem;
        border-left: 2px solid var(--gilt);
        transform: rotate(-1deg);
        box-shadow: 3px 3px 10px rgba(0,0,0,0.3);
    }
}

@media (max-width: 768px) {
    .hud-top, .hud-bottom { height: 20px; }
    .hud-left, .hud-right { width: 20px; }
    .viewport { padding: 25px; }
    .plate { padding: 2rem 1rem; }

    .corner svg {
        width: 60px;
        height: 60px;
    }

    .hud-nav {
        gap: 0.8rem;
    }

    .nav-tab {
        font-size: 0.7rem;
    }

    .marginalia-gutter {
        display: none;
    }

    .drop-cap {
        font-size: 2.5em;
    }

    .glitch-block {
        aspect-ratio: 16/9;
    }

    .corruption-strip {
        animation: none;
    }
}
