/* Cool Retro Terminal CSS */
@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    background: #000;
    overflow: hidden;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    font-family: 'Ubuntu Mono', monospace;
    height: 100vh;
    width: 100vw;
}

/* Retro terminal text selection */
::selection {
    background: #00ff00;
    color: #000;
    text-shadow: 
        0 0 3px #00ff00,
        0 0 6px #00ff00,
        0 0 9px #00ff00;
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.8),
        0 0 40px rgba(0, 255, 0, 0.6),
        0 0 60px rgba(0, 255, 0, 0.4),
        inset 0 0 15px rgba(0, 255, 0, 0.3);
    animation: selection-flicker 0.1s infinite alternate;
    outline: 2px solid rgba(0, 255, 0, 0.5);
    outline-offset: 2px;
}

::-moz-selection {
    background: #00ff00;
    color: #000;
    text-shadow: 
        0 0 3px #00ff00,
        0 0 6px #00ff00,
        0 0 9px #00ff00;
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.8),
        0 0 40px rgba(0, 255, 0, 0.6),
        0 0 60px rgba(0, 255, 0, 0.4),
        inset 0 0 15px rgba(0, 255, 0, 0.3);
    outline: 2px solid rgba(0, 255, 0, 0.5);
    outline-offset: 2px;
}

@keyframes selection-flicker {
    0% { 
        background: #00ff00;
        box-shadow: 
            0 0 20px rgba(0, 255, 0, 0.8),
            0 0 40px rgba(0, 255, 0, 0.6),
            0 0 60px rgba(0, 255, 0, 0.4),
            inset 0 0 15px rgba(0, 255, 0, 0.3);
    }
    100% { 
        background: #00dd00;
        box-shadow: 
            0 0 30px rgba(0, 255, 0, 1.0),
            0 0 50px rgba(0, 255, 0, 0.8),
            0 0 80px rgba(0, 255, 0, 0.6),
            inset 0 0 20px rgba(0, 255, 0, 0.4);
    }
}

.crt-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #001100 0%, #000800 70%, #000400 100%);
    overflow: hidden;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
}

.terminal {
    width: 100%;
    height: 100%;
    background: rgba(0, 17, 0, 0.9);
    padding: 20px;
    position: relative;
    
    /* CRT curve effect */
    transform: perspective(1000px) rotateX(1deg);
    
    /* Phosphor glow */
    filter: 
        contrast(1.1) 
        brightness(1.2) 
        saturate(1.3);
}

.terminal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, transparent 50%, rgba(0, 255, 0, 0.03) 50%),
        linear-gradient(transparent 50%, rgba(0, 255, 0, 0.03) 50%);
    background-size: 2px 2px;
    pointer-events: none;
}

.terminal-content {
    color: #00ff00;
    font-size: 32px;
    line-height: 1.4;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-shadow: 
        0 0 2px #00ff00,
        0 0 4px #00ff00;
    
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #00ff00 transparent;
}

.terminal-content::-webkit-scrollbar {
    width: 8px;
}

.terminal-content::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-content::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
    box-shadow: 0 0 2px #00ff00;
}

