/*
 * ERROR-404: Base Stylesheet
 * A broken streaming platform - CRT/Terminal aesthetic
 * Year: 2147
 */

/* ============================================
   CSS Custom Properties (Theme Variables)
   ============================================ */
:root {
    /* Phosphor Green CRT Palette */
    --phosphor-green: #00ff41;
    --phosphor-bright: #00ff6a;
    --phosphor-dim: #00802a;
    --phosphor-dark: #004d19;
    --phosphor-glow: rgba(0, 255, 65, 0.4);
    --phosphor-subtle: rgba(0, 255, 65, 0.1);

    /* Background Tones */
    --crt-black: #050505;
    --crt-dark: #0a0a0a;
    --crt-panel: #0d0d0d;
    --crt-border: #1a1a1a;

    /* Alert Colors */
    --warning-red: #ff0040;
    --warning-amber: #ffaa00;
    --info-cyan: #00ffff;

    /* Effect Controls */
    --scanline-opacity: 0.06;
    --static-intensity: 0.03;
    --glitch-frequency: 0.3;

    /* Typography */
    --font-mono: 'VT323', 'Courier New', monospace;
    --font-system: 'Share Tech Mono', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

body {
    font-family: var(--font-mono);
    background-color: var(--crt-black);
    color: var(--phosphor-green);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* ============================================
   CRT Screen Effects
   ============================================ */

/* Scanlines overlay - apply to body or container */
.crt-screen::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, var(--scanline-opacity)) 2px,
        rgba(0, 0, 0, var(--scanline-opacity)) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* Subtle flicker */
.crt-screen::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 255, 65, 0.015);
    pointer-events: none;
    z-index: 9998;
    animation: crt-flicker 0.1s infinite;
}

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

/* Vignette effect */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 9997;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-system);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 0 10px var(--phosphor-glow);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--phosphor-bright);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--phosphor-green);
    text-shadow: 0 0 8px var(--phosphor-glow);
}

code, pre {
    font-family: var(--font-mono);
    background: var(--crt-panel);
    border: 1px solid var(--crt-border);
}

code {
    padding: var(--space-xs) var(--space-sm);
}

pre {
    padding: var(--space-md);
    overflow-x: auto;
}

/* ============================================
   Layout Components
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.panel {
    background: var(--crt-panel);
    border: 1px solid var(--phosphor-dark);
    padding: var(--space-lg);
    position: relative;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--phosphor-dim),
        transparent
    );
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--crt-border);
    margin-bottom: var(--space-md);
}

.panel-title {
    font-size: 0.9rem;
    color: var(--phosphor-dim);
    letter-spacing: 0.2em;
}

/* ============================================
   Form Elements
   ============================================ */
input, textarea, select {
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--crt-dark);
    border: 1px solid var(--phosphor-dark);
    color: var(--phosphor-green);
    padding: var(--space-sm) var(--space-md);
    transition: var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--phosphor-dim);
    box-shadow: 0 0 10px var(--phosphor-subtle);
}

input::placeholder, textarea::placeholder {
    color: var(--phosphor-dark);
}

button, .btn {
    font-family: var(--font-mono);
    font-size: 1rem;
    background: transparent;
    border: 1px solid var(--phosphor-green);
    color: var(--phosphor-green);
    padding: var(--space-sm) var(--space-lg);
    cursor: pointer;
    transition: var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

button:hover, .btn:hover {
    background: var(--phosphor-subtle);
    box-shadow:
        0 0 10px var(--phosphor-glow),
        inset 0 0 10px var(--phosphor-subtle);
}

button:disabled, .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Status & Indicators
   ============================================ */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: var(--space-sm);
}

.status-online {
    background: var(--phosphor-green);
    box-shadow: 0 0 6px var(--phosphor-glow);
    animation: pulse-green 2s infinite;
}

.status-warning {
    background: var(--warning-amber);
    box-shadow: 0 0 6px rgba(255, 170, 0, 0.4);
    animation: pulse-amber 1.5s infinite;
}

.status-critical {
    background: var(--warning-red);
    box-shadow: 0 0 6px rgba(255, 0, 64, 0.4);
    animation: pulse-red 1s infinite;
}

.status-offline {
    background: var(--crt-border);
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes pulse-amber {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   Progress Bars (Repair Status)
   ============================================ */
.progress-bar {
    height: 20px;
    background: var(--crt-dark);
    border: 1px solid var(--phosphor-dark);
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--phosphor-dark),
        var(--phosphor-dim)
    );
    transition: width var(--transition-slow);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 4px,
        rgba(0, 0, 0, 0.2) 4px,
        rgba(0, 0, 0, 0.2) 8px
    );
}

.progress-label {
    position: absolute;
    right: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--phosphor-green);
}

/* ============================================
   Glitch Effects (Utility Classes)
   ============================================ */
.glitch-text {
    animation: glitch-text 4s infinite;
}

@keyframes glitch-text {
    0%, 90%, 100% {
        transform: none;
        text-shadow: none;
    }
    91% {
        transform: skewX(-2deg);
        text-shadow: -2px 0 var(--warning-red), 2px 0 var(--info-cyan);
    }
    92% {
        transform: skewX(2deg);
        text-shadow: 2px 0 var(--warning-red), -2px 0 var(--info-cyan);
    }
    93% {
        transform: skewX(-1deg);
        text-shadow: -1px 0 var(--warning-red), 1px 0 var(--info-cyan);
    }
}

.corrupt-char {
    color: var(--warning-red);
    animation: corrupt 2s infinite;
}

@keyframes corrupt {
    0%, 80%, 100% { opacity: 1; }
    85%, 95% { opacity: 0.3; }
}

/* Text corruption effect */
.corrupted::after {
    content: attr(data-corrupt);
    position: absolute;
    left: 0;
    color: var(--warning-red);
    opacity: 0;
    animation: corrupt-flash 5s infinite;
}

@keyframes corrupt-flash {
    0%, 95%, 100% { opacity: 0; }
    96% { opacity: 1; }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-dim { color: var(--phosphor-dim); }
.text-bright { color: var(--phosphor-bright); }
.text-warning { color: var(--warning-amber); }
.text-critical { color: var(--warning-red); }
.text-info { color: var(--info-cyan); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }

.glow {
    text-shadow: 0 0 10px var(--phosphor-glow);
}

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ============================================
   Responsive Breakpoints
   ============================================ */
@media (max-width: 768px) {
    :root {
        --space-md: 0.75rem;
        --space-lg: 1rem;
        --space-xl: 1.5rem;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    body {
        background: white;
        color: black;
    }

    .crt-screen::before,
    .crt-screen::after,
    .vignette {
        display: none;
    }
}
