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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: #08080a;
    color: #e8e6e1;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

/* === NOISE OVERLAY === */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* === THE WIRE === */
.wire {
    position: fixed;
    top: 0;
    left: calc(50% - min(320px, calc(50vw - clamp(1.5rem, 5vw, 4rem))));
    width: 1px;
    height: 100%;
    background-color: #39ff14;
    z-index: 10;
    animation: wirePulse 4s ease-in-out infinite;
}

@keyframes wirePulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.4; }
}

/* === COLUMN === */
.column {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 5vw, 4rem);
    position: relative;
}

/* === TYPOGRAPHY === */
.display-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #e8e6e1;
    margin-bottom: 32px;
}

.section-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: 2rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #e8e6e1;
    margin-bottom: 32px;
}

.subsection-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    color: #39ff14;
    text-transform: uppercase;
    margin-top: 64px;
    margin-bottom: 24px;
}

.coda-title {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #e8e6e1;
    text-align: center;
}

/* === PARAGRAPHS === */
p {
    margin-bottom: 32px;
    color: #e8e6e1;
}

code {
    font-family: 'Space Mono', monospace;
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    background: rgba(123, 47, 255, 0.13);
    padding: 2px 6px;
    border-radius: 2px;
    color: #e8e6e1;
}

/* === PULL QUOTE === */
.pull-quote {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: #e8e6e1;
    border-left: 3px solid #ff2d6f;
    padding-left: 24px;
    margin: 64px 0;
}

/* === CHAPTERS === */
.chapter-one {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.chapter-one .column {
    padding-top: 96px;
    padding-bottom: 96px;
}

.manifesto {
    color: #8a8a8e;
    max-width: 520px;
}

.scroll-arrow {
    display: block;
    margin-top: 48px;
    animation: bobArrow 2s ease-in-out infinite;
}

@keyframes bobArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

.chapter-two,
.chapter-three,
.chapter-four {
    padding-top: 96px;
    padding-bottom: 64px;
}

.chapter-five {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chapter-five .column {
    text-align: center;
}

/* === WIRE BRANCH === */
.wire-branch {
    width: 40px;
    height: 1px;
    background-color: #39ff14;
    opacity: 0.3;
    margin-bottom: 32px;
}

/* === WIRE TERMINUS === */
.wire-terminus {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #39ff14;
    margin: 32px auto;
}

/* === COLOPHON === */
.colophon {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #8a8a8e;
    margin-top: 48px;
}

.colophon-domain {
    color: #39ff14;
}

/* === INTERLUDES === */
.interlude {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    height: 60vh;
    background-color: #141418;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ripple */
.ripple-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    border-radius: 50%;
    border: 1px solid #39ff14;
    opacity: 0;
    transform: scale(0.1);
}

.interlude.ripple-active .ripple-ring {
    animation: ripple 2.5s ease-out forwards;
}

.interlude.ripple-active .ripple-ring:nth-child(2) { animation-delay: 0.4s; }
.interlude.ripple-active .ripple-ring:nth-child(3) { animation-delay: 0.8s; }
.interlude.ripple-active .ripple-ring:nth-child(4) { animation-delay: 1.2s; }

@keyframes ripple {
    0% { transform: scale(0.1); opacity: 0.4; }
    100% { transform: scale(3); opacity: 0; }
}

/* === INTERLUDE I — THE GRID === */
.grid-composition {
    position: relative;
    width: 80%;
    max-width: 600px;
    height: 300px;
}

.grid-rect {
    position: absolute;
    border: 1px solid;
}

.rect-1 { width: 233px; height: 144px; top: 10%; left: 5%; border-color: #39ff14; }
.rect-2 { width: 144px; height: 89px; top: 20%; left: 40%; border-color: #7b2fff; }
.rect-3 { width: 89px; height: 55px; top: 55%; left: 15%; border-color: #ff2d6f; }
.rect-4 { width: 55px; height: 34px; top: 60%; left: 65%; border-color: #39ff14; }
.rect-5 { width: 34px; height: 21px; top: 30%; left: 75%; border-color: #7b2fff; }
.rect-6 { width: 144px; height: 233px; top: 10%; right: 5%; border-color: #ff2d6f; }
.rect-7 { width: 89px; height: 144px; bottom: 5%; left: 30%; border-color: #39ff14; }

/* === INTERLUDE II — THE CIRCLE === */
.circle-composition {
    position: relative;
    width: 400px;
    height: 400px;
}

.kandinsky-circle {
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.circle-1 { width: 350px; height: 350px; border-color: #39ff14; stroke-dasharray: 5 10; border-style: dashed; animation: slowSpin 60s linear infinite; }
.circle-2 { width: 260px; height: 260px; border-color: #7b2fff; animation: slowSpin 45s linear infinite reverse; }
.circle-3 { width: 180px; height: 180px; border-color: #ff2d6f; border-style: dashed; animation: slowSpin 30s linear infinite; }
.circle-4 { width: 100px; height: 100px; border-color: #ffe83a; }
.circle-5 { width: 40px; height: 40px; border-color: #39ff14; animation: slowSpin 20s linear infinite reverse; }

@keyframes slowSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === INTERLUDE III — THE TRIANGLE === */
.triangle-composition {
    position: relative;
    width: 400px;
    height: 350px;
}

.kandinsky-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.tri-1 {
    border-width: 0 100px 173px 100px;
    border-color: transparent transparent transparent transparent;
    top: 20%;
    left: 25%;
    border-bottom-color: transparent;
    outline: none;
    /* Use clip-path for triangle outline */
}

.tri-1, .tri-2, .tri-3 {
    width: 200px;
    height: 180px;
    border: none;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.tri-1 {
    top: 10%;
    left: 20%;
    border: none;
    background: transparent;
    box-shadow: inset 0 0 0 1px #ffe83a;
    /* clip-path clips box-shadow too, use outline trick */
}

/* Better triangle approach with SVG-like borders */
.kandinsky-triangle {
    position: absolute;
    width: 0;
    height: 0;
    clip-path: none;
}

.tri-1 {
    width: 180px;
    height: 160px;
    top: 15%;
    left: 15%;
    background: linear-gradient(to bottom, transparent 0%, transparent 100%);
    border: 1.5px solid #ffe83a;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.tri-2 {
    width: 160px;
    height: 140px;
    top: 25%;
    left: 40%;
    background: linear-gradient(to bottom, transparent 0%, transparent 100%);
    border: 1.5px solid #39ff14;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.tri-3 {
    width: 140px;
    height: 120px;
    top: 35%;
    left: 28%;
    background: linear-gradient(to bottom, transparent 0%, transparent 100%);
    border: 1.5px solid #ff2d6f;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* === CIRCUIT ANNOTATIONS === */
.circuit-annotation {
    position: absolute;
    left: -70px;
    opacity: 0.7;
}

.annotation-1 { top: 80px; }
.annotation-2 { bottom: 40px; right: -90px; left: auto; }
.annotation-3 { top: 200px; }
.annotation-4 { top: 100px; }

.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

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

/* === SCROLL INDICATOR === */
.scroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #39ff14;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    background: transparent;
}

.scroll-percent {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: #39ff14;
    letter-spacing: 0;
}

/* === RESPONSIVE === */
@media (max-width: 700px) {
    .circuit-annotation {
        display: none;
    }
    .wire {
        left: 16px;
    }
}