.prompt-line {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

.terminal-input {
    background: transparent;
    border: none;
    outline: none;
    color: #00ff00; /* Bright green for active command input */
    font-family: 'Ubuntu Mono', monospace;
    font-size: 32px;
    text-shadow: 
        0 0 2px #00ff00,
        0 0 4px #00ff00;
    caret-color: #00ff00;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    resize: none;
    line-height: 1.4;
    padding: 0;
    margin: 0;
    vertical-align: top;
    width: 100%;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Retro blinking cursor */
.retro-cursor {
    background: #00ff00;
    color: #000;
    animation: cursor-blink 1s infinite;
    padding: 0 2px;
    box-shadow: 0 0 2px #00ff00;
    margin-left: 1px;
}

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

.terminal-input::selection {
    background: #00ff00;
    color: #000;
    text-shadow: 
        0 0 3px #00ff00,
        0 0 6px #00ff00,
        0 0 9px #00ff00;
}

.error-output {
    color: #ff6666;
    text-shadow: 
        0 0 1px #ff6666,
        0 0 2px #ff6666;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.command-output {
    color: #00aa00; /* Darker green for output */
    text-shadow: 
        0 0 1px #00aa00,
        0 0 2px #00aa00;
    white-space: pre-wrap; /* Allow wrapping while preserving whitespace */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.auth-info {
    color: #66aaff; /* Light blue for auth-related messages */
    text-shadow: 
        0 0 1px #66aaff,
        0 0 2px #66aaff;
    opacity: 0.8;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.prompt {
    color: #00ff00;
    margin-right: 5px;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Scanlines effect */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        transparent 50%, 
        rgba(0, 255, 0, 0.04) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    animation: scanlines 0.1s linear infinite;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* CRT scan line effect */
.flicker {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(0, 255, 0, 0.15),
        transparent
    );
    pointer-events: none;
    animation: scanline 4s linear infinite;
    box-shadow: 
        0 0 45px rgba(0, 255, 0, 0.9),
        0 0 100px rgba(0, 255, 0, 0.6),
        0 0 150px rgba(0, 255, 0, 0.3);
    opacity: 0.6;
}

@keyframes scanline {
    0% { 
        top: -20px; 
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% { 
        top: calc(100% + 20px); 
        opacity: 0;
    }
}

/* Static noise effect */
.noise {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 3px 3px;
    animation: noise 0.2s infinite;
    pointer-events: none;
    opacity: 0.05;
}

@keyframes noise {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-1px, -1px); }
    20% { transform: translate(1px, -2px); }
    30% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, 2px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(2px, -1px); }
    70% { transform: translate(-2px, -2px); }
    80% { transform: translate(1px, -1px); }
    90% { transform: translate(-1px, 1px); }
    100% { transform: translate(0, 0); }
}

/* CRT glow effect */
.crt-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 255, 0, 0.05) 0%,
        rgba(0, 255, 0, 0.02) 30%,
        transparent 70%
    );
    pointer-events: none;
}

/* Screen curvature */
.crt-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at top, transparent 60%, rgba(0,0,0,0.1) 100%),
        radial-gradient(ellipse at bottom, transparent 60%, rgba(0,0,0,0.1) 100%);
    pointer-events: none;
    border-radius: 3% / 10%;
}

/* Realistic CRT glitch effects */

/* Phosphor persistence ghosting */
.ghost-char {
    position: relative;
}

.ghost-char::after {
    content: attr(data-char);
    position: absolute;
    left: 1px;
    top: 0;
    color: rgba(0, 255, 0, 0.3);
    opacity: 0.7;
    filter: blur(0.5px);
    animation: phosphor-fade 3s ease-out forwards;
}

@keyframes phosphor-fade {
    0% { opacity: 0.7; }
    100% { opacity: 0; }
}

/* Electron beam deflection */
.beam-deflect {
    position: relative;
    animation: beam-wobble 0.1s ease-in-out;
}

@keyframes beam-wobble {
    0% { transform: translateX(0); }
    25% { transform: translateX(1px); }
    75% { transform: translateX(-0.6px); }
    100% { transform: translateX(0); }
}

/* CRT brightness fluctuation */
.brightness-flicker {
    animation: brightness-pulse 0.05s ease-in-out;
}

@keyframes brightness-pulse {
    0% { 
        filter: brightness(1) contrast(1);
        text-shadow: 0 0 2px #00ff00, 0 0 4px #00ff00;
    }
    50% { 
        filter: brightness(0.75) contrast(1.2);
        text-shadow: 0 0 1px #00ff00, 0 0 2px #00ff00;
    }
    100% { 
        filter: brightness(1) contrast(1);
        text-shadow: 0 0 2px #00ff00, 0 0 4px #00ff00;
    }
}

/* Horizontal sync issues */
.hsync-glitch {
    position: relative;
    overflow: hidden;
}

.hsync-glitch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, 
            transparent 0%, 
            rgba(0, 255, 0, 0.1) 2%,
            transparent 4%,
            transparent 96%,
            rgba(0, 255, 0, 0.1) 98%,
            transparent 100%);
    animation: hsync-shift 0.1s linear;
}

@keyframes hsync-shift {
    0% { transform: translateX(0); }
    100% { transform: translateX(5px); }
}

/* Vertical sync roll */
.vsync-roll {
    animation: vertical-roll 0.8s ease-in-out;
}

@keyframes vertical-roll {
    0% { transform: translateY(0); }
    25% { transform: translateY(-2px); }
    50% { transform: translateY(2px); }
    75% { transform: translateY(-1px); }
    100% { transform: translateY(0); }
}

/* Enhanced vertical glitch variations */
.vsync-roll.intense {
    animation: vertical-roll-intense 0.6s ease-in-out;
}

