/* ===== CSS Custom Properties ===== */
:root {
    --bg-primary: #f5f0e8;
    --bg-secondary: #ede7db;
    --text-primary: #2b2520;
    --text-secondary: #6b5e52;
    --accent-rose: #c4918a;
    --accent-gold: #c9a96e;
    --glitch-cyan: #00e5d0;
    --glitch-magenta: #e05090;
    --marble-light: #e8e4de;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    position: relative;
}

/* ===== Paper Grain Overlay ===== */
#paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    mix-blend-mode: multiply;
    opacity: 0.08;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ===== Pilaster Lines ===== */
#pilaster-lines {
    position: fixed;
    top: 0;
    right: calc(50% - 380px);
    width: 1px;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 40px,
        rgba(196, 145, 138, 0.3) 40px,
        rgba(196, 145, 138, 0.3) 120px,
        transparent 120px,
        transparent 180px
    );
}

/* ===== The Pedestal ===== */
#pedestal {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pedestal-inner {
    text-align: center;
}

.wordmark {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 1.5rem;
}

.wordmark .letter-block {
    display: inline-block;
    padding: 0.1em 0.15em;
    background: linear-gradient(
        135deg,
        #ffffff 0%,
        var(--marble-light) 30%,
        rgba(196, 145, 138, 0.05) 60%,
        #ffffff 100%
    );
    border: 1px solid var(--marble-light);
    box-shadow: 0 2px 8px rgba(43, 37, 32, 0.08);
    opacity: 0;
    transition: opacity 0.15s ease;
    position: relative;
}

.wordmark .letter-block.visible {
    opacity: 1;
}

.wordmark .letter-block.glitching {
    animation: glitch-block 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes glitch-block {
    0% { transform: translateX(0); }
    20% { transform: translateX(var(--glitch-x, 3px)); }
    40% { transform: translateX(calc(var(--glitch-x, 3px) * -0.5)); }
    100% { transform: translateX(0); }
}

.wordmark .letter-block .chromatic-cyan,
.wordmark .letter-block .chromatic-magenta {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    padding: 0.1em 0.15em;
}

.wordmark .letter-block .chromatic-cyan {
    color: var(--glitch-cyan);
    transform: translate(-3px, -1px);
}

.wordmark .letter-block .chromatic-magenta {
    color: var(--glitch-magenta);
    transform: translate(3px, 1px);
}

.wordmark .letter-block.glitching .chromatic-cyan,
.wordmark .letter-block.glitching .chromatic-magenta {
    opacity: 0.6;
}

.subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

.subtitle.visible {
    opacity: 1;
}

/* ===== Marble texture animation ===== */
@keyframes marble-drift {
    0% { background-position: 0 0; }
    100% { background-position: 200px 200px; }
}

.letter-block {
    animation: marble-drift 60s linear infinite;
}

/* ===== Bestiary Section ===== */
#bestiary {
    max-width: 680px;
    margin: 0 auto;
    padding: 4rem 1.5rem 6rem;
    position: relative;
}

@media (min-width: 1400px) {
    #bestiary {
        margin-left: calc(50% - 400px);
    }
}

/* ===== Bestiary Entry ===== */
.bestiary-entry {
    position: relative;
    margin-bottom: 5rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.bestiary-entry.revealed {
    opacity: 1;
    transform: translateY(0);
}

.entry-numeral {
    font-family: 'Cinzel Decorative', 'Playfair Display', serif;
    font-size: clamp(4rem, 10vw, 8rem);
    color: rgba(196, 145, 138, 0.2);
    position: sticky;
    top: 1rem;
    pointer-events: none;
    line-height: 1;
    margin-bottom: -3rem;
    z-index: 0;
}

.entry-content {
    position: relative;
    z-index: 1;
}

.entry-initial {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: 5rem;
    float: left;
    line-height: 0.85;
    margin-right: 0.15em;
    margin-top: 0.05em;
    color: var(--text-primary);
    position: relative;
}

/* Monster silhouette clip-paths */
.entry-initial[data-creature="serpent"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-rose);
    opacity: 0.15;
    clip-path: polygon(20% 0%, 40% 15%, 60% 5%, 80% 20%, 95% 40%, 85% 60%, 95% 80%, 75% 95%, 50% 85%, 30% 95%, 10% 80%, 5% 55%, 15% 35%);
}

.entry-initial[data-creature="winged"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-rose);
    opacity: 0.15;
    clip-path: polygon(50% 0%, 70% 10%, 100% 5%, 90% 30%, 100% 50%, 80% 55%, 65% 80%, 50% 100%, 35% 80%, 20% 55%, 0% 50%, 10% 30%, 0% 5%, 30% 10%);
}

.entry-initial[data-creature="amorphous"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-rose);
    opacity: 0.15;
    clip-path: polygon(30% 0%, 60% 5%, 80% 15%, 95% 35%, 90% 60%, 100% 80%, 80% 95%, 55% 100%, 30% 90%, 10% 75%, 0% 50%, 5% 30%, 15% 10%);
}

.entry-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.entry-taxonomy {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}

.entry-divider {
    margin: 1.5rem 0;
    text-align: center;
}

.fleuron {
    font-family: 'Cinzel Decorative', serif;
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin: 0 0.5rem;
    display: inline-block;
    animation: fleuron-pulse 2s ease-in-out infinite;
}

@keyframes fleuron-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.entry-description {
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.entry-note {
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding-left: 1.5rem;
    border-left: 2px solid var(--accent-gold);
}

/* ===== Section Dividers ===== */
.section-divider {
    text-align: center;
    margin: 4rem 0;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.section-divider.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Workshop Section ===== */
#workshop {
    background-color: var(--bg-secondary);
    padding: 6rem 1.5rem;
    position: relative;
}

.workshop-inner {
    max-width: 680px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.workshop-inner.revealed {
    opacity: 1;
    transform: translateY(0);
}

@media (min-width: 1400px) {
    .workshop-inner {
        margin-left: calc(50% - 400px);
    }
}

.section-header {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.workshop-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

/* ===== Closing Inscription ===== */
#inscription {
    padding: 8rem 1.5rem 6rem;
    text-align: center;
}

.inscription-inner {
    max-width: 680px;
    margin: 0 auto;
}

.inscription-line {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.inscription-line.revealed {
    opacity: 1;
    transform: translateY(0);
}

.monogram {
    font-family: 'Cinzel Decorative', serif;
    font-size: 3rem;
    color: var(--accent-gold);
    margin-top: 3rem;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.3s ease;
    opacity: 0;
    transition: opacity 0.6s ease-out, transform 0.3s ease;
}

.monogram.revealed {
    opacity: 1;
}

.monogram:hover {
    transform: scale(1.1);
}

/* ===== Glitch Flash ===== */
body.full-glitch {
    background-color: var(--glitch-cyan) !important;
}

body.full-glitch * {
    font-family: monospace !important;
}

body.full-glitch #paper-grain {
    mix-blend-mode: screen;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    #bestiary {
        padding: 2rem 1rem 4rem;
    }
    
    .entry-numeral {
        font-size: 4rem;
    }
    
    .entry-initial {
        font-size: 3.5rem;
    }
    
    #pilaster-lines {
        display: none;
    }
}
