/* ============================================
   TURINGTEST.QUEST - Adventure Game Quest
   ============================================ */

:root {
    --base-bg: #12121e;
    --surface: #1e1e2e;
    --text: #c8c8d4;
    --cyan: #4dc9f6;
    --amber: #f0a030;
    --green: #3dd68c;
    --red: #e05555;
    --border: #3a3a4a;
    --hud: #8888a0;
}

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

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

body {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text);
    background: var(--base-bg);
    overflow-x: hidden;
    padding-bottom: 48px;
}

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

#hud-room {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    color: var(--hud);
}

#hud-compass {
    opacity: 0.6;
    transition: transform 0.3s ease;
}

#hud-progress {
    position: fixed;
    bottom: 48px;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(58,58,74,0.5);
    z-index: 101;
}

#hud-bar {
    height: 100%;
    width: 0%;
    background: var(--cyan);
    transition: width 0.2s ease;
    box-shadow: 0 0 6px rgba(77,201,246,0.5);
}

/* === Inventory Bar === */
#inventory-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(18,18,30,0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 100;
    padding: 0 1rem;
}

.inv-slot {
    width: 32px;
    height: 32px;
    opacity: 0;
    transform: scale(0) translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.inv-slot.collected {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.inv-slot.glow svg rect {
    filter: brightness(1.8);
}

.pixel-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

/* === Room Sections === */
.room {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: var(--base-bg);
}

.room-border {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    border: 1px solid var(--border);
    pointer-events: none;
    z-index: 2;
}

.room-border-expand {
    transition: top 1s ease, left 1s ease, right 1s ease, bottom 1s ease;
}

.room-content {
    position: relative;
    z-index: 5;
    max-width: 800px;
    width: 100%;
}

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

.room-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    color: var(--cyan);
    margin-bottom: 2rem;
    opacity: 0;
    transition: opacity 1s ease;
}

.room-title.visible {
    opacity: 1;
}

/* === Flicker Overlay === */
.flicker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(200,200,212,0.02);
    pointer-events: none;
    z-index: 3;
    animation: flicker 4s step-end infinite;
}

@keyframes flicker {
    0%, 5% { opacity: 0; }
    6% { opacity: 1; }
    7% { opacity: 0; }
    30%, 31% { opacity: 0.5; }
    32% { opacity: 0; }
    70%, 72% { opacity: 0.3; }
    73%, 100% { opacity: 0; }
}

.flicker-once {
    animation: flickerOnce 1s step-end forwards;
}

@keyframes flickerOnce {
    0% { opacity: 0; }
    20% { opacity: 0.8; }
    40% { opacity: 0; }
    60% { opacity: 0.4; }
    100% { opacity: 0; }
}

/* === Terminal Blocks === */
.terminal-block {
    margin-top: 2rem;
}

.terminal-screen {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: inset 0 2px 12px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    max-width: 500px;
}

.terminal-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.06) 2px,
        rgba(0,0,0,0.06) 4px
    );
    pointer-events: none;
}

.term-line {
    font-family: 'Fira Mono', monospace;
    font-size: clamp(0.75rem, 0.9vw, 0.9rem);
    color: var(--cyan);
    text-shadow: 0 0 6px rgba(77,201,246,0.5);
    line-height: 1.6;
    opacity: 0;
    margin-bottom: 0.3rem;
}

.term-line.visible {
    opacity: 1;
}

.cursor-blink {
    animation: cursorBlink 1s step-end infinite;
}

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

/* === Door Motif === */
.door-motif {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
    z-index: 5;
    position: relative;
}

.door-frame {
    width: 120px;
    height: 180px;
    border: 3px solid var(--border);
    position: relative;
    background: var(--surface);
    overflow: hidden;
}

.door-surface {
    width: 100%;
    height: 100%;
    background: var(--base-bg);
    transition: transform 0.8s ease;
    transform-origin: left center;
}

.door-motif.opened .door-surface {
    transform: scaleX(0);
}

.door-knob {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
    border: 1px solid var(--hud);
}

.door-glow {
    position: absolute;
    right: -1px;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--amber);
    opacity: 0.7;
    box-shadow: 0 0 10px var(--amber);
}