@keyframes vertical-roll-intense {
    0% { transform: translateY(0); }
    15% { transform: translateY(-4px); }
    30% { transform: translateY(3px); }
    45% { transform: translateY(-2px); }
    60% { transform: translateY(4px); }
    75% { transform: translateY(-1px); }
    90% { transform: translateY(1px); }
    100% { transform: translateY(0); }
}

/* Quick vertical jitter */
.vsync-jitter {
    animation: vertical-jitter 0.3s ease-in-out;
}

@keyframes vertical-jitter {
    0% { transform: translateY(0); }
    10% { transform: translateY(-1px); }
    20% { transform: translateY(2px); }
    30% { transform: translateY(-2px); }
    40% { transform: translateY(1px); }
    50% { transform: translateY(-1px); }
    60% { transform: translateY(2px); }
    70% { transform: translateY(-1px); }
    80% { transform: translateY(1px); }
    90% { transform: translateY(-1px); }
    100% { transform: translateY(0); }
}

/* Character aliasing/anti-aliasing issues */
.alias-glitch {
    position: relative;
    filter: contrast(1.2);
}

.alias-glitch::before {
    content: attr(data-char);
    position: absolute;
    left: 0.5px;
    top: 0;
    color: rgba(0, 200, 0, 0.4);
    filter: blur(0.6px);
}

/* Weak signal fade */
.signal-weak {
    animation: signal-fade 1.5s ease-in-out;
}

@keyframes signal-fade {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* CRT focus issues */
.focus-drift {
    animation: focus-change 0.3s ease-in-out;
}

@keyframes focus-change {
    0% { 
        filter: blur(0px);
        text-shadow: 0 0 2px #00ff00, 0 0 4px #00ff00;
    }
    50% { 
        filter: blur(0.4px);
        text-shadow: 0 0 3px #00ff00, 0 0 6px #00ff00;
    }
    100% { 
        filter: blur(0px);
        text-shadow: 0 0 2px #00ff00, 0 0 4px #00ff00;
    }
}

/* Command vs Output styling */
.command-input {
    color: #00ff00; /* Bright green for command input */
    text-shadow: 
        0 0 2px #00ff00,
        0 0 4px #00ff00;
}

.command-prompt {
    color: #00ff00; /* Bright green for prompt */
    text-shadow: 
        0 0 2px #00ff00,
        0 0 4px #00ff00;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.executed-command {
    color: #00ff00; /* Bright green to match active input */
    text-shadow: 
        0 0 2px #00ff00,
        0 0 4px #00ff00;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Responsive design */
@media (max-width: 768px) {
    .terminal {
        padding: 15px;
    }
    
    .terminal-content {
        font-size: 18px;
        line-height: 1.3;
    }
    
    .terminal-input {
        font-size: 18px;
        line-height: 1.3;
    }
    
    .command-prompt, 
    .executed-command,
    .command-output {
        font-size: 18px;
        line-height: 1.3;
    }
    
    /* Match tab colors with background on mobile */
    * {
        -webkit-tap-highlight-color: rgba(0, 17, 0, 0.9);
        -webkit-touch-callout: none;
    }
    
    body {
        background: #000800;
    }
}

@media (max-width: 480px) {
    .terminal {
        padding: 8px;
    }
    
    .terminal-content {
        font-size: 16px;
        line-height: 1.2;
    }
    
    .terminal-input {
        font-size: 16px;
        line-height: 1.2;
    }
    
    .command-prompt, 
    .executed-command,
    .command-output {
        font-size: 16px;
        line-height: 1.2;
    }
    
    /* Enhanced mobile tab color matching */
    * {
        -webkit-tap-highlight-color: rgba(0, 17, 0, 0.9);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    body {
        background: #000800;
        -webkit-tap-highlight-color: transparent;
    }
    
    .crt-container {
        background: radial-gradient(ellipse at center, #001100 0%, #000800 70%, #000400 100%);
        -webkit-tap-highlight-color: transparent;
    }
}

@media (max-width: 320px) {
    .terminal {
        padding: 5px;
    }
    
    .terminal-content {
        font-size: 14px;
        line-height: 1.1;
    }
    
    .terminal-input {
        font-size: 14px;
        line-height: 1.1;
    }
    
    .command-prompt, 
    .executed-command,
    .command-output {
        font-size: 14px;
        line-height: 1.1;
    }
    
    /* Maximum mobile optimization */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    body {
        background: #000400;
    }
    
    .crt-container {
        background: #000400;
    }
}
