/* ============================================
   dilemma.dev - styles.css
   Dark-mode terminal noir, split-screen architecture
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cline x1='8' y1='0' x2='8' y2='16' stroke='%2300ff88' stroke-width='1'/%3E%3Cline x1='0' y1='8' x2='16' y2='8' stroke='%2300ff88' stroke-width='1'/%3E%3C/svg%3E") 8 8, crosshair;
}

body {
    background: #0a0a0f;
    color: #e8e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    font-variant-ligatures: contextual;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: #00ff88;
    color: #0a0a0f;
}

/* --- Scanline Overlay --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    z-index: 9999;
    pointer-events: none;
    animation: scanline-drift 16s linear infinite;
}

@keyframes scanline-drift {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(0.5px); }
}

/* --- Cursor Glow --- */
#cursor-glow {
    position: fixed;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    opacity: 0;
}

body:hover #cursor-glow {
    opacity: 1;
}

/* --- Code Rain Background --- */
#code-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.code-rain-snippet {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    opacity: 0.07;
    white-space: pre;
    pointer-events: none;
    color: #e8e8f0;
}

.code-rain-snippet .kw { color: #00ff88; }
.code-rain-snippet .str { color: #ffaa22; }
.code-rain-snippet .cm { color: #445566; }
.code-rain-snippet .err { color: #ff2244; }

/* --- Bisection Line --- */
#bisection-line {
    position: fixed;
    left: 50vw;
    top: 0;
    width: 2px;
    height: 100vh;
    background: #00ff88;
    box-shadow:
        0 0 4px #00ff88,
        0 0 12px rgba(0, 255, 136, 0.3),
        0 0 24px rgba(0, 255, 136, 0.1);
    z-index: 100;
    transform-origin: center;
    transform: scaleY(0);
    transition: box-shadow 0.3s ease;
}

#bisection-line:hover {
    box-shadow:
        0 0 6px #00ff88,
        0 0 18px rgba(0, 255, 136, 0.5),
        0 0 36px rgba(0, 255, 136, 0.2);
}

#bisection-line.active {
    transform: scaleY(1);
}

#bisection-line.glitch {
    animation: bisection-glitch 120ms steps(3) forwards;
}

#bisection-line.flash-red {
    background: #ff2244;
    box-shadow:
        0 0 4px #ff2244,
        0 0 12px rgba(255, 34, 68, 0.3),
        0 0 24px rgba(255, 34, 68, 0.1);
}

#bisection-line.flicker {
    animation: bisection-flicker 300ms steps(6) forwards;
}

@keyframes bisection-glitch {
    0% { transform: scaleY(1) translateX(0); }
    33% { transform: scaleY(1) translateX(-3px); }
    66% { transform: scaleY(1) translateX(4px); }
    100% { transform: scaleY(1) translateX(0); }
}

@keyframes bisection-flicker {
    0% { opacity: 1; }
    16% { opacity: 0.3; }
    33% { opacity: 1; }
    50% { opacity: 0.3; }
    66% { opacity: 1; }
    83% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* --- HUD Navigation --- */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 200;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#hud.visible {
    opacity: 1;
}

#hud span {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    color: #445566;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    pointer-events: auto;
}

#hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 16px;
}

/* --- Title Container --- */
#title-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    white-space: nowrap;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 5rem);
    letter-spacing: -0.03em;
    text-shadow: 0 0 20px rgba(232, 232, 240, 0.1);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

#title-container.visible {
    opacity: 1;
}

#title-container.moved-up {
    top: 20px;
    transform: translate(-50%, 0);
    font-size: 1.2rem;
    letter-spacing: 0.05em;
}

#title-left {
    color: #e8e8f0;
}

#title-right {
    color: #e8e8f0;
}

#title-cursor {
    color: #00ff88;
    animation: blink-cursor 1s step-end infinite;
}

#title-container.moved-up #title-cursor {
    display: none;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Main Content --- */
#content {
    position: relative;
    z-index: 10;
    opacity: 0;
    transition: opacity 1s ease;
    padding-top: 80px;
}

#content.visible {
    opacity: 1;
}

/* --- Dilemma Sections --- */
.dilemma-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

/* --- Panes --- */
.pane {
    width: 50%;
    padding: 80px 48px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
}

.pane-left {
    background: #0a0a0f;
    text-align: left;
    justify-content: flex-start;
}

.pane-right {
    background: #0f0a0a;
    text-align: left;
    justify-content: flex-end;
}

.pane-right .pane-content {
    text-align: right;
}

/* --- Line Numbers --- */
.line-numbers {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    color: #333344;
    letter-spacing: 0.08em;
    line-height: 1.75;
    user-select: none;
    flex-shrink: 0;
    padding-top: 4px;
}

.pane-right .line-numbers {
    text-align: right;
}

/* --- Pane Content --- */
.pane-content {
    flex: 1;
    max-width: calc(50vw - 112px);
}

.pane-content p {
    margin-bottom: 24px;
    color: #e8e8f0;
}

.pane-right .pane-content p {
    color: rgba(232, 232, 240, 0.75);
    font-style: italic;
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    letter-spacing: 0.05em;
    color: #e8e8f0;
    text-shadow: 0 0 20px rgba(232, 232, 240, 0.1);
    margin-bottom: 24px;
    line-height: 1.3;
}

.pane-left .section-heading {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.15);
}

.pane-right .section-heading {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.15);
}

/* --- Code Blocks --- */
.code-block {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    padding: 20px;
    background: rgba(26, 26, 42, 0.3);
    border: 1px solid #1a1a2a;
    border-radius: 0;
    margin-top: 16px;
    overflow-x: auto;
    color: #e8e8f0;
}

