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

:root {
    --bg-primary: #1a1510;
    --bg-secondary: #2a2318;
    --surface: #3d3425;
    --text-primary: #e8e0d2;
    --text-secondary: #9b8d78;
    --accent: #c67832;
    --accent-secondary: #8a6b3e;
    --alert: #b33a3a;
}

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    background: var(--bg-primary);
}

body {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
    line-height: 1.72;
    letter-spacing: 0.005em;
}

/* ===== GRAIN OVERLAY ===== */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* ===== MONOGRAM ===== */
.monogram {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 900;
    cursor: pointer;
}

.monogram svg {
    stroke: var(--accent);
    stroke-width: 2;
    fill: none;
}

.monogram .strand {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: drawStrand 400ms ease-out 300ms forwards;
}

.monogram .bridge {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    opacity: 0;
}

.monogram .bridge-1 { animation: drawBridge 300ms ease-out 700ms forwards; }
.monogram .bridge-2 { animation: drawBridge 300ms ease-out 780ms forwards; }
.monogram .bridge-3 { animation: drawBridge 300ms ease-out 860ms forwards; }

.monogram .fray {
    stroke-dasharray: 15;
    stroke-dashoffset: 15;
    opacity: 0;
    animation: drawFray 500ms ease-out 1000ms forwards;
}

.monogram .fray-1 { animation-delay: 1000ms; }
.monogram .fray-2 { animation-delay: 1080ms; }
.monogram .fray-3 { animation-delay: 1160ms; }
.monogram .fray-4 { animation-delay: 1240ms; }

@keyframes drawStrand {
    to { stroke-dashoffset: 0; }
}

@keyframes drawBridge {
    0% { opacity: 0; stroke-dashoffset: 20; }
    100% { opacity: 1; stroke-dashoffset: 0; }
}

@keyframes drawFray {
    0% { opacity: 0; stroke-dashoffset: 15; }
    60% { opacity: 0.8; stroke-dashoffset: 0; }
    100% { opacity: 0.4; stroke-dashoffset: 0; }
}

/* ===== NAV OVERLAY ===== */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(26, 21, 16, 0.96);
    z-index: 800;
    display: flex;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 400ms ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.nav-inner {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-left: 35%;
}

.nav-link {
    font-family: 'Darker Grotesque', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: -0.04em;
    line-height: 0.88;
    position: relative;
    padding-left: 3rem;
    transition: color 300ms ease;
}

.nav-link::before {
    content: attr(data-index);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.65;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    margin-left: 1.5rem;
    height: 1px;
    width: 0;
    background: var(--accent);
    transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link:hover::after {
    width: 120px;
}

/* ===== SECTIONS ===== */
.section {
    position: relative;
    min-height: 100vh;
    scroll-snap-align: start;
    padding: 10vh 0;
    transition: filter 300ms cubic-bezier(0.33, 1, 0.68, 1);
}

.section-hero {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 0;
}

.section + .section {
    margin-top: 15vh;
}

.section-content {
    position: relative;
    z-index: 2;
    padding-left: 35%;
    padding-right: 10%;
    max-width: 100vw;
}

/* ===== NOISE FIELDS ===== */
.noise-field {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(4);
    image-rendering: pixelated;
    opacity: 0.3;
    z-index: 1;
    pointer-events: none;
}

/* ===== HEADLINES ===== */
.headline {
    font-family: 'Darker Grotesque', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7.5rem);
    letter-spacing: -0.04em;
    line-height: 0.88;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

.headline .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(40px) rotate(-3deg);
    transition: opacity 500ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 500ms cubic-bezier(0.16, 1, 0.3, 1),
                color 300ms ease;
}

.headline .char.space {
    width: 0.3em;
}

