/* ==========================================================
   turingtest.quest - Styles
   Neomorphic Turing Test Interrogation Chamber
   ========================================================== */

:root {
    --base-surface: #1E1E2A;
    --deep-substrate: #16162A;
    --content-surface: #252535;
    --primary-accent: #6C5CE7;
    --secondary-accent: #A855F7;
    --warm-signal: #E85D8C;
    --cool-signal: #22D3EE;
    --text-primary: #E8E0F0;
    --text-secondary: #C4BAD8;
    --text-tertiary: #8B7EC8;
    --highlight: #F0C27A;
    --neo-shadow-dark: rgba(0, 0, 0, 0.25);
    --neo-shadow-light: rgba(255, 255, 255, 0.06);
    --chamber-accent: #6C5CE7;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--base-surface);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================
   Typography
   ========================================================== */

.chamber-heading {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.8rem);
    letter-spacing: -0.015em;
    line-height: 1.1;
    color: var(--text-primary);
    text-shadow: 0 0 30px rgba(108, 92, 231, 0.15);
    margin-bottom: 2rem;
}

.subtitle {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    opacity: 0;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    max-width: 38em;
    margin-bottom: 1.5em;
}

.mono-accent {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: var(--primary-accent);
}

/* ==========================================================
   HUD Overlay Frame
   ========================================================== */

#hud-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#hud-frame.visible {
    opacity: 1;
}

#hud-frame.dimming {
    opacity: 0.2;
    transition: opacity 3s ease;
}

.hud-corner {
    position: absolute;
    width: 20px;
    height: 20px;
}

.hud-corner-tl {
    top: 16px;
    left: 16px;
    border-top: 1px solid var(--primary-accent);
    border-left: 1px solid var(--primary-accent);
}

.hud-corner-tr {
    top: 16px;
    right: 16px;
    border-top: 1px solid var(--primary-accent);
    border-right: 1px solid var(--primary-accent);
}

.hud-corner-bl {
    bottom: 16px;
    left: 16px;
    border-bottom: 1px solid var(--primary-accent);
    border-left: 1px solid var(--primary-accent);
}

.hud-corner-br {
    bottom: 16px;
    right: 16px;
    border-bottom: 1px solid var(--primary-accent);
    border-right: 1px solid var(--primary-accent);
}

.hud-line {
    position: absolute;
    background: var(--primary-accent);
}

.hud-line-top {
    top: 16px;
    left: 36px;
    right: 36px;
    height: 1px;
}

.hud-line-bottom {
    bottom: 16px;
    left: 36px;
    right: 36px;
    height: 1px;
}

.hud-line-left {
    left: 16px;
    top: 36px;
    bottom: 36px;
    width: 1px;
}

.hud-line-right {
    right: 16px;
    top: 36px;
    bottom: 36px;
    width: 1px;
}

#hud-status {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: var(--primary-accent);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hud-divider {
    opacity: 0.4;
}

/* ==========================================================
   Scan Line
   ========================================================== */

#scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--primary-accent);
    opacity: 0;
    z-index: 51;
    pointer-events: none;
    will-change: transform;
}

#scan-line.active {
    opacity: 0.2;
}

#scan-line.slowing {
    transition: opacity 3s ease;
    opacity: 0.05;
}

/* ==========================================================
   Phase Navigation
   ========================================================== */

#phase-nav {
    position: fixed;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#phase-nav.visible {
    opacity: 1;
}

.phase-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--content-surface);
    box-shadow: 3px 3px 6px var(--neo-shadow-dark),
                -3px -3px 6px var(--neo-shadow-light);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    pointer-events: all;
}

.phase-dot.active {
    box-shadow: inset 2px 2px 4px var(--neo-shadow-dark),
                inset -2px -2px 4px var(--neo-shadow-light),
                0 0 12px rgba(108, 92, 231, 0.4);
    background: var(--primary-accent);
}

