/* =============================================================================
   RailScanPro Terminal Theme
   IBM 3270 Mainframe / Dispatch Terminal Aesthetic
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Font Face Definitions - Locally Hosted IBM 3270 Fonts
   ----------------------------------------------------------------------------- */

@font-face {
    font-family: 'IBM 3270';
    src: url('/fonts/terminal/3270-Regular.woff2') format('woff2'),
         url('/fonts/terminal/3270-Regular.woff') format('woff'),
         url('/fonts/terminal/3270-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM 3270 Condensed';
    src: url('/fonts/terminal/3270Condensed-Regular.woff2') format('woff2'),
         url('/fonts/terminal/3270Condensed-Regular.woff') format('woff'),
         url('/fonts/terminal/3270Condensed-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM 3270 SemiCondensed';
    src: url('/fonts/terminal/3270SemiCondensed-Regular.woff2') format('woff2'),
         url('/fonts/terminal/3270SemiCondensed-Regular.woff') format('woff'),
         url('/fonts/terminal/3270SemiCondensed-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* -----------------------------------------------------------------------------
   CSS Custom Properties - Terminal Color Palettes
   ----------------------------------------------------------------------------- */

:root {
    /* Green Phosphor (P1) - Classic IBM 3270 */
    --terminal-green-bg: #0a1a0a;
    --terminal-green-text: #33ff33;
    --terminal-green-dim: #1a991a;
    --terminal-green-bright: #66ff66;
    --terminal-green-glow: rgba(51, 255, 51, 0.4);

    /* Amber Phosphor (P3) - Warmer, easier on eyes */
    --terminal-amber-bg: #1a1100;
    --terminal-amber-text: #ffb000;
    --terminal-amber-dim: #996600;
    --terminal-amber-bright: #ffcc00;
    --terminal-amber-glow: rgba(255, 176, 0, 0.4);

    /* White Phosphor (P4) - Page white */
    --terminal-white-bg: #0a0a0a;
    --terminal-white-text: #e0e0e0;
    --terminal-white-dim: #808080;
    --terminal-white-bright: #ffffff;
    --terminal-white-glow: rgba(255, 255, 255, 0.3);

    /* Shared terminal properties */
    --terminal-font: 'IBM 3270', 'Consolas', 'Courier New', monospace;
    --terminal-font-condensed: 'IBM 3270 Condensed', 'IBM 3270', monospace;
    --terminal-font-semicondensed: 'IBM 3270 SemiCondensed', 'IBM 3270', monospace;
    --terminal-line-height: 1.4;
    --terminal-letter-spacing: 0.05em;
}

/* -----------------------------------------------------------------------------
   Base Terminal Screen Classes
   ----------------------------------------------------------------------------- */

.terminal-screen {
    font-family: var(--terminal-font);
    line-height: var(--terminal-line-height);
    letter-spacing: var(--terminal-letter-spacing);
    padding: 1rem;
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
}

/* Green Screen (Default IBM 3270) */
.terminal-green {
    background-color: var(--terminal-green-bg);
    color: var(--terminal-green-text);
    text-shadow:
        0 0 2px var(--terminal-green-text),
        0 0 8px var(--terminal-green-glow);
}

/* Amber Screen */
.terminal-amber {
    background-color: var(--terminal-amber-bg);
    color: var(--terminal-amber-text);
    text-shadow:
        0 0 2px var(--terminal-amber-text),
        0 0 8px var(--terminal-amber-glow);
}

/* White/Gray Screen */
.terminal-white {
    background-color: var(--terminal-white-bg);
    color: var(--terminal-white-text);
    text-shadow:
        0 0 1px var(--terminal-white-text),
        0 0 4px var(--terminal-white-glow);
}

/* -----------------------------------------------------------------------------
   CRT Effects (Optional - Apply with .crt-effects class)
   ----------------------------------------------------------------------------- */

.crt-effects {
    animation: crt-flicker 0.15s infinite;
}

.crt-effects::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 10;
}

/* Subtle screen curvature effect */
.crt-effects::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 70%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 11;
}

@keyframes crt-flicker {
    0% { opacity: 0.97; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

/* -----------------------------------------------------------------------------
   Terminal Text Styling
   ----------------------------------------------------------------------------- */

/* Dim/Low intensity text */
.terminal-green .terminal-dim { color: var(--terminal-green-dim); text-shadow: none; }
.terminal-amber .terminal-dim { color: var(--terminal-amber-dim); text-shadow: none; }
.terminal-white .terminal-dim { color: var(--terminal-white-dim); text-shadow: none; }

/* Bright/High intensity text */
.terminal-green .terminal-bright { color: var(--terminal-green-bright); }
.terminal-amber .terminal-bright { color: var(--terminal-amber-bright); }
.terminal-white .terminal-bright { color: var(--terminal-white-bright); }

/* Standard text (inherits from parent) */
.terminal-text { color: inherit; }

/* Border styling */
.terminal-green .terminal-border { border-color: var(--terminal-green-dim); }
.terminal-amber .terminal-border { border-color: var(--terminal-amber-dim); }
.terminal-white .terminal-border { border-color: var(--terminal-white-dim); }

/* Highlight (reverse video for emphasis) */
.terminal-green .terminal-highlight {
    background-color: var(--terminal-green-text);
    color: var(--terminal-green-bg);
    text-shadow: none;
}
.terminal-amber .terminal-highlight {
    background-color: var(--terminal-amber-text);
    color: var(--terminal-amber-bg);
    text-shadow: none;
}
.terminal-white .terminal-highlight {
    background-color: var(--terminal-white-text);
    color: var(--terminal-white-bg);
    text-shadow: none;
}

/* Background text (for inverted sections) */
.terminal-green .terminal-bg-text { color: var(--terminal-green-bg); }
.terminal-amber .terminal-bg-text { color: var(--terminal-amber-bg); }
.terminal-white .terminal-bg-text { color: var(--terminal-white-bg); }

/* Button styling */
.terminal-button {
    font-family: var(--terminal-font);
    background-color: transparent;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.terminal-green .terminal-button {
    color: var(--terminal-green-text);
    border-color: var(--terminal-green-dim);
}
.terminal-green .terminal-button:hover {
    background-color: var(--terminal-green-text);
    color: var(--terminal-green-bg);
}

.terminal-amber .terminal-button {
    color: var(--terminal-amber-text);
    border-color: var(--terminal-amber-dim);
}
.terminal-amber .terminal-button:hover {
    background-color: var(--terminal-amber-text);
    color: var(--terminal-amber-bg);
}

.terminal-white .terminal-button {
    color: var(--terminal-white-text);
    border-color: var(--terminal-white-dim);
}
.terminal-white .terminal-button:hover {
    background-color: var(--terminal-white-text);
    color: var(--terminal-white-bg);
}

/* Blinking cursor */
.terminal-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.2em;
    animation: cursor-blink 1s step-end infinite;
}

.terminal-green .terminal-cursor { background-color: var(--terminal-green-text); }
.terminal-amber .terminal-cursor { background-color: var(--terminal-amber-text); }
.terminal-white .terminal-cursor { background-color: var(--terminal-white-text); }

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

/* Reverse video (highlighted text) */
.terminal-reverse {
    padding: 0 0.25em;
}

.terminal-green .terminal-reverse {
    background-color: var(--terminal-green-text);
    color: var(--terminal-green-bg);
    text-shadow: none;
}

.terminal-amber .terminal-reverse {
    background-color: var(--terminal-amber-text);
    color: var(--terminal-amber-bg);
    text-shadow: none;
}

.terminal-white .terminal-reverse {
    background-color: var(--terminal-white-text);
    color: var(--terminal-white-bg);
    text-shadow: none;
}

/* Underlined fields (common in 3270 forms) */
.terminal-field {
    border-bottom: 1px solid currentColor;
    padding: 0 0.5em;
    margin: 0 0.25em;
}

/* -----------------------------------------------------------------------------
   Railroad Dispatch-Specific Styling
   ----------------------------------------------------------------------------- */

/* Status indicators */
.terminal-status-clear { color: #33ff33 !important; }     /* Green - Clear signal */
.terminal-status-caution { color: #ffff00 !important; }   /* Yellow - Approach */
.terminal-status-stop { color: #ff3333 !important; }      /* Red - Stop */
.terminal-status-restricted { color: #ff8800 !important; } /* Orange - Restricting */

/* Track occupancy display */
.terminal-track-occupied {
    background-color: rgba(255, 51, 51, 0.3);
    border: 1px solid #ff3333;
}

.terminal-track-clear {
    background-color: rgba(51, 255, 51, 0.1);
    border: 1px solid currentColor;
}

/* Train ID display */
.terminal-train-id {
    font-family: var(--terminal-font-condensed);
    padding: 0.125em 0.5em;
    border: 1px solid currentColor;
    display: inline-block;
}

/* -----------------------------------------------------------------------------
   Form Layout (IBM 3270 Style)
   ----------------------------------------------------------------------------- */

.terminal-form {
    display: grid;
    gap: 0.5rem;
}

.terminal-form-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.terminal-label {
    min-width: 15ch;
    text-align: right;
}

.terminal-input {
    font-family: var(--terminal-font);
    background: transparent;
    border: none;
    border-bottom: 1px solid currentColor;
    color: inherit;
    padding: 0.25em 0.5em;
    min-width: 20ch;
    text-shadow: inherit;
}

.terminal-input:focus {
    outline: none;
    border-bottom-width: 2px;
}

.terminal-input::placeholder {
    opacity: 0.5;
}

/* Function key row (PF keys) */
.terminal-pf-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid currentColor;
    opacity: 0.8;
    font-size: 0.875em;
}

.terminal-pf-key {
    padding: 0.25em 0.5em;
    border: 1px solid currentColor;
    cursor: pointer;
    transition: all 0.1s;
}

.terminal-pf-key:hover {
    background-color: currentColor;
    color: var(--terminal-green-bg);
}

/* -----------------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------------- */

.font-3270 { font-family: var(--terminal-font); }
.font-3270-condensed { font-family: var(--terminal-font-condensed); }
.font-3270-semicondensed { font-family: var(--terminal-font-semicondensed); }

/* Text sizes optimized for terminal display */
.terminal-xs { font-size: 0.75rem; }
.terminal-sm { font-size: 0.875rem; }
.terminal-base { font-size: 1rem; }
.terminal-lg { font-size: 1.125rem; }
.terminal-xl { font-size: 1.25rem; }
.terminal-2xl { font-size: 1.5rem; }
