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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    background: #F2EDE4;
    color: #1C1915;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === Progress Bar === */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: #6B1A3A;
    z-index: 100;
    transition: none;
}

/* === Chapter Base === */
.chapter {
    min-height: 100vh;
    position: relative;
}

/* === Reveal Animations === */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

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

/* === Underline Draw === */
.animate-underline {
    position: relative;
    display: inline-block;
}

.animate-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 3px;
    background: #6B1A3A;
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-underline.drawn::after {
    width: 100%;
}

/* === Wabi-Sabi Texture (Cracks) === */
.chapter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background:
        linear-gradient(47deg, transparent 49.5%, rgba(107, 99, 88, 0.08) 49.5%, rgba(107, 99, 88, 0.08) 50.5%, transparent 50.5%),
        linear-gradient(133deg, transparent 49.7%, rgba(107, 99, 88, 0.06) 49.7%, rgba(107, 99, 88, 0.06) 50.3%, transparent 50.3%);
    background-size: 800px 600px, 1200px 900px;
    background-position: 100px 200px, 500px 100px;
    z-index: 0;
}

/* =========================
   Chapter 1: The Threshold
   ========================= */
#threshold {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    scroll-snap-align: start;
    background: #F2EDE4;
    /* Aged linen texture */
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(107, 99, 88, 0.03) 2px, rgba(107, 99, 88, 0.03) 3px),
        repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(107, 99, 88, 0.02) 3px, rgba(107, 99, 88, 0.02) 4px);
}

.threshold-content {
    position: relative;
    z-index: 1;
    padding-left: clamp(2rem, 8vw, 10rem);
    width: 100%;
}

.hero-text {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(6rem, 18vw, 20rem);
    letter-spacing: -0.03em;
    line-height: 0.9;
    color: #1C1915;
}

.quest-suffix {
    display: block;
    margin-top: 2rem;
    margin-left: clamp(10rem, 40vw, 50rem);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6B6358;
}

/* =========================
   Chapter 2: The Exhibition
   ========================= */
#exhibition {
    padding: 15vh 0;
    scroll-snap-align: start;
}

.exhibition-group {
    display: grid;
    grid-template-columns: 3fr 7fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 4vw, 4rem);
    margin-bottom: 40vh;
    align-items: start;
}

.exhibition-group:last-child {
    margin-bottom: 0;
}

.exhibition-text {
    padding-top: 4rem;
}

.chapter-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 5rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #1C1915;
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Source Serif 4', serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #6B6358;
    max-width: 30ch;
}

/* === Photo Frames === */
.photo-frame {
    width: 100%;
    aspect-ratio: 4 / 5;
    position: relative;
    border: 1px solid #6B6358;
    padding: 12px;
    will-change: filter;
    contain: layout style paint;
}

.photo-frame::before {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(107, 99, 88, 0.3);
    pointer-events: none;
    z-index: 2;
}

.photo-inner {
    width: 100%;
    height: 100%;
    position: relative;
    filter: url(#grain);
    box-shadow: inset 0 0 80px rgba(15, 13, 10, 0.5);
    overflow: hidden;
    background: linear-gradient(135deg, #3A3530 0%, #5A524A 40%, #4A443E 100%);
}

.exhibition-group:nth-child(2) .photo-inner {
    background: linear-gradient(160deg, #4A443E 0%, #3A3530 50%, #5A524A 100%);
}

.exhibition-group:nth-child(3) .photo-inner {
    background: linear-gradient(110deg, #5A524A 0%, #4A443E 35%, #3A3530 100%);
}

.photo-stain {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(107, 26, 58, 0.07) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Duotone tints: Aged Sapphire #1E3A5F, Oxidized Emerald #2D5F4A */
.exhibition-group:nth-child(1) .photo-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #1E3A5F26 0%, transparent 100%);
}

.exhibition-group:nth-child(2) .photo-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #2D5F4A1F 0%, transparent 100%);
}

.exhibition-group:nth-child(3) .photo-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #1E3A5F1A 0%, #2D5F4A14 100%);
}

/* =========================
   Chapter 3: The Archive
   ========================= */
#archive {
    padding: 15vh 0;
    scroll-snap-align: start;
    position: relative;
    /* Cross-stitch grid background */
    /* Cross-stitch grid in Tarnished Gold #B8943E at low opacity */
    background-image:
        repeating-linear-gradient(0deg, transparent 0px, transparent 29px, #B8943E0F 29px, #B8943E0F 30px),
        repeating-linear-gradient(90deg, transparent 0px, transparent 29px, #B8943E0F 29px, #B8943E0F 30px);
    background-color: #F2EDE4;
}

.archive-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 4vw, 4rem);
}

.archive-block {
    margin: 8vh 0;
}

.archive-block.align-left {
    text-align: left;
    max-width: 65%;
}

.archive-block.align-right {
    text-align: right;
    margin-left: auto;
    max-width: 65%;
}

.archive-text {
    font-family: 'Source Serif 4', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    line-height: 1.6;
    color: #1C1915;
}

.hand-rule {
    display: block;
    width: 100%;
    height: 4px;
    margin: 4vh 0;
}

/* Diamond chain divider between chapters */
#exhibition::after {
    content: '';
    display: block;
    width: 100%;
    height: 40px;
    margin-top: 10vh;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 14px, rgba(107, 26, 58, 0.08) 14px, rgba(107, 26, 58, 0.08) 15px),
        repeating-linear-gradient(-45deg, transparent, transparent 14px, rgba(107, 26, 58, 0.08) 14px, rgba(107, 26, 58, 0.08) 15px);
}

/* =========================
   Chapter 4: The Seal
   ========================= */
#seal {
    background: #0F0D0A;
    color: #F2EDE4;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    position: relative;
}

#seal::before {
    display: none;
}

.seal-transition {
    position: absolute;
    top: -30vh;
    left: 0;
    right: 0;
    height: 30vh;
    background: linear-gradient(to bottom, transparent, #0F0D0A);
    pointer-events: none;
}

.seal-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.seal-text {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: -0.03em;
    line-height: 0.9;
    color: #F2EDE4;
}

.seal-text::after {
    background: #6B1A3A;
    transition: width 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.seal-year {
    margin-top: 3rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6B6358;
}

/* === Responsive === */
@media (max-width: 768px) {
    .exhibition-group {
        grid-template-columns: 1fr;
        margin-bottom: 20vh;
    }

    .exhibition-text {
        padding-top: 0;
    }

    .photo-frame {
        max-width: 85%;
    }

    .archive-block.align-left,
    .archive-block.align-right {
        max-width: 90%;
    }

    .quest-suffix {
        margin-left: clamp(4rem, 20vw, 20rem);
    }
}