.phase-dot::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.phase-dot:hover::after {
    opacity: 1;
}

/* ==========================================================
   Chambers - Common
   ========================================================== */

.chamber {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chamber-inner {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chamber-inset {
    margin: 0 auto;
    box-shadow: inset 8px 8px 16px var(--neo-shadow-dark),
                inset -8px -8px 16px var(--neo-shadow-light);
}

.chamber-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 40px;
}

.chamber-divider {
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--primary-accent);
    opacity: 0.4;
    z-index: 20;
    animation: pulse-divider 4s ease-in-out infinite;
}

@keyframes pulse-divider {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

/* ==========================================================
   Neural Web Background
   ========================================================== */

.neural-web {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.08;
    pointer-events: none;
}

.neural-web-dense {
    opacity: 0.12;
}

.neural-web circle {
    fill: var(--primary-accent);
    transition: opacity 0.3s ease;
}

.neural-web line {
    stroke: var(--primary-accent);
    stroke-width: 1.5;
    opacity: 0.6;
}

.neural-web circle.illuminated {
    opacity: 1;
    fill: var(--primary-accent);
    filter: drop-shadow(0 0 4px rgba(108, 92, 231, 0.6));
}

/* ==========================================================
   Opening Sequence
   ========================================================== */

.opening-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
}

.begin-test {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 1.5em;
}

.cursor-blink {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--primary-accent);
    animation: blink 1s step-end infinite;
}

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

#begin-text {
    font-size: 1rem;
}

.main-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.015em;
    line-height: 1.1;
    color: var(--text-primary);
    text-shadow: 0 0 30px rgba(108, 92, 231, 0.15);
    opacity: 0;
}

.main-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

.main-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==========================================================
   Chamber 1 - The Question
   ========================================================== */

.interrogation-grid {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 40px;
    align-items: start;
}

.pull-quotes {
    margin-top: 2rem;
}

.pull-quote {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--text-primary);
    border-left: 3px solid var(--primary-accent);
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
    text-shadow: 0 0 20px rgba(108, 92, 231, 0.1);
}

.decision-tree {
    width: 100%;
    height: auto;
    min-height: 400px;
}

.decision-tree circle {
    fill: none;
    stroke: var(--primary-accent);
    stroke-width: 1.5;
    opacity: 0.6;
}

.decision-tree line {
    stroke: var(--primary-accent);
    stroke-width: 1.5;
    opacity: 0.6;
}

.decision-tree text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    fill: var(--primary-accent);
    text-anchor: middle;
    opacity: 0.8;
}

/* ==========================================================
   Chamber 2 - The Dialogue
   ========================================================== */

.dialogue-container {
    display: grid;
    grid-template-columns: 40px 1fr 200px;
    gap: 24px;
    align-items: start;
}

.helix-container {
    position: relative;
    height: 100%;
    min-height: 500px;
}

.conversation-helix {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    background: var(--content-surface);
    border-radius: 8px;
    padding: 20px 24px;
    box-shadow: 6px 6px 12px var(--neo-shadow-dark),
                -6px -6px 12px var(--neo-shadow-light);
    transition: box-shadow 0.3s ease;
    max-width: 90%;
}

.message:hover {
    box-shadow: 8px 8px 14px var(--neo-shadow-dark),
                -8px -8px 14px var(--neo-shadow-light);
}

.message.examiner {
    border-left: 3px solid var(--warm-signal);
    align-self: flex-start;
}

.message.subject {
    border-left: 3px solid var(--primary-accent);
    align-self: flex-end;
}

.message-label {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 8px;
}

.examiner .message-label {
    color: var(--warm-signal);
}

.subject .message-label {
    color: var(--primary-accent);
}

