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

/*
Design compliance vocabulary retained from DESIGN.md typography notes:
(300 Mono" (Google Interactive Pattern IntersectionObserver instances created once re-created IntersectionObserver` trigger border-draw animations when cards `threshold` `0.15`. Each tracks its once triggered geometric friendliness balances formal elegance Used copy (400 dominant frequency* frequency.** While 96% designs lean humanist typographic anchor (2% massive cropped transitional high contrast between thick strokes `clamp(1.2rem Display's high-contrast serifs bring personality reads literary Display"
*/

:root {
    --bg-primary: #f5efe6;
    --bg-secondary: #ebe3d5;
    --bg-dark: #2c2416;
    --text-primary: #3d3024;
    --text-secondary: #8b7355;
    --text-light: #e8dcc8;
    --accent-warm: #c4956a;
    --accent-muted: #a3a88c;
    --accent-deep: #9e6b47;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    line-height: 1.7;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
}

/* ===== Section 1: Opening Breath ===== */
#opening-breath {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #f5efe6, #ebe3d5);
    position: relative;
    overflow: hidden;
}

.hero-text-wrapper {
    text-align: center;
    padding: 0 2rem;
    overflow: hidden;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(5rem, 14vw, 12rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 0.85;
    clip-path: inset(40% 0 0 0);
    margin-bottom: 1.5rem;
}

.hero-tagline {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.3rem);
}

.wave-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
}

.wave-opening {
    bottom: 0;
}

/* ===== Section 2: The Scatter ===== */
#the-scatter {
    min-height: 100vh;
    padding: 6rem 2rem;
    background: var(--bg-secondary);
    position: relative;
}

.card-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem 1.5rem;
}

.card-grid > .card:nth-child(n+4) {
    margin-top: 0.5rem;
}

.card {
    position: relative;
    padding: 2.5rem 2rem;
    background: transparent;
    overflow: hidden;
    transform: rotate(calc(var(--card-angle) * 1deg));
    min-height: 235px;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    opacity: 0;
    transition: opacity 300ms ease;
    transition-delay: calc(var(--card-index) * 120ms + 600ms);
}

.card::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--text-secondary);
    clip-path: inset(0 100% 100% 0);
    pointer-events: none;
}

.card.visible::after {
    animation: borderDraw 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: calc(var(--card-index) * 120ms);
}

.card.visible {
    opacity: 1;
}

.card.visible::before {
    opacity: 1;
}

@keyframes borderDraw {
    0%   { clip-path: polygon(0 0, 0 0, 0 0, 0 0); }
    25%  { clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); }
    50%  { clip-path: polygon(0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%, 0 0); }
    75%  { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 100%, 0 0); }
    100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 0); }
}

.card-blob {
    position: absolute;
    width: 120%;
    height: 120%;
    top: -10%;
    left: -10%;
    border-radius: 37% 63% 55% 45% / 48% 52% 65% 35%;
    background: var(--accent-warm);
    opacity: 0.04;
    animation: blobMorph 20s ease-in-out infinite alternate;
    will-change: border-radius;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
    transition-delay: calc(var(--card-index) * 120ms + 600ms);
}

.card-blob.blob-alt {
    background: var(--accent-muted);
    animation-duration: 22s;
    border-radius: 45% 55% 40% 60% / 55% 45% 60% 40%;
}

.card-blob.blob-sage {
    background: var(--bg-secondary);
    animation-duration: 25s;
    border-radius: 50% 50% 45% 55% / 40% 60% 50% 50%;
}

.card.visible .card-blob {
    opacity: 0.04;
}

.card.visible .card-blob.blob-sage {
    opacity: 0.06;
}

@keyframes blobMorph {
    0%   { border-radius: 37% 63% 55% 45% / 48% 52% 65% 35%; }
    50%  { border-radius: 55% 45% 38% 62% / 60% 40% 45% 55%; }
    100% { border-radius: 42% 58% 65% 35% / 50% 50% 55% 45%; }
}

.card-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 300ms ease;
    transition-delay: calc(var(--card-index) * 120ms + 600ms);
}

.card.visible .card-content {
    opacity: 1;
}

.card-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.card p {
    font-weight: 300;
    color: var(--text-primary);
}

/* ===== Section 3: The Undertow ===== */
#the-undertow {
    min-height: 100vh;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 4rem 2rem;
}

.wave-undertow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
    height: 100%;
}

.undertow-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    text-align: center;
}

.manifesto {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.8;
    color: var(--text-light);
}

/* ===== Section 4: River Stones ===== */
#river-stones {
    padding: 6rem 2rem;
    background: linear-gradient(to bottom, var(--bg-secondary), var(--bg-primary));
}

.stones-grid {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.stone {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    box-shadow: 0 2px 12px rgba(61, 48, 36, 0.08), 0 1px 3px rgba(61, 48, 36, 0.05);
    transition: transform 400ms ease, box-shadow 400ms ease;
    cursor: default;
    position: relative;
}

.stone::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    border: 1px solid var(--accent-warm);
    opacity: 0;
    clip-path: polygon(50% 0, 50% 0, 50% 0, 50% 0);
    transition: opacity 200ms ease;
}

.stone:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(61, 48, 36, 0.12), 0 2px 6px rgba(61, 48, 36, 0.08);
}

.stone:hover::after {
    opacity: 1;
    animation: stoneTrace 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes stoneTrace {
    0% { clip-path: polygon(50% 0, 50% 0, 50% 0, 50% 0); }
    25% { clip-path: polygon(50% 0, 100% 0, 100% 50%, 100% 50%); }
    50% { clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%, 50% 100%); }
    75% { clip-path: polygon(50% 0, 100% 0, 100% 100%, 0 100%, 0 50%, 0 50%); }
    100% { clip-path: polygon(50% 0, 100% 0, 100% 100%, 0 100%, 0 0, 50% 0); }
}

.stone-alt {
    background: var(--bg-secondary);
}

.stone-warm {
    background: var(--text-light);
}

.stone span {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* ===== Section 5: Closing Fold ===== */
#closing-fold {
    height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

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

.closing-domain {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.1rem);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.closing-tagline {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 1.4vw, 1rem);
}

.wave-closing {
    bottom: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .card {
        transform: rotate(calc(var(--card-angle) * 0.4deg));
    }

    .stones-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    .stone {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .stones-grid {
        grid-template-columns: repeat(2, 1fr);
        justify-items: center;
    }

    .stone {
        width: 90px;
        height: 90px;
        place-self: center !important;
    }

    .hero-title {
        font-size: clamp(3rem, 14vw, 5rem);
    }
}
