/* algoha.com - Algorithmic Revelation */
:root {
    --void: #0B0E17;
    --eureka: #00E5A0;
    --amber: #FFB347;
    --pale-blue: #C8D6E5;
    --grid-whisper: #1A1F2E;
    --proof-white: #F0F4F8;
    --error-coral: #FF6B6B;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--void);
    background-image: radial-gradient(circle, var(--grid-whisper) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--pale-blue);
    font-family: 'Source Serif 4', serif;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* Timeline */
.timeline-svg {
    position: fixed;
    left: calc(33.33% - 1px);
    top: 0;
    width: 2px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.timeline-node {
    position: absolute;
    left: calc(33.33% - 6px);
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--eureka);
    z-index: 11;
    opacity: 0.4;
    transition: opacity 0.6s ease, box-shadow 0.6s ease;
}

.timeline-node-final {
    width: 20px;
    height: 20px;
    left: calc(33.33% - 10px);
    box-shadow: 0 0 20px rgba(0, 229, 160, 0.5);
    opacity: 1;
}

.iteration.in-view .timeline-node {
    opacity: 1;
    box-shadow: 0 0 12px rgba(0, 229, 160, 0.4);
}

/* Iteration Counter */
.iteration-counter {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.counter-text {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--eureka);
    opacity: 0.6;
}

/* Floating Pseudocode */
.pseudo-float {
    position: fixed;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--eureka);
    opacity: 0.2;
    z-index: 5;
    pointer-events: none;
    animation: pseudoFloat 8s ease-in-out infinite;
}

@keyframes pseudoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Sections */
.iteration {
    position: relative;
    min-height: 100vh;
    padding: 10vh 8vw;
    display: flex;
    align-items: center;
    gap: 4rem;
}

.iter-0 {
    justify-content: center;
    flex-direction: column;
}

.iter-content {
    max-width: 42ch;
    z-index: 5;
}

.content-right {
    margin-left: auto;
    margin-right: 8vw;
}

.content-left {
    margin-left: calc(33.33% + 3rem);
}

/* Interstitials */
.interstitial {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.interstitial code {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    color: var(--eureka);
    opacity: 0.4;
    letter-spacing: 0.02em;
}

/* Hero */
.hero-container {
    text-align: center;
    position: relative;
    z-index: 5;
}

.hero-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--proof-white);
    line-height: 1;
    margin-bottom: 1.5rem;
}

.hero-char {
    display: inline-block;
    transition: transform 2.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}

.hero-subtitle {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(1rem, 1.4vw, 1.3rem);
    color: var(--pale-blue);
    opacity: 0;
    animation: fadeSlideIn 1.2s ease 2.6s forwards;
}

@keyframes fadeSlideIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 0.8; transform: translateY(0); }
}

/* Section Titles */
.section-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.03em;
    color: var(--proof-white);
    margin-bottom: 1.5rem;
}

.body-text {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.72;
    color: var(--pale-blue);
}

/* Bar Charts */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 200px;
    padding: 0 2rem;
}

.bar {
    flex: 1;
    height: var(--h);
    background: var(--grid-whisper);
    border-radius: 2px 2px 0 0;
    transition: background 0.6s ease;
}

.bar-signal {
    background: var(--amber);
    animation: barPulse 2s ease-in-out infinite;
}

@keyframes barPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.bar-solved {
    background: var(--eureka);
}

.sorted {
    max-width: 50vw;
    margin-left: auto;
    margin-right: 10vw;
}

.unsorted {
    max-width: 60vw;
    margin-left: auto;
    margin-right: 6vw;
}

/* Filmstrip */
.filmstrip-container {
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 0;
}

.filmstrip {
    display: flex;
    gap: 2rem;
    padding: 0 4rem;
    width: max-content;
}

.film-frame {
    scroll-snap-align: start;
    width: 180px;
    height: 200px;
    background: var(--grid-whisper);
    border: 1px solid rgba(0, 229, 160, 0.1);
    border-radius: 4px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
}

.mb {
    flex: 1;
    height: var(--h);
    background: var(--grid-whisper);
    border: 1px solid rgba(0, 229, 160, 0.15);
    border-radius: 1px 1px 0 0;
}

.mb-active { background: var(--eureka); border-color: var(--eureka); }
.mb-swap { background: var(--amber); border-color: var(--amber); }
.mb-done { background: var(--eureka); border-color: var(--eureka); opacity: 0.7; }

.frame-label {
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    color: var(--eureka);
    opacity: 0.5;
    text-align: center;
}

/* Tree */
.tree-container {
    width: 50%;
    max-width: 600px;
    margin-left: calc(33.33% + 2rem);
}

.tree-svg {
    width: 100%;
    height: auto;
}

.tree-edge {
    stroke: rgba(0, 229, 160, 0.3);
    stroke-width: 1;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-svg.drawn .tree-edge {
    stroke-dashoffset: 0;
}

.tree-node {
    fill: var(--eureka);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.tree-svg.drawn .tree-node {
    opacity: 1;
}

/* Complexity Display */
.complexity-display {
    width: 100%;
    text-align: center;
    margin-bottom: 3rem;
}

.big-o {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 15vw, 12rem);
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--pale-blue), var(--eureka));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.iter-4 {
    flex-direction: column;
}

/* Comparison Counter */
.comparison-counter {
    position: absolute;
    bottom: 10vh;
    right: 12vw;
    text-align: center;
}

.counter-value {
    font-family: 'Fira Code', monospace;
    font-size: 48px;
    color: var(--eureka);
    display: block;
}

.counter-label {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--eureka);
    opacity: 0.5;
}

/* Eureka */
.iter-6 {
    justify-content: center;
    flex-direction: column;
    text-align: center;
}

.eureka-container {
    z-index: 5;
}

.eureka-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(4rem, 14vw, 12rem);
    letter-spacing: -0.03em;
    color: var(--amber);
    animation: eurekaPulse 3s ease 0.5s;
}

@keyframes eurekaPulse {
    0% { transform: scale(1); }
    10% { transform: scale(1.02); }
    20% { transform: scale(1); }
}

.eureka-domain {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    color: var(--eureka);
    margin-top: 1.5rem;
}

/* Slide Reveal */
.slide-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.slide-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Border Animate */
.border-animate {
    position: relative;
}

.border-animate::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid var(--eureka);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.border-animate.active::after {
    opacity: 1;
    animation: drawBorder 0.8s ease forwards;
}

@keyframes drawBorder {
    0% { clip-path: polygon(0 0, 0 0, 0 0, 0 0); }
    25% { clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); }
    50% { clip-path: polygon(0 0, 100% 0, 100% 100%, 100% 100%); }
    75% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
    100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}

/* Responsive */
@media (max-width: 768px) {
    .timeline-svg { left: 24px; }
    .timeline-node { left: 18px; }
    .content-left { margin-left: 60px; }
    .content-right { margin-left: 60px; margin-right: 4vw; }
    .bar-chart { max-width: 90vw; margin: 0 auto; }
    .sorted, .unsorted { max-width: 90vw; margin: 0 auto; }
    .tree-container { width: 90%; margin-left: 5%; }
    .pseudo-float { display: none; }
}
