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

:root {
    --desk-dark: #2C1E12;
    --page-cream: #F5ECD7;
    --page-aged: #EDE2C8;
    --text-primary: #1C1410;
    --accent-amber: #C4883A;
    --accent-sienna: #A0522D;
    --accent-claret: #6B1D2A;
    --glitch-red: #E63946;
    --glitch-cyan: #2EC4B6;
    --text-muted: #8B7E74;
    --brass: #B8A088;
    --brass-light: #C8B898;
    --brass-medium: #A08868;
    --leather-dark: #3E2A1E;
    --leather-mid: #4A3222;
    --leather-light: #5C3D2E;

    --glitch-intensity: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Lora', serif;
    color: var(--text-primary);
    background: var(--desk-dark);
    scroll-behavior: smooth;
}

.page-container {
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    position: relative;
}

/* Desk Surface Background */
.desk-surface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            90deg,
            #2C1E12 0px,
            #3C2A1A 2px,
            #2C1E12 4px,
            #1C1410 6px,
            #2C1E12 8px
        ),
        repeating-linear-gradient(
            0deg,
            #2C1E12 0px,
            #3A2818 3px,
            #2C1E12 6px
        );
    background-blend-mode: multiply;
    z-index: -1;
    pointer-events: none;
}

.desk-surface::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' seed='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.5;
    pointer-events: none;
}

.magazine-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    z-index: 1;
}

/* Spread Sections */
.spread {
    display: flex;
    width: 100%;
    min-height: 100vh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
}

.page {
    flex: 1;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    position: relative;
    background: linear-gradient(175deg, var(--page-cream) 0%, var(--page-aged) 100%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='linen'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='4' seed='1'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23linen)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
}

.page-left {
    border-right: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 2px 0 8px rgba(0, 0, 0, 0.08), inset -2px 0 8px rgba(255, 255, 255, 0.3);
}

.page-right {
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset -2px 0 8px rgba(0, 0, 0, 0.08), inset 2px 0 8px rgba(255, 255, 255, 0.2);
}

.page > * {
    position: relative;
    z-index: 1;
}

/* SPREAD 1: COVER */
.spread-1 .page-left {
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.masthead {
    text-align: center;
}

.title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(4rem, 12vw, 10rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--accent-amber);
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(196, 136, 58, 0.3);
    line-height: 1.1;
    margin-bottom: 20px;
}

.subtitle {
    font-family: 'Lora', serif;
    font-size: clamp(0.95rem, 1.5vw, 1.3rem);
    color: var(--text-muted);
    letter-spacing: 0.05em;
    font-style: italic;
}

/* Table of Contents */
.table-of-contents {
    text-align: left;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px dashed rgba(0, 0, 0, 0.15);
}

.toc-title {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-sienna);
    margin-bottom: 30px;
    border-bottom: 2px solid var(--accent-amber);
    padding-bottom: 15px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.toc-item {
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px 0;
}

.toc-item:hover .toc-label {
    color: var(--accent-amber);
}

.toc-label {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 0 0 auto;
    transition: color 0.3s ease;
}

.toc-dots {
    flex: 1;
    border-bottom: 1px dotted var(--text-muted);
    margin: 0 12px;
    height: 1px;
}

.toc-page {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex: 0 0 auto;
}

/* SPREAD 2: FEATURE ARTICLE */
.spread-2 .page-left {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pull-quote {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-style: italic;
    font-weight: 400;
    color: var(--accent-sienna);
    line-height: 1.3;
    text-align: center;
    max-width: 90%;
    margin: 0;
}

.feature-article {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 90%;
}

.article-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--accent-claret);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-amber);
    padding-bottom: 12px;
}

.article-body {
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    color: var(--text-primary);
    text-align: justify;
}

.article-body:first-of-type::first-letter {
    font-size: 3em;
    float: left;
    line-height: 1;
    font-weight: 700;
    color: var(--accent-amber);
    margin-right: 8px;
    margin-top: -8px;
}

/* SPREAD 3: PHOTO ESSAY */
.photo-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    justify-content: center;
    height: 100%;
}