.headline.animate-in .char {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

.headline.animate-in .char.flash {
    color: var(--accent);
}

.headline-hero {
    font-size: clamp(3rem, 8vw, 7.5rem);
    max-width: 14ch;
}

.headline-stack-sub {
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: var(--text-secondary);
}

.headline-bleed {
    transform: translateX(-15%);
    max-width: none;
    width: 115%;
}

/* ===== SLASH LAYOUT ===== */
.slash-layout {
    transform: rotate(-2deg);
}

.slash-layout .headline-slash {
    text-align: right;
    margin-bottom: 3rem;
}

.slash-layout .body-block {
    transform: rotate(2deg);
}

/* ===== STACK LAYOUT ===== */
.stack-compressed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stack-compressed .headline {
    margin-bottom: 0.5rem;
}

.stack-compressed .stack-body {
    margin-top: 2rem;
}

/* ===== BLEED LAYOUT ===== */
.bleed-layout {
    padding-left: 35%;
    padding-right: 0;
}

.bleed-layout .headline-bleed {
    margin-left: -20%;
    width: 130%;
}

.bleed-layout .bleed-body {
    padding-right: 15%;
}

/* ===== BODY TEXT ===== */
.body-text {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--text-primary);
    max-width: 55ch;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

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

/* ===== HIGHLIGHT WORDS ===== */
.highlight-word {
    position: relative;
    font-weight: 600;
    color: var(--text-primary);
}

.highlight-word::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -2px;
    width: 0;
    height: 0;
    border-left: 0 solid transparent;
    border-right: 0 solid transparent;
    border-bottom: 2px solid var(--accent);
    transition: all 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.highlight-word.draw::after {
    left: 0;
    width: 100%;
    border-left-width: 4px;
    border-right-width: 4px;
}

/* ===== ANNOTATIONS ===== */
.annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.65;
    margin-top: 3rem;
    transition: letter-spacing 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.annotation:hover {
    letter-spacing: 0.15em;
}

/* ===== TYPING TEXT ===== */
.typing-text {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--accent);
    width: 0;
    animation: typing 2s cubic-bezier(0.33, 1, 0.68, 1) 800ms forwards,
               blink-caret 600ms step-end infinite;
}

@keyframes typing {
    to { width: 100%; }
}

@keyframes blink-caret {
    50% { border-color: transparent; }
}

/* ===== SECTION INDEX / ODOMETER ===== */
.section-index {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.65;
    margin-bottom: 2rem;
}

.odometer {
    display: inline-block;
    overflow: hidden;
    height: 1.2em;
    vertical-align: bottom;
}

/* ===== ANGULAR DIVIDERS ===== */
.angular-divider {
    width: 100%;
    height: 40px;
    position: absolute;
    bottom: 0;
    left: 0;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.2s ease-out;
}

.divider-path.drawn {
    stroke-dashoffset: 0;
}

/* ===== TELOMERE DECORATION ===== */
.telomere-decoration {
    position: fixed;
    right: 5vw;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    opacity: 0.12;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
    fill: none;
    pointer-events: none;
}

.deco-strand {
    stroke-dasharray: 160;
    stroke-dashoffset: 160;
    animation: drawDecoStrand 2s ease-out 1.5s forwards;
}

.deco-bridge {
    stroke-dasharray: 35;
    stroke-dashoffset: 35;
    animation: drawDecoBridge 800ms ease-out forwards;
}

.deco-bridge:nth-child(3) { animation-delay: 2s; }
.deco-bridge:nth-child(4) { animation-delay: 2.15s; }
.deco-bridge:nth-child(5) { animation-delay: 2.3s; }
.deco-bridge:nth-child(6) { animation-delay: 2.45s; }
.deco-bridge:nth-child(7) { animation-delay: 2.6s; }

.deco-fray {
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
    animation: drawDecoFray 600ms ease-out 3s forwards;
    opacity: 0.5;
}

@keyframes drawDecoStrand {
    to { stroke-dashoffset: 0; }
}

@keyframes drawDecoBridge {
    to { stroke-dashoffset: 0; }
}

@keyframes drawDecoFray {
    to { stroke-dashoffset: 0; }
}

/* ===== BACKGROUND ACCENT SHAPES ===== */
.section-slash::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -5%;
    width: 40vw;
    height: 50vh;
    background: var(--bg-secondary);
    clip-path: polygon(20% 0, 100% 15%, 85% 100%, 0 80%);
    z-index: 0;
    opacity: 0.5;
}

.section-bleed::before {
    content: '';
    position: absolute;
    bottom: -5%;
    left: -10%;
    width: 35vw;
    height: 45vh;
    background: var(--bg-secondary);
    clip-path: polygon(0 10%, 100% 0, 90% 85%, 15% 100%);
    z-index: 0;
    opacity: 0.4;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .section-content,
    .bleed-layout {
        padding-left: 8%;
        padding-right: 8%;
    }

    .nav-inner {
        padding-left: 10%;
    }

    .headline-bleed,
    .bleed-layout .headline-bleed {
        transform: none;
        margin-left: 0;
        width: 100%;
    }

    .slash-layout {
        transform: none;
    }

    .slash-layout .body-block {
        transform: none;
    }

    .telomere-decoration {
        display: none;
    }

    .section + .section {
        margin-top: 8vh;
    }
}