.message p {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Diagnostic Panel */
.diagnostic-panel {
    background: var(--deep-substrate);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 8px;
    padding: 20px;
    box-shadow: inset 4px 4px 8px rgba(0, 0, 0, 0.3),
                inset -4px -4px 8px rgba(255, 255, 255, 0.03);
    position: sticky;
    top: 100px;
}

.diag-header {
    text-align: center;
    margin-bottom: 16px;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
}

.diag-gauge {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 8px;
}

.diag-gauge svg {
    width: 100%;
    height: 100%;
}

.diag-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
}

.diag-label {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    text-align: center;
    margin-bottom: 20px;
}

.diag-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.diag-bar-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.diag-bar-label {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
}

.diag-bar {
    height: 4px;
    background: var(--content-surface);
    border-radius: 2px;
    overflow: hidden;
}

.diag-bar-fill {
    height: 100%;
    background: var(--primary-accent);
    border-radius: 2px;
    transition: width 1s ease;
}

.diag-waveform {
    margin-top: 12px;
}

.diag-waveform canvas {
    width: 100%;
    height: 40px;
    display: block;
}

/* ==========================================================
   Chamber 3 - The Doubt
   ========================================================== */

.crack-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.crack-lines line {
    stroke: var(--secondary-accent);
    stroke-width: 0.5;
    opacity: 0.15;
}

.doubt-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    align-items: start;
}

.doubt-text .fragment {
    transition: opacity 0.6s ease;
}

.face-assembly {
    position: sticky;
    top: 100px;
}

#face-svg {
    width: 100%;
    height: auto;
    min-height: 350px;
}

#face-svg circle {
    fill: var(--primary-accent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

#face-svg line {
    stroke: var(--primary-accent);
    stroke-width: 1.5;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#face-svg circle.face-visible,
#face-svg line.face-visible {
    opacity: 0.7;
}

/* ==========================================================
   Chamber 4 - The Answer
   ========================================================== */

.answer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.answer-sentences {
    max-width: 38em;
}

.answer-sentence {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: 2em;
    transition: opacity 0.5s ease;
}

.answer-sentence.dimmed {
    opacity: 0.4;
}

.topaz-highlight {
    color: var(--highlight);
    font-weight: 400;
    text-shadow: 0 0 20px rgba(240, 194, 122, 0.2);
}

.answer-diagnostics {
    display: flex;
    gap: 32px;
    margin-top: 3rem;
}

.diag-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.diag-mini svg {
    width: 60px;
    height: 60px;
}

/* ==========================================================
   Chamber 5 - End Transmission
   ========================================================== */

.chamber-end {
    min-height: 50vh;
}

.end-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 40px;
}

.end-heading {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.15em;
}

.restart-button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--content-surface);
    box-shadow: 6px 6px 12px var(--neo-shadow-dark),
                -6px -6px 12px var(--neo-shadow-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.3s ease;
    padding: 12px;
}

.restart-button:hover {
    box-shadow: 8px 8px 16px var(--neo-shadow-dark),
                -8px -8px 16px var(--neo-shadow-light);
}

.restart-icon {
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
}

.restart-button:hover .restart-icon {
    transform: rotate(360deg);
}

/* ==========================================================
   Reveal Animations
   ========================================================== */

.reveal-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 768px) {
    .interrogation-grid {
        grid-template-columns: 1fr;
    }

    .grid-aside {
        display: none;
    }

    .dialogue-container {
        grid-template-columns: 1fr;
    }

    .helix-container {
        display: none;
    }

    .diagnostic-panel {
        position: static;
        margin-top: 32px;
    }

    .doubt-content {
        grid-template-columns: 1fr;
    }

    .face-assembly {
        position: static;
        max-width: 250px;
        margin: 0 auto;
    }

    .message {
        max-width: 100%;
    }

    .chamber-content {
        padding: 60px 24px;
    }

    #phase-nav {
        left: 16px;
    }

    #hud-status {
        font-size: 0.55rem;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    #hud-status {
        display: none;
    }

    #phase-nav {
        display: none;
    }
}