.glow-cyan {
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

/* === Corridor (horizontal scroll) === */
.corridor {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    height: 100vh;
    background: var(--base-bg);
}

.corridor-track {
    display: flex;
    width: 300vw;
    height: 100%;
}

.corridor-panel {
    width: 100vw;
    height: 100%;
    flex-shrink: 0;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

.corridor-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--surface) 0%, var(--base-bg) 50%, var(--surface) 100%);
    opacity: 0.5;
}

.corridor-text {
    font-family: 'Fira Mono', monospace;
    font-size: clamp(1.2rem, 2vw, 2rem);
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(77,201,246,0.4);
    z-index: 2;
    opacity: 0.7;
    letter-spacing: 0.05em;
}

/* === Cable Bundles === */
.cable-bundle {
    position: absolute;
    height: 4px;
    border-radius: 2px;
    z-index: 1;
}

.cable-1 {
    width: 60%;
    bottom: 20%;
    left: 10%;
    background: #2a2a3a;
}

.cable-2 {
    width: 40%;
    top: 15%;
    right: 5%;
    background: #3a3a4a;
}

.cable-3 {
    width: 70%;
    top: 30%;
    left: 15%;
    background: #2a2a3a;
}

/* === Warning Tape === */
.warning-tape {
    position: absolute;
    bottom: 10%;
    left: 0;
    width: 100%;
    height: 24px;
    background: repeating-linear-gradient(
        45deg,
        var(--amber),
        var(--amber) 10px,
        var(--base-bg) 10px,
        var(--base-bg) 20px
    );
    opacity: 0.6;
}

/* === File Cards === */
.file-cards {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.file-card {
    background: #2a2838;
    border: 1px solid var(--border);
    padding: 1.5rem 2rem;
    border-radius: 4px;
    max-width: 500px;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.file-card.slide-left {
    transform: translateX(-40px) rotate(-0.5deg);
    align-self: flex-start;
}

.file-card.slide-right {
    transform: translateX(40px) rotate(0.5deg);
    align-self: flex-end;
}

.file-card.revealed {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
}

.card-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: var(--amber);
    margin-bottom: 0.75rem;
}

.card-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.9rem, 1vw, 1rem);
    color: var(--text);
    line-height: 1.6;
}

/* === Testing Chamber Split === */
.room-split {
    display: flex;
    flex-direction: column;
}

.test-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.test-machine {
    background: rgba(30,30,46,0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.test-human {
    padding: 1.5rem;
}

.human-response {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.human-response.revealed {
    opacity: 1;
    transform: translateY(0);
}

.typed-scroll {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.typed-scroll.visible {
    opacity: 1;
}

.accent-amber {
    color: var(--amber);
    font-weight: 500;
}

/* === Room 04: The Core === */
#room-04 {
    position: relative;
}

.core-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80vw;
    height: 80vw;
    max-width: 600px;
    max-height: 600px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(77,201,246,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

.core-question {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1rem, 2.5vw, 2rem);
    color: var(--cyan);
    text-shadow: 0 0 15px rgba(77,201,246,0.4);
    margin-bottom: 2rem;
    animation: corePulse 3s ease-in-out infinite;
    text-align: center;
    line-height: 1.8;
}

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

.core-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    font-style: italic;
    color: var(--text);
    line-height: 1.8;
    max-width: 600px;
    opacity: 0.8;
    z-index: 5;
    position: relative;
}

/* === End Screen === */
#room-end {
    background: var(--base-bg);
}

.end-title {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--green);
    text-shadow: 0 0 15px rgba(61,214,140,0.5);
}

.end-transmission {
    font-family: 'Fira Mono', monospace;
    font-size: 0.9rem;
    color: var(--text);
    opacity: 0.5;
    margin-top: 2rem;
}

.end-domain {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    color: var(--hud);
    margin-top: 3rem;
    opacity: 0.4;
}

/* === Responsive === */
@media (max-width: 768px) {
    .room-border {
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .corridor {
        height: auto;
        overflow-x: hidden;
    }

    .corridor-track {
        flex-direction: column;
        width: 100%;
        height: auto;
    }

    .corridor-panel {
        width: 100%;
        height: 50vh;
    }

    .test-split {
        grid-template-columns: 1fr;
    }

    #hud {
        padding: 8px 12px;
    }

    .file-card {
        max-width: 100%;
    }

    .file-card.slide-left,
    .file-card.slide-right {
        align-self: stretch;
    }
}
