/* ═══════════════════════════════════════════════════════════════
   Colossal Cave Adventure — 3270 Terminal + Punch Card Theme
   ═══════════════════════════════════════════════════════════════ */

:root {
    --phosphor: #33ff33;
    --phosphor-dim: #1a8c1a;
    --phosphor-glow: rgba(51, 255, 51, 0.3);
    --crt-bg: #0a0a0a;
    --card-bg: #f5f0e0;
    --card-border: #c4b898;
    --card-hole: #c4b89880;
    --fortran-accent: #8b6914;
    --rust-accent: #b7410e;
    --panel-bg: #1a1a2e;
    --tutorial-bg: #12121c;
    --text-light: #e0dcc8;
    --text-muted: #8a8670;
}

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

html, body {
    height: 100%;
    background: #0d0d1a;
    color: var(--text-light);
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    overflow: hidden;
}

/* ─── Two-Column Layout ───────────────────────────────────── */

.app-container {
    display: grid;
    grid-template-columns: 1fr 520px;
    height: 100vh;
    gap: 2px;
    background: #000;
}

.pane {
    overflow: hidden;
}

/* ─── Right Column: image + tutorial stacked ──────────────── */

.right-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--tutorial-bg);
}

/* ─── 3270 Terminal ────────────────────────────────────────── */

.terminal {
    width: 100%;
    height: 100%;
    background: var(--crt-bg);
    position: relative;
    border: 3px solid #222;
    border-radius: 8px;
}

.terminal-screen {
    width: 100%;
    height: 100%;
    padding: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    /* CRT curvature effect */
    background: radial-gradient(ellipse at center, #0a0a0a 0%, #050505 100%);
}

/* CRT scanlines */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    z-index: 10;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    line-height: 1.4;
    color: var(--phosphor);
    text-shadow: 0 0 5px var(--phosphor-glow);
    scrollbar-width: none;
}

.terminal-output::-webkit-scrollbar {
    display: none;
}

.terminal-line {
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 1.4em;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #1a3a1a;
}

.prompt {
    color: var(--phosphor);
    text-shadow: 0 0 5px var(--phosphor-glow);
    font-size: 14px;
    flex-shrink: 0;
}

/* Visible echo of typed text */
.input-echo {
    color: var(--phosphor);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    text-shadow: 0 0 5px var(--phosphor-glow);
    white-space: pre;
}

/* Hidden real input — captures keystrokes */
.terminal-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    pointer-events: none;
}

/* Cursor sits right after the echo text */
.cursor {
    color: var(--phosphor);
    opacity: 0;
    text-shadow: 0 0 5px var(--phosphor-glow);
    transition: opacity 0.1s;
    flex-shrink: 0;
}

.cursor.visible {
    opacity: 1;
}

/* ─── Room Image ───────────────────────────────────────────── */

.image-section {
    flex-shrink: 0;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.image-section.collapsed {
    display: none;
}

.room-image-container {
    position: relative;
    width: 100%;
    max-width: 512px;
    aspect-ratio: 1 / 1;
}

.room-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid #333;
    border-radius: 4px;
    transition: opacity 0.5s ease-in-out;
}

.room-image.dark {
    filter: brightness(0.05);
}

.dark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 4px;
}

.dark-text {
    color: var(--phosphor-dim);
    font-size: 18px;
    text-shadow: 0 0 10px var(--phosphor-glow);
    letter-spacing: 0.3em;
}

/* ─── Image Toggle Bar ────────────────────────────────────── */

.image-toggle-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 2px 8px;
    background: #0e0e18;
    border-bottom: 1px solid #222;
}

.image-toggle-btn {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-muted);
    padding: 2px 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s;
}

.image-toggle-btn:hover {
    border-color: var(--phosphor-dim);
    color: var(--phosphor);
}

/* ─── Tutorial Panel ───────────────────────────────────────── */

