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

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

body {
    background-color: #f4edd8;
    color: #3b2e1e;
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* === FLOATING ELEMENTS === */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floater {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

.floater-1 {
    width: 40px;
    height: 40px;
    background: #4a7c72;
    opacity: 0.18;
    top: 15%;
    left: 10%;
    animation: float1 45s ease-in-out infinite;
}

.floater-2 {
    width: 25px;
    height: 25px;
    background: #c4983a;
    opacity: 0.2;
    top: 40%;
    left: 80%;
    border-radius: 4px;
    transform: rotate(45deg);
    animation: float2 38s ease-in-out infinite;
}

.floater-3 {
    width: 35px;
    height: 35px;
    background: #b5573a;
    opacity: 0.15;
    top: 65%;
    left: 25%;
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    animation: float3 52s ease-in-out infinite;
}

.floater-4 {
    width: 20px;
    height: 50px;
    background: #c4983a;
    opacity: 0.2;
    top: 80%;
    left: 60%;
    border-radius: 50%;
    animation: float4 42s ease-in-out infinite;
}

.floater-5 {
    width: 30px;
    height: 30px;
    background: #4a7c72;
    opacity: 0.22;
    top: 25%;
    left: 55%;
    border-radius: 50% 50% 50% 0;
    animation: float5 35s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(80px, -40px); }
    50% { transform: translate(30px, 60px); }
    75% { transform: translate(-50px, 20px); }
}

@keyframes float2 {
    0%, 100% { transform: rotate(45deg) translate(0, 0); }
    25% { transform: rotate(45deg) translate(-60px, 50px); }
    50% { transform: rotate(45deg) translate(40px, 80px); }
    75% { transform: rotate(45deg) translate(70px, -30px); }
}

@keyframes float3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(50px, 40px); }
    50% { transform: translate(-40px, -50px); }
    75% { transform: translate(-80px, 30px); }
}

@keyframes float4 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-30px, -60px); }
    50% { transform: translate(60px, -20px); }
    75% { transform: translate(20px, 50px); }
}

@keyframes float5 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(40px, 70px); }
    50% { transform: translate(-60px, 30px); }
    75% { transform: translate(50px, -40px); }
}

/* === SPREAD BASE === */
.spread {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
}

/* === SPREAD 0 — THE COVER === */
.spread-cover {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
}

.cover-letter {
    width: 40%;
    max-width: 320px;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.cover-letter.visible {
    opacity: 1;
}

.puzzle-p {
    width: 100%;
    height: auto;
}

.p-piece {
    transform: translate(0, 0);
    transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 1.2s ease-out;
}

.p-piece.scattered {
    opacity: 0;
}

.p-piece-1.scattered { transform: translate(-30px, 20px); }
.p-piece-2.scattered { transform: translate(40px, -30px); }
.p-piece-3.scattered { transform: translate(20px, 40px); }
.p-piece-4.scattered { transform: translate(-40px, -20px); }
.p-piece-5.scattered { transform: translate(30px, 30px); }
.p-piece-6.scattered { transform: translate(-20px, 40px); }
.p-piece-7.scattered { transform: translate(50px, -10px); }
.p-piece-8.scattered { transform: translate(-30px, 30px); }

.cover-domain {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: center center;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(0.875rem, 1.5vw, 1.125rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a6b5a;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.8s ease-out 0.4s;
}

.cover-domain.visible {
    opacity: 1;
}

.cover-domain span {
    display: inline-block;
    transform: translateY(10px);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease-out;
}

.cover-domain.visible span {
    transform: translateY(0);
    opacity: 1;
}

.cover-subhead {
    position: absolute;
    bottom: 15vh;
    left: 40px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out 1s, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1s;
}

.cover-subhead.visible {
    opacity: 1;
    transform: translateY(0);
}

.cover-subhead p {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: #3b2e1e;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.underline-draw {
    display: block;
    width: 260px;
    height: 8px;
    margin-top: 8px;
}

.underline-path {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    transition: stroke-dashoffset 1.2s ease-out 1.4s;
}

.cover-subhead.visible .underline-path {
    stroke-dashoffset: 0;
}

/* === SPREAD 1 — THE INDEX === */
.spread-index {
    min-height: 100vh;
    display: flex;
    gap: 60px;
    padding-top: 80px;
    padding-bottom: 80px;
    background-color: #e8dfca;
}

.index-left {
    width: 40%;
    flex-shrink: 0;
}

.index-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: #3b2e1e;
    margin-bottom: 40px;
}

.index-entry {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #bfb8a8;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.entry-number {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: #b5573a;
    line-height: 1.2;
    flex-shrink: 0;
    width: 36px;
}

.entry-text h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #3b2e1e;
    margin-bottom: 2px;
}

.entry-text p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 0.9rem;
    color: #7a6b5a;
    line-height: 1.5;
}

.entry-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-left: auto;
}

