/* =========================================================
   simulai.dev — generative simulation aesthetic
   Palette
     #0A0F1C  background deep
     #121A2E  background mid
     #00F5D4  accent primary (cyan-mint)
     #7B61FF  accent secondary (electric violet)
     #FF6B6B  accent tertiary (coral)
     #C8D6E5  text primary
     #5A6C80  text secondary
   Typography
     Space Grotesk 700  -> phase titles
     IBM Plex Mono 400  -> body
     IBM Plex Mono 300  -> annotations
   ========================================================= */

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

:root {
    --bg-deep: #0A0F1C;
    --bg-mid: #121A2E;
    --accent-cyan: #00F5D4;
    --accent-violet: #7B61FF;
    --accent-coral: #FF6B6B;
    --text-primary: #C8D6E5;
    --text-secondary: #5A6C80;
    --panel-bg: rgba(10, 15, 28, 0.85);
    --panel-bg-mid: rgba(18, 26, 46, 0.78);
    --easing: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    scroll-behavior: smooth;
    background: var(--bg-deep);
}

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 500vh;
}

/* ---------- Persistent simulation canvas ---------- */
#simulation-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(123, 97, 255, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 70%, rgba(0, 245, 212, 0.06) 0%, transparent 60%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 50%, var(--bg-deep) 100%);
    pointer-events: none;
}

/* ---------- Vertical progress bar ---------- */
#progress-bar {
    position: fixed;
    top: 0;
    right: 24px;
    width: 2px;
    height: 100vh;
    background: rgba(90, 108, 128, 0.18);
    z-index: 20;
}

#progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
    box-shadow: 0 0 8px rgba(0, 245, 212, 0.5);
    transition: height 80ms linear;
}

/* ---------- Phase indicator (top left) ---------- */
#phase-indicator {
    position: fixed;
    top: 24px;
    left: 32px;
    z-index: 20;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: color 400ms var(--easing);
}

#phase-indicator .phase-num {
    color: var(--accent-cyan);
}

#phase-indicator .phase-name {
    color: var(--text-secondary);
}

/* ---------- Main content layer ---------- */
#content {
    position: relative;
    z-index: 1;
}