.code-block .kw { color: #00ff88; }
.code-block .fn { color: #e8e8f0; }
.code-block .ty { color: #ffaa22; }
.code-block .str { color: #ffaa22; }
.code-block .cm { color: #445566; }
.code-block .num { color: #ff2244; }
.code-block .attr { color: #2233aa; }

/* --- Circuit Traces --- */
.circuit-trace {
    position: absolute;
    height: 1px;
    background: #1a1a2a;
    top: 50%;
    z-index: 5;
    transform: scaleX(0);
    transition: transform 0.4s ease-out;
}

.circuit-trace-left {
    left: 0;
    right: 50%;
    transform-origin: right center;
}

.circuit-trace-right {
    left: 50%;
    right: 0;
    transform-origin: left center;
}

.circuit-trace.drawn {
    transform: scaleX(1);
}

.trace-node {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #00ff88;
    opacity: 0;
    top: -1.5px;
    transition: opacity 0.2s ease, box-shadow 0.4s ease;
}

.circuit-trace-left .trace-node {
    left: 0;
}

.circuit-trace-right .trace-node {
    right: 0;
}

.circuit-trace.drawn .trace-node {
    opacity: 0.4;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
    animation: node-pulse 3s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% {
        box-shadow: 0 0 4px rgba(0, 255, 136, 0.3);
        opacity: 0.4;
    }
    50% {
        box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
        opacity: 0.6;
    }
}

/* --- Collision Zones --- */
.collision-zone {
    position: absolute;
    bottom: 10%;
    left: 30%;
    right: 30%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    z-index: 20;
    mix-blend-mode: screen;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.collision-zone.visible {
    opacity: 1;
    transform: translateY(0);
}

.collision-text-left,
.collision-text-right {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: -0.02em;
    padding: 8px 20px;
}

.collision-text-left {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
    text-align: right;
}

.collision-text-right {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.3);
    text-align: left;
}

/* --- ASCII Dividers --- */
.ascii-divider {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 32px 0;
}

.ascii-divider pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.6rem, 0.8vw, 0.75rem);
    color: #445566;
    opacity: 0.7;
    line-height: 1.4;
    display: inline-block;
    text-align: left;
}

/* --- Decision Tree --- */
#decision-tree-container {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 80px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#decision-tree-container.visible {
    opacity: 1;
    transform: translateY(0);
}

#decision-tree {
    width: 100%;
    max-width: 600px;
    height: auto;
}

.tree-node {
    transition: filter 0.3s ease;
}

.tree-node:hover {
    filter: brightness(1.4);
}

.tree-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 9px;
    fill: #e8e8f0;
}

.tree-label-amber {
    fill: #ffaa22;
}

/* --- Final Section --- */
.dilemma-final {
    min-height: 60vh;
    align-items: center;
    justify-content: center;
}

.pane-final {
    display: flex;
    align-items: center;
    justify-content: center;
}

.final-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    letter-spacing: -0.02em;
}

.pane-left .final-text {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.15);
}

.pane-right .final-text {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.15);
}

/* --- Enter Prompt --- */
.enter-prompt {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: #e8e8f0;
}

.prompt-text {
    color: #e8e8f0;
}

.prompt-cursor {
    color: #00ff88;
    animation: blink-cursor 1s step-end infinite;
}

/* --- Scroll Reveal Animations --- */
.pane-left .pane-content {
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.pane-right .pane-content {
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.pane-left .pane-content.revealed,
.pane-right .pane-content.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Tab Toggle: Swapped State --- */
body.swapped .pane-left {
    background: #0f0a0a;
}

body.swapped .pane-right {
    background: #0a0a0f;
}

body.swapped .pane-left .section-heading {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.15);
}

body.swapped .pane-right .section-heading {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.15);
}

body.swapped .pane-left .pane-content p {
    color: rgba(232, 232, 240, 0.75);
    font-style: italic;
}

body.swapped .pane-right .pane-content p {
    color: #e8e8f0;
    font-style: normal;
}

body.swapped .collision-text-left {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.3);
}

body.swapped .collision-text-right {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

body.swapped .pane-left .final-text {
    color: #ff2244;
    text-shadow: 0 0 20px rgba(255, 34, 68, 0.15);
}

body.swapped .pane-right .final-text {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.15);
}

/* Swap transition */
.pane {
    transition: background 0.2s ease;
}

.pane .section-heading,
.pane .pane-content p,
.pane .final-text {
    transition: color 0.2s ease, text-shadow 0.2s ease, font-style 0.2s ease;
}

/* --- Circuit Board Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 47px, #1a2a1a 47px, #1a2a1a 48px, transparent 48px),
        linear-gradient(0deg, transparent 47px, #1a2a1a 47px, #1a2a1a 48px, transparent 48px);
    background-size: 48px 48px;
    opacity: 0.15;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .dilemma-section {
        flex-direction: column;
    }

    .pane {
        width: 100%;
        padding: 40px 24px;
    }

    .pane-right .pane-content {
        text-align: left;
    }

    .pane-content {
        max-width: 100%;
    }

    #bisection-line {
        left: 50%;
        opacity: 0.3;
    }

    .collision-zone {
        left: 10%;
        right: 10%;
        flex-direction: column;
        text-align: center;
    }

    .collision-text-left,
    .collision-text-right {
        text-align: center;
    }

    #hud {
        padding: 8px 12px;
    }

    #hud-center {
        display: none;
    }

    .ascii-divider pre {
        font-size: 0.5rem;
    }
}
