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

:root {
    --parchment: #f4efe6;
    --dark-umber: #3b302a;
    --warm-bark: #5c4a3a;
    --terracotta: #c2704f;
    --sage: #9aab8f;
    --lavender: #a8919e;
    --warm-stone: #d6cec2;
    --pencil: #c4b5a0;
    --muted-gray: #8a7e6d;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--parchment);
    color: var(--dark-umber);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
}

/* ===== Scroll Container ===== */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

/* ===== Spread Base ===== */
.spread {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

.spread-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 24px;
    padding: 48px;
    min-height: 100vh;
    align-content: start;
}

/* ===== Grid Lines Background ===== */
.spread-1,
.spread-2,
.spread-3 {
    background-image:
        repeating-linear-gradient(
            90deg,
            rgba(196, 181, 160, 0.15) 0px,
            rgba(196, 181, 160, 0.15) 1px,
            transparent 1px,
            transparent calc(12.5% - 12px)
        );
    background-color: var(--parchment);
}

.spread-4 {
    background: var(--parchment);
}

/* ===== Spread 1: The Brief ===== */
.spread-1 .spread-grid {
    align-content: center;
    grid-template-rows: auto auto 1fr;
}

.hero-title {
    grid-column: 1 / 6;
    grid-row: 1;
}

.hero-title h1 {
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.02em;
    color: var(--dark-umber);
    border: 3px solid var(--dark-umber);
    padding: 16px 24px;
    display: inline-block;
}

.hero-subtitle {
    grid-column: 1 / 5;
    grid-row: 2;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.9;
    margin-top: 24px;
    color: var(--dark-umber);
}

.compass-incomplete {
    grid-column: 6 / 9;
    grid-row: 2 / 4;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 48px;
}

/* ===== Spread 2: The Sketch ===== */
.spread-2 .spread-grid {
    grid-template-columns: repeat(8, 1fr);
    align-content: center;
}

.sketch-text {
    grid-column: 1 / 5;
    max-width: 38ch;
    padding-right: 24px;
}

.sketch-text h2 {
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.02em;
    margin-bottom: 24px;
    color: var(--dark-umber);
}

.sketch-text p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.9;
    margin-bottom: 1.5em;
    color: var(--dark-umber);
}

.sketch-divider {
    grid-column: 5 / 6;
    border-left: 3px solid var(--warm-bark);
    height: 70%;
    align-self: center;
    justify-self: center;
}

.sketch-illustration {
    grid-column: 5 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 80vh;
}

.sketch-illustration svg {
    max-height: 70vh;
    width: auto;
}

/* ===== Spread 3: The Iteration ===== */
.spread-3 .spread-grid {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: auto 1fr;
    align-content: start;
    padding-top: 48px;
    padding-bottom: 48px;
    position: relative;
}

.iteration-title {
    grid-column: 1 / 5;
    grid-row: 1;
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.02em;
    margin-bottom: 32px;
    color: var(--dark-umber);
}

.proto-card {
    background: var(--warm-stone);
    border: 3px solid var(--warm-bark);
    padding: 24px;
    box-shadow: 6px 6px 0 var(--terracotta);
    position: relative;
}

.card-version {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: var(--muted-gray);
    display: block;
    margin-bottom: 12px;
}

.tool-icon {
    display: block;
    margin-bottom: 12px;
}

.proto-card p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.7;
    color: var(--dark-umber);
}

.incomplete-border {
    border-right: none;
}

.card-1 {
    grid-column: 1 / 4;
    grid-row: 2;
    z-index: 1;
}

.card-2 {
    grid-column: 3 / 6;
    grid-row: 2;
    margin-top: 60px;
    z-index: 2;
}

.card-3 {
    grid-column: 5 / 8;
    grid-row: 2;
    margin-top: 20px;
    z-index: 3;
}

.card-4 {
    grid-column: 2 / 5;
    grid-row: 3;
    margin-top: -40px;
    z-index: 4;
}

.card-5 {
    grid-column: 5 / 9;
    grid-row: 3;
    margin-top: -20px;
    z-index: 5;
}

/* Iteration marks pseudo-elements */
.card-1::before {
    content: '~';
    position: absolute;
    top: -12px;
    right: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.2rem;
    color: var(--terracotta);
}

.card-3::after {
    content: '// wip';
    position: absolute;
    bottom: -18px;
    left: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted-gray);
}

.card-5::before {
    content: '>';
    position: absolute;
    top: -12px;
    left: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1rem;
    color: var(--sage);
}

/* ===== Spread 4: The Emergence ===== */
.spread-4 .spread-grid {
    align-content: center;
    justify-items: center;
    text-align: center;
}

.emergence-compass {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.emergence-text {
    grid-column: 1 / -1;
    margin-top: 48px;
}

.emergence-domain {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--muted-gray);
    display: block;
    margin-bottom: 16px;
}

.emergence-phrase {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    line-height: 1.9;
    color: var(--dark-umber);
}

/* ===== Animations ===== */
.hero-title,
.hero-subtitle,
.compass-incomplete,
.sketch-text,
.sketch-illustration,
.iteration-title,
.proto-card,
.emergence-compass,
.emergence-text {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease;
    transition-delay: calc(var(--stagger-index, 0) * 200ms);
}

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

/* SVG drawing animation */
.draw-line {
    stroke-dasharray: var(--path-length, 500);
    stroke-dashoffset: var(--path-length, 500);
    transition: stroke-dashoffset 2s ease;
}

.draw-active .draw-line {
    stroke-dashoffset: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .spread-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 24px;
    }

    .hero-title {
        grid-column: 1 / -1;
    }

    .hero-subtitle {
        grid-column: 1 / -1;
    }

    .compass-incomplete {
        grid-column: 2 / 5;
        grid-row: 3;
        justify-content: center;
        padding-bottom: 24px;
    }

    .sketch-text {
        grid-column: 1 / -1;
        max-width: none;
        padding-right: 0;
    }

    .sketch-divider {
        display: none;
    }

    .sketch-illustration {
        grid-column: 1 / -1;
    }

    .iteration-title {
        grid-column: 1 / -1;
    }

    .card-1, .card-2, .card-3, .card-4, .card-5 {
        grid-column: 1 / -1;
        margin-top: 0;
    }

    .card-2 { margin-top: 0; }
    .card-4 { margin-top: 0; }
}
