/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    background: #141414;
    color: #cccccc;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    overflow: hidden;
    height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* === SIDEBAR === */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;
    background: #0a0a0a;
    border-right: 1px solid #2a2a2a;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
}
#sidebar.glitch-border {
    border-right-color: #ffffff;
}
#wordmark {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #f5f5f5;
    margin-bottom: 3rem;
}
#wordmark .dot { color: #00e5ff; }

#sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #555555;
    transition: color 0.3s;
    cursor: pointer;
}
.nav-item:hover { color: #999999; }
.nav-item.active { color: #cccccc; }
.nav-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #555555;
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}
.nav-item.active .nav-indicator {
    background: #00e5ff;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

#iteration-counter {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #00e5ff;
    margin-top: auto;
}

/* === VIEWPORT === */
#viewport {
    margin-left: 280px;
    width: calc(100vw - 280px);
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    position: relative;
}
.frame {
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}
.frame-content {
    width: 100%;
    height: 100%;
    position: relative;
}
.frame-border {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    border-bottom: 1px dashed #333333;
}

/* === SCROLL SCRUBBER === */
#scroll-scrubber {
    position: fixed;
    top: 0;
    left: 280px;
    width: calc(100vw - 280px);
    height: 1px;
    background: #00e5ff;
    z-index: 50;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.1s linear;
}

/* === FRAME 1: INITIALIZE === */
.frame1-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
#hero-wordmark {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(6rem, 15vw, 14rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #f5f5f5;
    line-height: 1;
    text-align: center;
}
#hero-wordmark .dot { color: #00e5ff; }
#hero-tagline {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: #999999;
    margin-top: 2rem;
    text-align: center;
    max-width: 40ch;
    min-height: 1.75em;
}

/* === FRAME 2: CONFIGURE === */
.frame2-content {
    position: relative;
}
#mesh-grid {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}
#mesh-overlay-text {
    position: absolute;
    bottom: 10%;
    left: 8%;
    max-width: 500px;
    z-index: 10;
}
.mesh-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #e8e8e8;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}
.mesh-body {
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    color: #cccccc;
    margin-bottom: 1rem;
}
.mesh-annotation {
    color: #555555;
}
.mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* === FRAME 3: ITERATE === */
.frame3-content {
    position: relative;
    overflow: hidden;
}
.collage-circle {
    position: absolute;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #2a2a2a;
}
.c1 { width: 200px; height: 200px; top: 10%; left: 15%; }
.c2 { width: 80px; height: 80px; top: 60%; left: 70%; }
.c3 { width: 140px; height: 140px; top: 35%; right: 10%; }
.c4 { width: 50px; height: 50px; top: 75%; left: 30%; }

.collage-triangle {
    position: absolute;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: rgba(153, 153, 153, 0.1);
}
.t1 { width: 160px; height: 160px; top: 20%; right: 25%; }
.t2 { width: 100px; height: 100px; bottom: 15%; left: 45%; }

.collage-panel {
    position: absolute;
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 2rem;
    z-index: 5;
}
.collage-panel h2 {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #e8e8e8;
    margin-bottom: 1rem;
}
.collage-panel p {
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    color: #cccccc;
}
.p1 { top: 15%; left: 8%; max-width: 420px; }
.p2 { bottom: 12%; right: 8%; max-width: 320px; }

.collage-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}
.collage-svg.svg2 { z-index: 3; }

.collage-svg path {
    transition: stroke-dashoffset 2s ease-out;
}
.frame3-content.in-view .collage-svg path {
    stroke-dashoffset: 0 !important;
}

/* === FRAME 4: CONVERGE === */
.frame4-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 8%;
    gap: 2rem;
}
.converge-element {
    transform: translateX(var(--cx, 0)) translateY(var(--cy, 0)) rotate(var(--cr, 0));
    filter: blur(4px);
    opacity: 0.3;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                filter 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 600px;
    text-align: center;
}
.converge-element.converged {
    transform: none !important;
    filter: blur(0);
    opacity: 1;
}
.converge-element h2 {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #e8e8e8;
    letter-spacing: 0.1em;
}
.converge-element p {
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    color: #cccccc;
}

/* === FRAME 5: OBSERVE === */
.frame5-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 8%;
    position: relative;
}
.observe-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1.1rem, 1.6vw, 1.4rem);
    line-height: 2;
    color: #999999;
    max-width: 50ch;
    text-align: center;
}
#lorenz-canvas {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 200px;
    height: 200px;
    opacity: 0.8;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #sidebar { display: none; }
    #viewport { margin-left: 0; width: 100vw; }
    #scroll-scrubber { left: 0; width: 100vw; }
    #hero-wordmark { font-size: clamp(3rem, 12vw, 7rem); }
    #mesh-overlay-text { left: 5%; right: 5%; max-width: none; }
    .p1 { left: 5%; right: 5%; max-width: none; }
    .p2 { right: 5%; max-width: none; }
}