.phase {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 120px 8vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

/* ---------- Phase metadata strip ---------- */
.phase-meta {
    position: absolute;
    top: 56px;
    left: 8vw;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.phase-meta.phase-meta-right {
    left: auto;
    right: 8vw;
    text-align: right;
}

.meta-line {
    display: block;
    opacity: 0.85;
}

.meta-label {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* ---------- Phase titles ---------- */
.phase-title {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 700;
    font-size: clamp(64px, 13vw, 168px);
    line-height: 0.92;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    margin: 0;
    word-break: break-word;
}

.phase-title.sub-title {
    font-size: clamp(54px, 10vw, 132px);
}

.phase-title.small-title {
    font-size: clamp(44px, 8vw, 104px);
}

.phase-title.centered-title {
    text-align: center;
}

.phase-title .ch {
    display: inline-block;
    transform: translateY(28px);
    opacity: 0;
    transition:
        transform 600ms var(--easing),
        opacity 500ms var(--easing);
}

.phase-title.is-revealed .ch {
    transform: translateY(0);
    opacity: 1;
}

/* per-character stagger */
.phase-title.is-revealed .ch:nth-child(1) { transition-delay: 30ms; }
.phase-title.is-revealed .ch:nth-child(2) { transition-delay: 60ms; }
.phase-title.is-revealed .ch:nth-child(3) { transition-delay: 90ms; }
.phase-title.is-revealed .ch:nth-child(4) { transition-delay: 120ms; }
.phase-title.is-revealed .ch:nth-child(5) { transition-delay: 150ms; }
.phase-title.is-revealed .ch:nth-child(6) { transition-delay: 180ms; }
.phase-title.is-revealed .ch:nth-child(7) { transition-delay: 210ms; }
.phase-title.is-revealed .ch:nth-child(8) { transition-delay: 240ms; }
.phase-title.is-revealed .ch:nth-child(9) { transition-delay: 270ms; }

/* ---------- Phase 1: Initialization ---------- */
.phase-1 {
    align-items: flex-start;
    justify-content: center;
}

.phase-1 .phase-title {
    margin-bottom: 12px;
}

.phase-subtitle {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 400;
    font-size: 18px;
    letter-spacing: 0.12em;
    color: var(--text-primary);
    opacity: 0.3;
    margin-left: 4px;
    margin-bottom: 48px;
}

.phase-caption {
    max-width: 540px;
    margin-top: 8px;
    color: var(--text-primary);
}

.cap-line {
    font-size: 16px;
    line-height: 1.75;
    margin-bottom: 6px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms var(--easing), transform 500ms var(--easing);
}

.cap-line.is-visible { opacity: 1; transform: translateY(0); }
.cap-line:nth-child(1) { transition-delay: 0ms; }
.cap-line:nth-child(2) { transition-delay: 100ms; }

.scroll-prompt {
    position: absolute;
    bottom: 48px;
    left: 8vw;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.scroll-arrow {
    font-size: 18px;
    color: var(--accent-cyan);
    animation: scroll-bounce 2s var(--easing) infinite;
}

@keyframes scroll-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50%      { transform: translateY(8px); opacity: 1; }
}

/* ---------- Phase divider (dot wave) ---------- */
.phase-divider {
    position: relative;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1;
}

.phase-divider .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: background-color 240ms var(--easing), transform 240ms var(--easing), box-shadow 240ms var(--easing);
}

.phase-divider .dot.lit {
    background: var(--accent-cyan);
    box-shadow: 0 0 6px rgba(0, 245, 212, 0.8);
    transform: scale(1.4);
}

/* ---------- Phase 2: Configuration (diagonal panels) ---------- */
.phase-2 {
    justify-content: center;
}

.phase-2 .phase-title {
    margin-bottom: 60px;
    transform: translateX(-2vw);
}

.diagonal-panels {
    position: relative;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 0;
}

.diag-panel {
    position: relative;
    background: var(--panel-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(123, 97, 255, 0.18);
    padding: 40px 36px;
    width: 48%;
    min-width: 320px;
    transition: transform 800ms var(--easing), opacity 700ms var(--easing);
}

.diag-left {
    transform: translateX(-12vw) rotate(2.5deg);
    opacity: 0;
    margin-right: -3vw;
    z-index: 2;
}

.diag-right {
    transform: translateX(12vw) rotate(-1.5deg);
    opacity: 0;
    margin-top: 60px;
    z-index: 1;
}

.phase-2.is-active .diag-left {
    transform: translateX(0) rotate(2.5deg);
    opacity: 1;
}

.phase-2.is-active .diag-right {
    transform: translateX(0) rotate(-1.5deg);
    opacity: 1;
}

.panel-stamp {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-cyan);
    margin-bottom: 18px;
}

.panel-heading {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 500;
    font-size: 26px;
    line-height: 1.25;
    color: var(--text-primary);
    margin-bottom: 18px;
}

.panel-body {
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.panel-body.small {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 18px;
    line-height: 1.7;
}

.panel-list {
    list-style: none;
    margin-top: 24px;
    border-top: 1px solid rgba(90, 108, 128, 0.2);
    padding-top: 16px;
    font-size: 12px;
    letter-spacing: 0.06em;
}

.panel-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(90, 108, 128, 0.15);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.panel-list .list-key { color: var(--text-secondary); }
.panel-list .list-val { color: var(--accent-cyan); }

.slider-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}

.slider-row {
    display: grid;
    grid-template-columns: 110px 1fr 64px;
    align-items: center;
    gap: 12px;
}

.slider-label {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.slider-track {
    position: relative;
    height: 4px;
    background: rgba(90, 108, 128, 0.25);
    border-radius: 1px;
    overflow: hidden;
}

.slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
    transition: width 1.6s var(--easing);
}

.slider-fill.is-set {
    width: calc(var(--target) * 100%);
}

.slider-val {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    text-align: right;
}

/* ---------- Phase 3: Execution ---------- */
.phase-3 {
    justify-content: center;
    align-items: center;
}

.phase-3 .phase-title {
    margin-bottom: 60px;
}

.exec-column {
    max-width: 540px;
    margin: 0 auto;
    padding: 32px 28px;
    background: rgba(10, 15, 28, 0.55);
    border-left: 1px solid rgba(0, 245, 212, 0.4);
    border-right: 1px solid rgba(123, 97, 255, 0.18);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.exec-line {
    font-family: "IBM Plex Mono", monospace;
    font-size: 14px;
    line-height: 1.85;
    color: var(--text-primary);
    margin-bottom: 14px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms var(--easing), transform 500ms var(--easing);
}

.exec-line.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.exec-line:nth-child(1) { transition-delay: 0ms; }
.exec-line:nth-child(2) { transition-delay: 100ms; }
.exec-line:nth-child(3) { transition-delay: 200ms; }
.exec-line:nth-child(4) { transition-delay: 300ms; }
.exec-line:nth-child(5) { transition-delay: 400ms; }
.exec-line:nth-child(6) { transition-delay: 500ms; }
.exec-line:nth-child(7) { transition-delay: 600ms; }

.exec-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Phase 4: Analysis (broken grid) ---------- */
.phase-4 {
    justify-content: center;
}

.phase-4 .phase-title {
    margin-bottom: 60px;
    text-align: right;
}

.analysis-grid {
    position: relative;
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: minmax(200px, auto);
    gap: 24px;
}

.readout {
    background: var(--panel-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(123, 97, 255, 0.18);
    padding: 28px 30px;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms var(--easing), transform 600ms var(--easing);
}

.phase-4.is-active .readout { opacity: 1; transform: translateY(0); }

/* deliberate misalignment offsets */
.readout-a { transform: translate(-22px, 16px); }
.readout-b { transform: translate(34px, -12px); }
.readout-c { transform: translate(-12px, 28px); }
.readout-d { transform: translate(22px, -8px); }

.phase-4.is-active .readout-a { transform: translate(-22px, 16px); }
.phase-4.is-active .readout-b { transform: translate(34px, -12px); }
.phase-4.is-active .readout-c { transform: translate(-12px, 28px); }
.phase-4.is-active .readout-d { transform: translate(22px, -8px); }

.readout-a { transition-delay: 0ms; }
.readout-b { transition-delay: 120ms; }
.readout-c { transition-delay: 240ms; }
.readout-d { transition-delay: 360ms; }

.readout-stamp {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.readout-value {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 700;
    font-size: 36px;
    line-height: 1.1;
    color: var(--accent-cyan);
    margin-bottom: 18px;
    letter-spacing: -0.02em;
}

.readout-d .readout-value { color: var(--accent-violet); }

.readout-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

/* ---------- Phase 5: Convergence ---------- */
.phase-5 {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-top: 120px;
    padding-bottom: 160px;
    min-height: 100vh;
}

.phase-5 .phase-title {
    margin-bottom: 80px;
    text-align: center;
}

.converge-text {
    max-width: 620px;
    margin: 0 auto;
    color: var(--text-primary);
}

.converge-line {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 400;
    font-size: clamp(20px, 2.4vw, 28px);
    line-height: 1.5;
    margin-bottom: 8px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 700ms var(--easing), transform 700ms var(--easing);
}

.converge-line.is-visible { opacity: 1; transform: translateY(0); }
.converge-line:nth-child(1) { transition-delay: 100ms; }
.converge-line:nth-child(2) { transition-delay: 320ms; color: var(--accent-coral); }

.converge-meta {
    margin-top: 96px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    align-items: center;
}

/* ---------- Body backdrop pulse ---------- */
body.is-pulsing {
    animation: brightness-pulse 400ms var(--easing);
}

@keyframes brightness-pulse {
    0%   { filter: brightness(1.0); }
    50%  { filter: brightness(1.1); }
    100% { filter: brightness(1.0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .phase {
        padding: 100px 6vw;
    }

    .diag-panel {
        width: 100%;
        margin-top: 24px;
    }

    .diag-left { margin-right: 0; }
    .diag-right { margin-top: 36px; }

    .analysis-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .readout-a, .readout-b, .readout-c, .readout-d,
    .phase-4.is-active .readout-a,
    .phase-4.is-active .readout-b,
    .phase-4.is-active .readout-c,
    .phase-4.is-active .readout-d {
        transform: translate(0, 0);
    }

    .scroll-prompt { left: 6vw; bottom: 24px; }

    .slider-row {
        grid-template-columns: 88px 1fr 56px;
    }
}
