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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #1a1916;
    color: #c4a882;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* === Grain Overlay === */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    filter: url(#grain);
    background: white;
}

/* === Entry Gate === */
.entry-gate {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 10vh;
    position: relative;
}

.name-container {
    display: flex;
    align-items: baseline;
}

.name-letter {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(6rem, 20vw, 18rem);
    font-weight: 400;
    letter-spacing: -0.04em;
    line-height: 0.85;
    color: #ddd5c0;
    display: inline-block;
    opacity: 0;
    transform: translateY(100vh);
    will-change: transform, opacity;
}

.name-letter.arrived {
    opacity: 1;
    transform: translateY(0);
}

/* === Timeline === */
.timeline {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 200px;
    min-height: 100vh;
}

/* Central Spine */
.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 0;
    background: #5c6b5e;
    transform: translateX(-50%);
    mask-image: linear-gradient(to bottom, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 5%, black 95%, transparent);
    transition: none;
}

.timeline.spine-visible::before {
    height: 100%;
}

/* === Timeline Node === */
.timeline-node {
    position: relative;
    width: 50%;
    min-height: 60vh;
    display: flex;
    align-items: flex-start;
    padding-top: 20vh;
    opacity: 0;
}

.timeline-node.revealed {
    opacity: 1;
}

/* Right nodes */
.node-right {
    margin-left: 50%;
    padding-left: 40px;
    --node-offset: 20px;
    transform: translateY(30px) translateX(20px);
}

.node-right.revealed {
    transform: translateY(0) translateX(0);
}

/* Left nodes */
.node-left {
    margin-right: 50%;
    padding-right: 40px;
    text-align: right;
    --node-offset: -20px;
    transform: translateY(30px) translateX(-20px);
    flex-direction: row-reverse;
}

.node-left.revealed {
    transform: translateY(0) translateX(0);
}

/* === Diamond Marker === */
.node-diamond {
    position: absolute;
    top: calc(20vh + 8px);
    width: 10px;
    height: 10px;
    background: #5c6b5e;
    transform: rotate(45deg);
    flex-shrink: 0;
    z-index: 2;
}

.node-right .node-diamond {
    left: -5px;
}

.node-left .node-diamond {
    right: -5px;
}

/* === Connector Line === */
.node-connector {
    position: absolute;
    top: calc(20vh + 12px);
    width: 40px;
    height: 2px;
}

.node-right .node-connector {
    left: 0;
}

.node-left .node-connector {
    right: 0;
}

.connector-line {
    width: 100%;
    height: 100%;
}

.connector-line line {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    transition: stroke-dashoffset 0.6s ease 0.3s;
}

.timeline-node.revealed .connector-line line {
    stroke-dashoffset: 0;
}

/* === Generative Glyph === */
.node-glyph {
    position: absolute;
    top: calc(20vh - 16px);
    width: 48px;
    height: 48px;
    opacity: 0.6;
}

.node-right .node-glyph {
    left: -68px;
}

.node-left .node-glyph {
    right: -68px;
}

.node-glyph svg {
    width: 48px;
    height: 48px;
    color: #8faa8b;
}

/* === Node Content === */
.node-content {
    max-width: 480px;
    background: #222019;
    padding: 24px 28px;
}

.node-date {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7a7468;
    display: block;
    margin-bottom: 12px;
}

.node-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #ddd5c0;
    margin-bottom: 16px;
}

.node-content p {
    color: #c4a882;
    max-width: 480px;
}

.node-left .node-content p {
    margin-left: auto;
}

/* === Colophon === */
.colophon {
    position: relative;
    text-align: center;
    padding: 80px 24px 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.colophon-diamond {
    width: 10px;
    height: 10px;
    background: #5c6b5e;
    transform: rotate(45deg);
}

.colophon-glyph {
    width: 48px;
    height: 48px;
    opacity: 0.6;
}

.colophon-glyph svg {
    width: 48px;
    height: 48px;
}

.colophon-email {
    font-family: 'DM Mono', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    color: #c4a882;
    text-decoration: none;
    position: relative;
    display: inline-block;
}

.colophon-email::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: #b56a4a;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.colophon-email:hover::after {
    width: 100%;
}

.colophon-email:hover {
    color: #b56a4a;
}

.colophon-note {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #7a7468;
}

/* === Link Hover === */
a {
    color: #c4a882;
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

a:hover {
    color: #b56a4a;
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {
    .timeline::before {
        left: 24px;
    }

    .timeline-node {
        width: calc(100% - 48px);
        margin-left: 48px !important;
        margin-right: 0 !important;
        padding-left: 24px !important;
        padding-right: 0 !important;
        text-align: left !important;
        flex-direction: row !important;
    }

    .node-right,
    .node-left {
        --node-offset: 20px;
        transform: translateY(30px) translateX(20px);
    }

    .node-right.revealed,
    .node-left.revealed {
        transform: translateY(0) translateX(0);
    }

    .node-diamond {
        left: -29px !important;
        right: auto !important;
    }

    .node-connector {
        left: -24px !important;
        right: auto !important;
        width: 24px;
    }

    .node-glyph {
        display: none;
    }

    .node-left .node-content p {
        margin-left: 0;
    }

    .node-content {
        max-width: calc(100vw - 72px);
    }
}

/* === Spring animation helper === */
.timeline-node {
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.6s ease;
}