.index-right {
    width: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tessellation-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.tess-piece {
    transform: translate(0, 0);
    transition: transform 2s cubic-bezier(0.22, 1, 0.36, 1), opacity 2s ease-out;
}

.tess-piece.scattered {
    opacity: 0;
}

/* === SPREAD DIVIDER === */
.spread-divider {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px;
}

.divider-svg {
    width: 100%;
    height: 30px;
}

/* === SPREAD 2 — THE FEATURE === */
.spread-feature {
    min-height: 150vh;
    display: flex;
    gap: 60px;
    padding-top: 80px;
    padding-bottom: 80px;
}

.feature-pullquote {
    width: 33%;
    flex-shrink: 0;
    position: sticky;
    top: 20vh;
    height: fit-content;
}

.feature-pullquote blockquote {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #b5573a;
}

.feature-body {
    width: 67%;
}

.feature-lede {
    font-size: clamp(1.1rem, 1.4vw, 1.3rem);
    line-height: 1.6;
    margin-bottom: 2em;
    color: #3b2e1e;
}

.feature-body > p {
    margin-bottom: 1.8em;
}

/* Puzzle Diagrams */
.puzzle-diagram {
    margin: 2.5em 0;
    padding: 24px;
    text-align: center;
}

.puzzle-diagram svg {
    max-width: 250px;
    width: 100%;
    height: auto;
}

.diagram-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease-out;
}

.puzzle-diagram.drawn .diagram-path {
    stroke-dashoffset: 0;
}

.diagram-caption {
    display: block;
    margin-top: 12px;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    color: #7a6b5a;
    line-height: 1.5;
}

/* === SPREAD 3 — THE GALLERY === */
.spread-gallery {
    min-height: 100vh;
    padding-top: 60px;
    padding-bottom: 60px;
    background-color: #e8dfca;
}

.gallery-text-above,
.gallery-text-below {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 0;
}

.gallery-intro,
.gallery-outro {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: #7a6b5a;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.gallery-band {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    padding: 20px 0;
    position: sticky;
    top: 10vh;
    z-index: 1;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.gallery-band::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex-shrink: 0;
    width: 320px;
}

.gallery-image {
    position: relative;
    overflow: hidden;
    filter: sepia(0.25) contrast(0.9) brightness(0.95) saturate(0.7);
    transition: filter 0.4s ease-out;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
}

.gallery-image:hover {
    filter: sepia(0.1) contrast(0.95) brightness(1) saturate(0.85);
}

.gallery-placeholder {
    width: 100%;
    height: auto;
    display: block;
}

.grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    background-size: 128px 128px;
    pointer-events: none;
}

.gallery-caption {
    display: block;
    margin-top: 10px;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    color: #7a6b5a;
    line-height: 1.5;
}

/* === SPREAD 4 — THE COLOPHON === */
.spread-colophon {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 80px;
    padding-bottom: 80px;
}

.colophon-mark {
    width: 160px;
    margin-bottom: 40px;
}

.puzzle-p-complete {
    width: 100%;
    height: auto;
}

.colophon-text {
    max-width: 480px;
}

.colophon-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.02em;
    color: #3b2e1e;
    margin-bottom: 20px;
}

.colophon-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1rem;
    line-height: 1.65;
    color: #3b2e1e;
    margin-bottom: 20px;
}

.colophon-credits {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a6b5a;
    margin-bottom: 16px;
}

.colophon-contact {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    color: #4a7c72;
}

.colophon-rule {
    width: 100%;
    max-width: 1200px;
    margin-top: 60px;
    padding: 0 40px;
}

.final-rule-svg {
    width: 100%;
    height: 8px;
}

.final-rule-path {
    stroke-dasharray: 1300;
    stroke-dashoffset: 1300;
    transition: stroke-dashoffset 2s ease-out;
}

.colophon-rule.drawn .final-rule-path {
    stroke-dashoffset: 0;
}

/* === LINK UNDERLINE DRAW === */
a {
    color: #4a7c72;
    text-decoration: none;
    position: relative;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
    .spread {
        padding: 0 20px;
    }

    .spread-cover {
        flex-direction: column;
        justify-content: center;
    }

    .cover-letter {
        width: 60%;
    }

    .cover-domain {
        right: 20px;
        font-size: 0.75rem;
    }

    .cover-subhead {
        left: 20px;
        bottom: 10vh;
    }

    .spread-index {
        flex-direction: column;
        gap: 40px;
    }

    .index-left,
    .index-right {
        width: 100%;
    }

    .spread-feature {
        flex-direction: column;
        gap: 30px;
    }

    .feature-pullquote {
        width: 100%;
        position: relative;
        top: auto;
    }

    .feature-body {
        width: 100%;
    }

    .gallery-item {
        width: 260px;
    }

    .colophon-mark {
        width: 120px;
    }

    .spread-divider {
        padding: 20px;
    }
}
