:root {
    --bg: #f7f3ed;
    --text: #2c2926;
    --accent: #c75b12;
    --amber: #d9943a;
    --ash: #b8b0a5;
    --deep: #1a1714;
    --umber: #6b4a2e;

    --font-display: 'Libre Baskerville', Georgia, serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'Courier Prime', 'Courier New', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.9;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

#particle-canvas {
    position: fixed;
    top: 0;
    right: 0;
    width: 40vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

.narrative {
    position: relative;
    z-index: 2;
}

/* Beats */
.beat {
    display: flex;
    align-items: flex-start;
    padding: 0 5vw;
    position: relative;
}

.beat__content {
    width: 55%;
    padding-right: 5%;
}

.beat__content--full {
    width: 100%;
    padding-right: 0;
}

.beat__margin {
    width: 40%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4rem;
}

/* Beat 1: The Root */
.beat--root {
    min-height: 100vh;
    align-items: flex-start;
    padding-top: 15vh;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 8rem);
    line-height: 1.15;
    letter-spacing: 0.01em;
    color: var(--text);
    min-height: 1.2em;
}

.wordmark .cursor {
    display: inline-block;
    width: 3px;
    height: 0.85em;
    background-color: var(--accent);
    margin-left: 2px;
    vertical-align: baseline;
    animation: blink 530ms step-end infinite;
}

.wordmark .cursor.fade-out {
    animation: cursorFade 400ms forwards;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes cursorFade {
    to { opacity: 0; }
}

.subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--ash);
    margin-top: 1.5rem;
    opacity: 0;
    transition: opacity 800ms ease;
}

.subtitle.visible {
    opacity: 1;
}

/* Typewriter Headings */
.typewriter-heading {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 2rem;
    min-height: 1.5em;
}

.typewriter-heading .cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background-color: var(--accent);
    margin-left: 1px;
    vertical-align: baseline;
    animation: blink 530ms step-end infinite;
}

.typewriter-heading .cursor.fade-out {
    animation: cursorFade 400ms forwards;
}

.typewriter-heading--sub {
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    margin-bottom: 1rem;
}

/* Body text */
.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.9;
    max-width: 100%;
    color: var(--text);
}

/* Grain line dividers */
.grain-line {
    display: flex;
    align-items: center;
    width: 60%;
    padding: 3rem 5vw;
    gap: 8px;
}

.grain-line__rule {
    flex: 1;
    height: 1px;
    background-color: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s ease;
}

.grain-line.animated .grain-line__rule {
    transform: scaleX(1);
}

.grain-line__knot {
    opacity: 0;
    transition: opacity 0.4s ease 0.5s;
}

.grain-line.animated .grain-line__knot {
    opacity: 1;
}

/* Beat 2: The Grain */
.beat--grain {
    min-height: 120vh;
    padding-top: 6rem;
}

.beat--grain .beat__margin {
    position: sticky;
    top: 20vh;
    height: fit-content;
}

.illustration--grain {
    width: 280px;
    height: 280px;
}

/* SVG draw animation */
.illustration[data-animate="draw"] circle,
.illustration[data-animate="draw"] path,
.illustration[data-animate="draw"] line,
.illustration[data-animate="draw"] ellipse {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.illustration.drawn circle,
.illustration.drawn path,
.illustration.drawn line,
.illustration.drawn ellipse {
    stroke-dashoffset: 0;
}

/* Beat 3: The Craft */
.beat--craft {
    min-height: 140vh;
    padding-top: 6rem;
}

.beat--craft .beat__margin {
    position: sticky;
    top: 10vh;
    height: fit-content;
    padding-top: 4rem;
}

.vignette {
    margin-bottom: 8rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease;
}

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

.illustration--plane {
    width: 240px;
}

.illustration--dovetail {
    width: 180px;
}

.illustration--bowl {
    width: 220px;
}

/* Beat 4: The Ring */
.beat--ring {
    min-height: 100vh;
    padding-top: 6rem;
    justify-content: center;
}

.ring-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 2rem auto;
}

.illustration--ring {
    width: 100%;
    height: auto;
}

.illustration--ring circle {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.illustration--ring circle.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.ring-labels {
    position: absolute;
    inset: 0;
}

.ring-label {
    position: absolute;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--umber);
    opacity: 0;
    transition: opacity 0.5s ease;
    transform: translateX(-50%);
}

.ring-label.visible {
    opacity: 1;
}

/* Beat 5: The Bark */
.beat--bark {
    min-height: 90vh;
    padding-top: 6rem;
}

.materials-list {
    list-style: none;
}

.material-item {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--text);
    line-height: 2.2;
    opacity: 0;
    transition: opacity 300ms ease;
}

.material-item.visible {
    opacity: 1;
}

.material-item .typed-text {
    font-family: var(--font-mono);
    font-style: normal;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--accent);
}

.material-item .typed-text .cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background-color: var(--accent);
    margin-left: 1px;
    vertical-align: baseline;
    animation: blink 530ms step-end infinite;
}

/* Beat 6: The Canopy */
.beat--canopy {
    min-height: 80vh;
    padding-top: 6rem;
}

.quote {
    margin-bottom: 4rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 700ms ease, transform 700ms ease;
}

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

.quote__text {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    line-height: 1.4;
    color: var(--text);
    margin-bottom: 0.8rem;
}

.quote__cite {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--ash);
    font-style: normal;
}

/* Beat 7: The Seed */
.beat--seed {
    min-height: 100vh;
    padding-top: 20vh;
}

.contact-email {
    margin-bottom: 2rem;
}

.closing-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    color: var(--text);
    opacity: 0;
    transition: opacity 800ms ease;
}

.closing-wordmark.visible {
    opacity: 1;
}

.end-breath {
    height: 30vh;
}

/* Mobile */
@media (max-width: 768px) {
    #particle-canvas {
        display: none;
    }

    .beat {
        flex-direction: column;
    }

    .beat__content {
        width: 90%;
    }

    .beat__margin {
        width: 90%;
        position: relative;
        top: auto;
        margin-top: 2rem;
    }

    .beat--craft .beat__margin,
    .beat--grain .beat__margin {
        position: relative;
        top: auto;
    }

    .grain-line {
        width: 90%;
    }

    .illustration--grain {
        width: 200px;
        height: 200px;
    }
}