.photo-item {
    display: flex;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.photo-item:hover {
    transform: translateY(-8px) scale(1.02);
}

.polaroid {
    background: white;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    max-width: 280px;
    transition: box-shadow 0.3s ease;
}

.photo-item:hover .polaroid {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.polaroid-image {
    width: 100%;
    aspect-ratio: 1;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.polaroid-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 8px 8px;
    pointer-events: none;
}

.polaroid-caption {
    font-family: 'Lora', serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-align: center;
    font-style: italic;
}

.polaroid-caption::before {
    content: '📌 ';
}

/* SPREAD 4: BACK MATTER */
.spread-4 .page-left {
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.colophon {
    text-align: center;
    max-width: 90%;
}

.colophon-title {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-claret);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent-amber);
    padding-bottom: 15px;
}

.colophon-text {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: 15px;
    font-style: italic;
}

.wax-seal {
    width: 120px;
    height: 120px;
    margin: 30px auto 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--brass-light), var(--accent-claret), #4A1020);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

.wax-seal::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px dashed rgba(255, 255, 255, 0.4);
    opacity: 0.6;
}

.seal-text {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 700;
    color: var(--page-cream);
    position: relative;
    z-index: 1;
}

/* Letters Section */
.spread-4 .page-right {
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 80px;
}

.letters {
    width: 100%;
    max-width: 90%;
}

.letters-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-sienna);
    margin-bottom: 30px;
    border-bottom: 2px solid var(--accent-amber);
    padding-bottom: 12px;
}

.letter-item {
    margin-bottom: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-left: 3px solid var(--accent-amber);
    position: relative;
    transform: rotate(-1deg);
}

.letter-item:nth-child(even) {
    transform: rotate(1.5deg);
    background: rgba(245, 236, 215, 0.7);
}

.letter-text {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-style: italic;
}

.letter-author {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
    font-style: normal;
    letter-spacing: 0.05em;
}

/* Fixed Elements */
.paper-clip-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 40px;
    height: 40px;
    cursor: pointer;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.paper-clip-fixed:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.paper-clip-icon {
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.1));
}

/* Bookmark Ribbon */
.bookmark-ribbon {
    position: fixed;
    top: 0;
    right: 40px;
    width: 40px;
    height: 100vh;
    z-index: 50;
    pointer-events: none;
}

.ribbon-body {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #8B1E2E 0%,
        var(--accent-claret) 20%,
        var(--brass-medium) 50%,
        var(--accent-claret) 80%,
        #6B1820 100%
    );
    box-shadow:
        inset -2px 0 4px rgba(0, 0, 0, 0.3),
        inset 2px 0 4px rgba(255, 255, 255, 0.1);
    clip-path: polygon(0 0, 90% 0, 100% 50%, 90% 100%, 0 100%);
}

.tassel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 30px;
    background: linear-gradient(
        180deg,
        var(--accent-claret) 0%,
        #5A161F 100%
    );
    border-radius: 2px;
    opacity: 0.8;
}

/* Glitch Effects Container */
.glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glitch-layer.active {
    opacity: 1;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .spread {
        flex-direction: column;
        min-height: 200vh;
    }

    .page {
        height: 50vh;
        width: 100%;
    }

    .page-left {
        border-right: none;
        border-bottom: 2px solid rgba(0, 0, 0, 0.1);
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 -2px 8px rgba(255, 255, 255, 0.3);
    }

    .page-right {
        border-left: none;
        border-top: 2px solid rgba(255, 255, 255, 0.3);
        box-shadow: inset 0 -2px 8px rgba(0, 0, 0, 0.08), inset 0 2px 8px rgba(255, 255, 255, 0.2);
    }

    .title {
        font-size: clamp(2rem, 8vw, 4rem);
    }

    .pull-quote {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }

    .table-of-contents {
        max-width: 90%;
    }

    .photo-grid {
        gap: 20px;
    }

    .polaroid {
        max-width: 200px;
    }
}

/* Animation Keyframes */
@keyframes glitch-shift {
    0% {
        transform: translate(0);
    }
    50% {
        transform: translate(8px, 0);
    }
    100% {
        transform: translate(0);
    }
}

@keyframes channel-split {
    0% {
        clip-path: inset(0);
    }
    50% {
        clip-path: inset(30% 0 30% 0);
    }
    100% {
        clip-path: inset(0);
    }
}

@keyframes phosphor-glow {
    0%, 100% {
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1), 0 0 20px rgba(196, 136, 58, 0.3);
    }
    50% {
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1), 0 0 40px rgba(196, 136, 58, 0.8), 0 0 60px rgba(196, 136, 58, 0.5);
    }
}

/* Coffee Ring Decoration */
@keyframes subtle-fade {
    0%, 100% { opacity: 0.04; }
    50% { opacity: 0.06; }
}

.coffee-ring {
    position: absolute;
    border: 2px solid var(--accent-amber);
    border-radius: 50%;
    opacity: 0.04;
    pointer-events: none;
    animation: subtle-fade 8s ease-in-out infinite;
}
