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

:root {
    --soot: #1c1c22;
    --graphite: #2e2e36;
    --flint: #4a4a52;
    --smoke: #7a7a82;
    --ash: #a8a0a0;
    --parchment: #e8dcc8;
    --amber: #c49a5c;
    --arc: #6b8fa3;
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { scroll-behavior: smooth; }
body {
    background: var(--soot);
    color: var(--flint);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.72;
    overflow-x: hidden;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* === NAV TOGGLE === */
#nav-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s var(--bounce);
}
#nav-toggle:hover { transform: scale(1.15); }
#nav-toggle.active svg polygon { stroke: var(--parchment); }
#nav-toggle.active svg circle { fill: var(--parchment); }

/* === OVERLAY MENU === */
.overlay-menu {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--soot);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.overlay-menu.open {
    opacity: 1;
    pointer-events: all;
}
.overlay-menu nav {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    text-align: center;
}
.overlay-link {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--parchment);
    text-decoration: none;
    letter-spacing: 0.12em;
    transition: color 0.3s ease;
}
.overlay-link:hover { color: var(--amber); }

/* === SECTIONS BASE === */
.section {
    position: relative;
    width: 100%;
}

/* === OPENING === */
.section-opening {
    height: 100vh;
    background: var(--soot);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
}

.bucky-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.bucky-wireframe {
    width: min(80vw, 500px);
    height: min(80vw, 500px);
    animation: buckyRotate 60s linear infinite;
}
@keyframes buckyRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.bucky-still { animation: none; }

.opening-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

#tanso-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 9rem);
    color: var(--parchment);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
#tanso-title span {
    display: inline-block;
    opacity: 0;
    transform: scale(0);
}
#tanso-title span.animate {
    animation: bounceIn 500ms var(--bounce) forwards;
}
@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0); }
    70% { opacity: 1; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}

.title-hidden { /* initial hidden state handled by JS */ }

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 1.25rem;
    color: var(--smoke);
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}
.subtitle.visible { opacity: 1; }

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0;
    animation: fadeInUp 0.6s ease 2.5s forwards;
}
.scroll-indicator svg {
    animation: gentleBounce 2s ease-in-out infinite;
}
@keyframes gentleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === TORN EDGES === */
.torn-edge {
    position: relative;
    height: 12px;
    z-index: 10;
}
.torn-edge-dark {
    background: var(--soot);
    clip-path: url(#tornEdge1);
}
.torn-edge-light {
    background: var(--parchment);
    clip-path: url(#tornEdge1);
}
.torn-edge-dark-to-light {
    background: var(--soot);
    clip-path: url(#tornEdge2);
}
.torn-edge-light-to-dark {
    background: var(--parchment);
    clip-path: url(#tornEdge1);
}

/* === EDITORIAL LAYOUT === */
.editorial-row {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
    position: relative;
}
.editorial-main {
    flex: 0 1 62%;
    margin-left: 5%;
}
.editorial-main-narrow {
    flex: 0 1 50%;
    margin-left: 10%;
}
.editorial-row-narrow {
    max-width: 1000px;
}

.marginalia {
    flex: 0 1 200px;
    padding-top: 6rem;
    position: relative;
}

/* === SECTION TITLES === */
.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--soot);
    margin-bottom: 2rem;
}
.section-title-light { color: var(--parchment); }

/* === BODY TEXT === */
.body-text p {
    margin-bottom: 1.5rem;
    color: var(--flint);
}
.body-text-light p { color: #c8c0b4; }
.body-text-fragmented p {
    margin-bottom: 2.5rem;
}

/* === PULL QUOTE === */
.pull-quote {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 600;
    font-size: 1.5rem;
    color: #5a4a3a;
    border-left: 2px solid var(--amber);
    padding: 1.5rem 0 1.5rem 1.5rem;
    margin: 3rem 0;
    max-width: 500px;
}
.section-graphite .pull-quote {
    color: var(--parchment);
    border-left-color: var(--arc);
}

/* === MARGINALIA === */
.margin-note {
    margin-bottom: 2rem;
}
.formula {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    color: var(--smoke);
}
.margin-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--ash);
    margin-top: 0.2rem;
}
.marginalia-light .formula { color: #a8a0a0; }
.marginalia-light .margin-label { color: var(--smoke); }

.coffee-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 55%, rgba(196,154,92,0.08) 56%, rgba(196,154,92,0.04) 70%, transparent 71%);
    margin-top: 2rem;
}

/* === BUBBLE CLUSTERS === */
.bubble-cluster svg {
    width: 150px;
    height: auto;
}

/* === DIAMOND SECTION === */
.section-diamond {
    background: var(--parchment);
    position: relative;
    filter: url(#foxing);
}
.diamond-watermark {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40%;
    pointer-events: none;
}
.diamond-lattice { width: 100%; height: auto; }

/* Paper crease */
.section-diamond::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(74,74,82,0.06) 20%, rgba(74,74,82,0.1) 50%, rgba(74,74,82,0.06) 80%, transparent);
    transform: rotate(-0.5deg);
}

/* === GRAPHITE SECTION === */
.section-graphite {
    background: var(--graphite);
    position: relative;
    overflow: hidden;
}
.hex-lattice-bg {
    position: absolute;
    inset: 0;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='52'%3E%3Cpolygon points='30,2 56,15 56,37 30,50 4,37 4,15' fill='none' stroke='%236b8fa3' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 60px 52px;
}

/* === COMBUSTION SECTION === */
.section-combustion {
    background: var(--soot);
    position: relative;
    overflow: hidden;
}
.amber-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 80%, rgba(196,154,92,0.06), transparent 60%);
    animation: flicker 4s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes flicker {
    0% { opacity: 0.5; }
    25% { opacity: 1; }
    50% { opacity: 0.7; }
    75% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Extra foxing on combustion */
.section-combustion::after {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(196,154,92,0.04) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(196,154,92,0.03) 0%, transparent 30%),
        radial-gradient(circle at 45% 80%, rgba(196,154,92,0.05) 0%, transparent 35%);
    pointer-events: none;
}

/* === CYCLE SECTION === */
.section-cycle {
    background: #e5dac6;
    position: relative;
}
.cycle-diagram {
    max-width: 400px;
    margin: 3rem auto;
}
#cycle-svg { width: 100%; height: auto; }

/* === CLOSING === */
.section-closing {
    height: 100vh;
    background: var(--soot);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
}
.bucky-bg-still {
    opacity: 0.5;
}
.closing-content {
    position: relative;
    z-index: 2;
    text-align: center;
}
.closing-hex { margin-bottom: 1.5rem; }
.closing-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--parchment);
    letter-spacing: 0.12em;
    margin-bottom: 1rem;
}
.closing-info {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--smoke);
    letter-spacing: 0.02em;
}

/* === REVEAL ANIMATIONS === */
.reveal {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.5s ease, transform 0.5s var(--bounce);
}
.reveal.visible {
    opacity: 1;
    transform: scale(1);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .editorial-row {
        flex-direction: column;
        padding: 3rem 1.25rem;
    }
    .editorial-main, .editorial-main-narrow {
        flex: 1;
        margin-left: 0;
    }
    .marginalia {
        padding-top: 1rem;
        display: flex;
        gap: 1.5rem;
        flex-wrap: wrap;
    }
    .diamond-watermark { display: none; }
    .pull-quote { font-size: 1.25rem; }
}
