/* ═══════════════════════════════════════════════════
   TERMINAL.CSS — Full Interactive Terminal UI
   The Analog Supercomputer — CRT Terminal Emulator
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

/* ─── Tokens ─── */
:root {
    --green: #00ff41;
    --green-dim: #00cc33;
    --green-muted: #4a9e5c;
    --green-ghost: #1a5c28;
    --green-glow: rgba(0, 255, 65, 0.15);
    --green-glow-strong: rgba(0, 255, 65, 0.35);
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-high: #1a1a1a;
    --surface-highest: #252525;
    --red: #ff5f56;
    --yellow: #ffbd2e;
    --blue: #6fc3df;
    --cyan: #00e5ff;
    --magenta: #ff79c6;
    --orange: #ff6b35;
    --white: #e0e0e0;
    --white-dim: #999;
    --error: #ff5555;
    --font: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

::selection {
    background: var(--green);
    color: #000;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--green-ghost); }
::-webkit-scrollbar-thumb:hover { background: var(--green-muted); }

/* ─── CRT Effects ─── */
.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
}

.crt-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(0, 0, 0, 0.35) 100%
    );
}

body.no-crt .scanlines,
body.no-crt .crt-glow {
    display: none;
}

/* ─── Terminal Window ─── */
.terminal {
    width: 100%;
    max-width: 960px;
    height: calc(100vh - 24px);
    max-height: 800px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--green-ghost);
    box-shadow:
        0 0 40px rgba(0, 255, 65, 0.04),
        0 0 2px rgba(0, 255, 65, 0.1),
        inset 0 0 80px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* ─── Title Bar ─── */
.terminal__titlebar {
    display: flex;
    align-items: center;
    height: 38px;
    padding: 0 14px;
    background: var(--surface-high);
    border-bottom: 1px solid var(--green-ghost);
    flex-shrink: 0;
    user-select: none;
}

.terminal__titlebar-dots {
    display: flex;
    gap: 7px;
    margin-right: 14px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot--red { background: var(--red); }
.dot--yellow { background: var(--yellow); }
.dot--green { background: #27c93f; }

.terminal__titlebar-title {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    color: var(--green-muted);
    letter-spacing: 0.08rem;
}

.terminal__titlebar-actions {
    display: flex;
    gap: 6px;
}

.terminal__titlebar-btn {
    background: none;
    border: 1px solid var(--green-ghost);
    color: var(--green-ghost);
    font-family: var(--font);
    font-size: 0.6rem;
    padding: 2px 8px;
    cursor: pointer;
    letter-spacing: 0.05rem;
}

.terminal__titlebar-btn:hover {
    border-color: var(--green-muted);
    color: var(--green-muted);
}

.terminal__titlebar-btn.active {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-glow);
}

/* ─── Terminal Body ─── */
.terminal__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    scroll-behavior: auto;
}

.terminal__output {
    flex: 1;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.82rem;
    line-height: 1.65;
    letter-spacing: 0.04rem;
}

/* ─── Output Line Types ─── */
.line { margin: 0; }

.line-cmd {
    color: var(--white);
}

.line-cmd .prompt-user { color: var(--green); font-weight: 600; }
.line-cmd .prompt-at { color: var(--green-muted); }
.line-cmd .prompt-host { color: var(--green-dim); }
.line-cmd .prompt-colon { color: var(--white-dim); }
.line-cmd .prompt-path { color: var(--blue); font-weight: 500; }
.line-cmd .prompt-dollar { color: var(--white-dim); margin-right: 8px; }
.line-cmd .cmd-text { color: var(--white); }

.line-output { color: var(--green); }
.line-info { color: var(--green-dim); }
.line-dim { color: var(--green-muted); }
.line-ghost { color: var(--green-ghost); }
.line-error { color: var(--error); }
.line-warning { color: var(--yellow); }
.line-cyan { color: var(--cyan); }
.line-blue { color: var(--blue); }
.line-magenta { color: var(--magenta); }
.line-white { color: var(--white); }
.line-orange { color: var(--orange); }
.line-bold { font-weight: 700; }
.line-blank { height: 0.82rem; }