.tutorial-pane {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.tutorial-panel {
    padding: 16px;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

.tutorial-title {
    font-size: 15px;
    color: var(--text-light);
    font-weight: 700;
}

.explore-btn {
    background: transparent;
    border: 1px solid #555;
    color: var(--text-muted);
    padding: 4px 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.explore-btn:hover {
    border-color: var(--phosphor-dim);
    color: var(--phosphor);
}

.explore-btn.active {
    border-color: var(--phosphor);
    color: var(--phosphor);
    background: rgba(51, 255, 51, 0.1);
}

/* ─── Explore Navigation ──────────────────────────────────── */

.explore-nav {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(51, 255, 51, 0.04);
    border: 1px solid rgba(51, 255, 51, 0.15);
    border-radius: 4px;
}

.explore-nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.nav-btn {
    background: transparent;
    border: 1px solid #555;
    color: var(--text-muted);
    padding: 4px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: var(--phosphor-dim);
    color: var(--phosphor);
}

.nav-room-label {
    color: var(--phosphor);
    font-size: 13px;
    font-weight: 700;
    min-width: 70px;
    text-align: center;
}

.explore-featured {
    border-top: 1px solid rgba(51, 255, 51, 0.1);
    padding-top: 8px;
}

.featured-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}

.featured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.featured-room {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-muted);
    padding: 2px 7px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.15s;
}

.featured-room:hover {
    border-color: var(--phosphor-dim);
    color: var(--phosphor);
}

.featured-room.active {
    border-color: var(--phosphor);
    color: var(--crt-bg);
    background: var(--phosphor);
}

/* ─── The Machine Room (appears first) ────────────────────── */

.machine-room {
    padding: 12px;
    background: rgba(26, 26, 46, 0.5);
    border-radius: 4px;
    border: 1px solid #2a2a3e;
    border-left: 3px solid #4a3a6e;
    margin-bottom: 12px;
}

.machine-room h3 {
    font-size: 15px;
    color: #8a7ab0;
    margin-bottom: 8px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.machine-room h3::before {
    content: '\2699 ';  /* gear symbol */
}

.machine-room p {
    font-size: 14px;
    line-height: 1.7;
    color: #b0a8c8;
    font-style: italic;
    margin-bottom: 0.8em;
}

.machine-room p:last-child {
    margin-bottom: 0;
}

.machine-room a {
    color: #a99fd8;
    text-decoration: underline;
    text-decoration-color: #6a5f8a;
    transition: color 0.15s;
}

.machine-room a:hover {
    color: #d0c8f0;
    text-decoration-color: #a99fd8;
}

/* ─── Tutorial Discussion ──────────────────────────────────── */

.tutorial-discussion {
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border-left: 3px solid #444;
}

.tutorial-discussion h3 {
    font-size: 15px;
    color: var(--phosphor-dim);
    margin-bottom: 8px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.tutorial-discussion p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-light);
    margin-bottom: 0.8em;
}

.tutorial-discussion p:last-child {
    margin-bottom: 0;
}

.tutorial-discussion a {
    color: var(--phosphor);
    text-decoration: underline;
    text-decoration-color: var(--phosphor-dim);
    transition: color 0.15s;
}

.tutorial-discussion a:hover {
    color: #66ff66;
}

/* ─── Punch Card Code Blocks ───────────────────────────────── */

.punch-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 2px;
    margin-bottom: 12px;
    position: relative;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
}

.punch-card.fortran {
    border-left: 4px solid var(--fortran-accent);
}

.punch-card.rust {
    border-left: 4px solid var(--rust-accent);
}

.punch-holes {
    font-size: 7px;
    letter-spacing: 3px;
    color: var(--card-hole);
    padding: 2px 12px;
    user-select: none;
    line-height: 1;
}

.punch-holes.top {
    border-bottom: 1px solid #e8e0cc;
}

.punch-holes.bottom {
    border-top: 1px solid #e8e0cc;
}

.card-label {
    position: absolute;
    top: 2px;
    right: 8px;
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.punch-card.fortran .card-label {
    color: var(--fortran-accent);
}

.punch-card.rust .card-label {
    color: var(--rust-accent);
}

.card-code {
    padding: 8px 12px;
    font-size: 11px;
    line-height: 1.5;
    color: #2a2a2a;
    overflow-x: auto;
    white-space: pre;
    font-family: 'IBM Plex Mono', monospace;
    /* FORTRAN column markers */
    background: linear-gradient(
        to right,
        transparent 0ch,
        transparent 5.5ch,
        #ede8d8 5.5ch,
        #ede8d8 6.5ch,
        transparent 6.5ch
    );
}

.punch-card.rust .card-code {
    background: none;
}

/* ─── Responsive (Desktop Only) ────────────────────────────── */

/* ─── Ambient Glow Effects ─────────────────────────────────── */

.terminal::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: radial-gradient(ellipse at center, var(--phosphor-glow) 0%, transparent 70%);
    opacity: 0.15;
    border-radius: 10px;
    pointer-events: none;
    z-index: -1;
}

/* ─── Acknowledgments Bar ──────────────────────────────────── */

.ack-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-muted);
    font-size: 10px;
    padding: 4px 16px;
    text-align: center;
    border-top: 1px solid #222;
    z-index: 100;
}

.ack-bar a {
    color: var(--phosphor-dim);
    text-decoration: none;
}

.ack-bar a:hover {
    color: var(--phosphor);
}
