/**
 * Simulated Terminal Archive - Styles
 * Clean, focused styling for the terminal interface
 */

/* ============================================================================
   Font Face - Self-hosted for consistent rendering
   ============================================================================ */

@font-face {
    font-family: 'Roboto Mono';
    src: url('fonts/RobotoMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================================================
   CSS Variables
   ============================================================================ */

:root {
    --bg: #0a0a0a;
    --fg: #00ff41;
    --fg-dim: #00aa2a;
    --fg-bright: #00ff88;
    --glow: rgba(0, 255, 65, 0.3);
    --glow-strong: rgba(0, 255, 65, 0.5);

    --font: 'Roboto Mono', 'Courier New', Courier, monospace;
    --font-size: 16px;
    --line-height: 1.4;

    --terminal-padding: 20px;
    --terminal-radius: 12px;
}

/* ============================================================================
   Base Reset
   ============================================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: var(--font-size);
    line-height: var(--line-height);
}

/* ============================================================================
   Matrix Canvas
   ============================================================================ */

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.7;
}

/* ============================================================================
   Terminal Container
   ============================================================================ */

.terminal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(95vw, 800px);
    height: min(90vh, 600px);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--fg-dim);
    border-radius: var(--terminal-radius);
    box-shadow: 0 0 30px var(--glow), inset 0 0 60px rgba(0, 0, 0, 0.5);
    z-index: 10;
    overflow: hidden;
}

/* ============================================================================
   Output Area
   ============================================================================ */

#output {
    flex: 1;
    padding: var(--terminal-padding);
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#output::-webkit-scrollbar {
    display: none;
}

/* ============================================================================
   Input Area
   ============================================================================ */

.input-line {
    display: flex;
    align-items: center;
    padding: 10px var(--terminal-padding) var(--terminal-padding);
    border-top: 1px solid rgba(0, 255, 65, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

.prompt {
    color: var(--fg);
    white-space: nowrap;
    user-select: none;
}

.user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--fg);
    font: inherit;
    caret-color: var(--fg);
    min-width: 0;
}

.user-input:focus {
    outline: none;
}

.user-input.masked-input {
    letter-spacing: 0.2em;
}

/* ============================================================================
   CRT Effects
   ============================================================================ */

.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.crt-overlay.crt-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.15) 50%
    );
    background-size: 100% 3px;
    animation: scanline 8s linear infinite;
}

.crt-overlay.crt-active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(0, 0, 0, 0.3) 100%
    );
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(6px); }
}

/* ============================================================================
   Loading Screen (minimal)
   ============================================================================ */

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-text {
    color: var(--fg);
    font-size: 14px;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

.loading-text .blink {
    animation: blink 1s step-end infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================================================
   Mobile Responsive
   ============================================================================ */

@media (max-width: 600px) {
    :root {
        --font-size: 14px;
        --terminal-padding: 12px;
    }

    .terminal {
        width: 98vw;
        height: 95vh;
        border-radius: 8px;
    }
}

/* Touch device adjustments */
@media (hover: none) and (pointer: coarse) {
    .user-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ============================================================================
   Portrait Mode Optimizations
   ============================================================================ */

/* Short prompt hidden by default */
.prompt-short {
    display: none;
}

@media (max-aspect-ratio: 4/5) {
    :root {
        --font-size: 14px;
        --terminal-padding: 10px;
    }

    /* Full-screen terminal in portrait */
    .terminal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100%;
        transform: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
        animation: none;
    }

    /* Output area: fills space above fixed input */
    #output {
        flex: 1;
        padding-bottom: 70px; /* Space for fixed input */
    }

    /* Fixed input at bottom - stays above virtual keyboard */
    .input-line {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px var(--terminal-padding);
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: rgba(0, 0, 0, 0.95);
        border-top: 1px solid var(--fg-dim);
        z-index: 20;
    }

    /* Minimalist prompt in portrait */
    .prompt-full {
        display: none;
    }

    .prompt-short {
        display: inline;
    }

    /* Reduce matrix rain opacity for better focus */
    #canvas {
        opacity: 0.4;
    }
}

/* ============================================================================
   Selection
   ============================================================================ */

::selection {
    background: var(--fg);
    color: var(--bg);
}

/* ============================================================================
   Subtle Glow Animation on Terminal
   ============================================================================ */

@keyframes terminalGlow {
    0%, 100% {
        box-shadow: 0 0 30px var(--glow), inset 0 0 60px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 40px var(--glow-strong), inset 0 0 60px rgba(0, 0, 0, 0.5);
    }
}

.terminal {
    animation: terminalGlow 4s ease-in-out infinite;
}