/* Clickable links in output */
.term-link {
    color: var(--cyan);
    text-decoration: underline;
    text-decoration-color: var(--green-ghost);
    cursor: pointer;
    text-underline-offset: 3px;
}
.term-link:hover {
    color: var(--green);
    text-decoration-color: var(--green);
    text-shadow: 0 0 8px var(--green-glow-strong);
}

/* Badges */
.badge-free {
    color: #000;
    background: var(--green);
    padding: 0 5px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06rem;
}
.badge-pro {
    color: #000;
    background: var(--orange);
    padding: 0 5px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06rem;
}

/* ASCII art blocks */
.ascii-block {
    color: var(--green-ghost);
    line-height: 1.25;
    font-size: 0.75rem;
}

.ascii-block.bright {
    color: var(--green);
    text-shadow: 0 0 12px var(--green-glow-strong);
}

/* Directory listing table */
.ls-table {
    display: inline;
}

.ls-entry {
    display: inline-block;
    min-width: 24ch;
    padding-right: 2ch;
}

.ls-dir { color: var(--blue); font-weight: 600; }
.ls-file { color: var(--green); }
.ls-exec { color: var(--green); font-weight: 700; }
.ls-link { color: var(--cyan); }

/* Skills bars */
.skill-bar {
    display: inline-block;
}
.skill-bar-fill { color: var(--green); }
.skill-bar-empty { color: var(--green-ghost); }
.skill-bar-label { color: var(--green-muted); display: inline-block; min-width: 18ch; }

/* ─── Input Line ─── */
.terminal__input-line {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.82rem;
    line-height: 1.65;
    padding-top: 2px;
}

.terminal__prompt {
    white-space: nowrap;
    flex-shrink: 0;
}

.prompt-user { color: var(--green); font-weight: 600; }
.prompt-at { color: var(--green-muted); }
.prompt-host { color: var(--green-dim); }
.prompt-colon { color: var(--white-dim); }
.prompt-path { color: var(--blue); font-weight: 500; }
.prompt-dollar { color: var(--white-dim); margin-right: 8px; }

.terminal__input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.terminal__input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--white);
    font-family: var(--font);
    font-size: 0.82rem;
    letter-spacing: 0.04rem;
    caret-color: var(--green);
    line-height: 1.65;
}

/* ─── Mobile Hint ─── */
.mobile-hint {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font);
    font-size: 0.65rem;
    color: var(--green-ghost);
    text-align: center;
    z-index: 10;
    letter-spacing: 0.06rem;
    pointer-events: none;
    transition: opacity 0.3s;
}

.mobile-hint strong { color: var(--green-muted); }

.mobile-hint.hidden { opacity: 0; }

/* ─── Typing animation for boot ─── */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-cursor::after {
    content: '█';
    animation: blink 0.7s step-end infinite;
    color: var(--green);
    margin-left: 1px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    body { padding: 0; }

    .terminal {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border: none;
    }

    .terminal__body {
        padding: 10px 8px;
    }

    .terminal__output {
        font-size: 0.68rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .terminal__output .line {
        white-space: pre-wrap;
        word-break: break-word;
    }

    .terminal__input {
        font-size: 0.68rem;
    }

    .terminal__input-line {
        font-size: 0.68rem;
        flex-wrap: wrap;
    }

    .terminal__prompt {
        font-size: 0.65rem;
    }

    .ls-entry {
        min-width: 14ch;
        font-size: 0.65rem;
    }

    .ascii-block {
        font-size: 0.55rem;
        letter-spacing: -0.02rem;
    }

    .terminal__titlebar-actions {
        display: none;
    }

    .terminal__titlebar-title {
        font-size: 0.6rem;
    }
}

@media (max-width: 400px) {
    .terminal__output { font-size: 0.6rem; }
    .terminal__input { font-size: 0.6rem; }
    .terminal__input-line { font-size: 0.6rem; }
    .terminal__prompt { font-size: 0.55rem; }
    .ascii-block { font-size: 0.48rem; letter-spacing: -0.03rem; }
    .ls-entry { min-width: 12ch; }
}

/* ─── Fullscreen mode ─── */
.terminal.fullscreen {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border: none;
}
