@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

/* ==========================================================================
   1. CSS Variables & Theme Setup
   ========================================================================== */
:root {
    /* Colors */
    --bg-color: #050505;
    --terminal-bg: #0a0a10;
    --terminal-bg-gradient-start: #0a0e27;
    --terminal-bg-gradient-mid: #1a1e37;
    
    /* Typography Colors */
    --text-primary: #00ff41;
    --text-secondary: #00d4ff;
    --text-alert: #ff0051; /* Unified red */
    --text-warning: #ffaa00; /* Unified orange */
    --text-purple: #ff00ff;
    --text-muted: #cccccc;

    /* Glow Effects */
    --glow-primary: 0 0 10px rgba(0, 255, 65, 0.5), 0 0 2px rgba(0, 255, 65, 0.3);
    --glow-secondary: 0 0 10px rgba(0, 212, 255, 0.5), 0 0 2px rgba(0, 212, 255, 0.3);
    --glow-alert: 0 0 10px rgba(255, 0, 81, 0.5);
    
    /* Fonts */
    --font-main: 'Share Tech Mono', 'Courier New', monospace;
    --font-retro: 'VT323', monospace;
}

/* ==========================================================================
   2. Reset & Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

a {
    color: var(--text-secondary);
    text-decoration: none;
    text-shadow: 0 0 5px var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--text-secondary);
    box-shadow: 0 0 5px var(--text-secondary);
    transition: width 0.3s ease;
}

a:hover, a:focus-visible {
    color: var(--text-primary);
    text-shadow: 0 0 10px var(--text-primary), 0 0 20px var(--text-primary);
    outline: none;
}

a:hover::after, a:focus-visible::after {
    width: 100%;
    background: var(--text-primary);
    box-shadow: 0 0 10px var(--text-primary);
}

/* ==========================================================================
   3. CRT Overlay & Screen Effects
   ========================================================================== */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    opacity: 0.15;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.4),
        rgba(0, 0, 0, 0.4) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: scrollScanlines 8s linear infinite;
}

.screen-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(0, 255, 65, 0.03) 0%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    z-index: 9997;
}

/* ==========================================================================
   4. Layout: Terminal Container
   ========================================================================== */
#terminal-container {
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    background: linear-gradient(135deg, var(--terminal-bg-gradient-start) 0%, var(--terminal-bg-gradient-mid) 50%, var(--terminal-bg-gradient-start) 100%);
    border: 2px solid var(--text-primary);
    border-radius: 10px;
    box-shadow: 
        0 0 30px rgba(0, 255, 65, 0.3), 
        inset 0 0 30px rgba(0, 255, 65, 0.1),
        0 0 0 4px rgba(0, 255, 65, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    z-index: 10;
    backdrop-filter: blur(10px);
    transform: perspective(1000px) rotateX(0.5deg);
    transition: transform 0.3s ease;
    animation: flicker 0.15s infinite;
}

/* Inner CRT glow overlay specifically for the container */
#terminal-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 255, 65, 0.03) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ==========================================================================
   5. Terminal Components
   ========================================================================== */

/* --- Header --- */
#terminal-header {
    background: linear-gradient(135deg, #161a33 0%, #1e2347 100%);
    padding: 12px 20px;
    border-bottom: 2px solid var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.4), 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 2;
    position: relative;
    letter-spacing: 1px;
}

#terminal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 65, 0.1), transparent);
    animation: shine 3s ease-in-out infinite;
}

.terminal-title {
    font-weight: bold;
    text-shadow: 0 0 10px var(--text-primary), 0 0 20px var(--text-primary);
    position: relative;
    z-index: 1;
}

.terminal-status {
    color: var(--text-primary);
    animation: pulse 2s infinite;
    position: relative;
    z-index: 1;
}

/* --- Output Area --- */
#terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 1rem;
    line-height: 1.6;
    z-index: 2;
    scrollbar-width: thin;
    scrollbar-color: var(--text-primary) var(--terminal-bg-gradient-start);
}

/* Custom Webkit Scrollbar */
#terminal-output::-webkit-scrollbar { width: 8px; }
#terminal-output::-webkit-scrollbar-track { background: var(--terminal-bg-gradient-start); }
#terminal-output::-webkit-scrollbar-thumb {
    background: var(--text-primary);
    border-radius: 4px;
}

/* --- Input Area --- */
#terminal-input-line {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background: #161a33;
    border-top: 1px solid var(--text-primary);
    z-index: 2;
}

.prompt {
    color: var(--text-primary);
    margin-right: 10px;
    text-shadow: 0 0 5px var(--text-primary);
    flex-shrink: 0;
    white-space: nowrap;
}

#terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    caret-color: var(--text-primary);
    text-shadow: var(--glow-primary);
}

/* ==========================================================================
   6. Output Utilities & Typography
   ========================================================================== */
.output-line {
    margin-bottom: 5px;
    word-wrap: break-word;
}

.command-line { color: var(--text-primary); margin-bottom: 10px; }
.command-line .prompt { margin-right: 5px; }

/* Status Colors */
.success { color: var(--text-primary); text-shadow: var(--glow-primary); }
.error { color: var(--text-alert); text-shadow: var(--glow-alert); }
.warning { color: var(--text-warning); text-shadow: 0 0 5px rgba(255, 170, 0, 0.5); }
.info { color: var(--text-secondary); text-shadow: var(--glow-secondary); }
.highlight { color: var(--text-purple); font-weight: bold; text-shadow: 0 0 5px var(--text-purple); }

.category-header {
    color: var(--text-purple);
    font-size: 1.1rem;
    font-weight: bold;
    margin: 20px 0 10px 0;
    text-shadow: 0 0 10px var(--text-purple), 0 0 20px var(--text-purple);
    border-bottom: 2px solid var(--text-purple);
    padding-bottom: 5px;
    animation: headerGlow 3s ease-in-out infinite;
}

.ascii-art {
    color: var(--text-primary);
    line-height: 1.2;
    text-shadow: 0 0 5px var(--text-primary);
    white-space: pre;
}

/* ==========================================================================
   7. Specific Modules (Files, Help, Projects)
   ========================================================================== */
   
/* File System */
.ls-output {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 10px 0;
}

.ls-dir {
    color: var(--text-secondary);
    font-weight: bold;
    text-shadow: 0 0 5px var(--text-secondary);
}

.ls-link {
    color: var(--text-primary);
    text-decoration: underline;
    cursor: pointer;
}

.ls-file { color: var(--text-muted); }

.file-content {
    white-space: pre-wrap;
    color: #e0e0e0;
    padding: 15px;
    border-left: 2px solid var(--text-primary);
    background: rgba(0, 255, 65, 0.05);
    margin: 10px 0;
    font-family: var(--font-retro);
}

/* Projects */
.project-item {
    margin: 10px 0;
    padding: 12px 15px;
    border-left: 3px solid var(--text-primary);
    background: linear-gradient(90deg, rgba(0, 255, 65, 0.08), rgba(0, 255, 65, 0.02));
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.project-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 65, 0.2), transparent);
    transition: left 0.5s ease;
}

.project-item:hover, .project-item:focus-visible {
    background: linear-gradient(90deg, rgba(0, 255, 65, 0.15), rgba(0, 212, 255, 0.08));
    border-left-color: var(--text-secondary);
    transform: translateX(8px);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    outline: none;
}

.project-item:hover::before, .project-item:focus-visible::before {
    left: 100%;
}

.project-title {
    color: var(--text-primary);
    font-weight: bold;
    text-shadow: 0 0 5px var(--text-primary);
    position: relative;
    z-index: 1;
}

.project-description {
    color: var(--text-secondary);
    margin: 5px 0;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.project-category {
    color: var(--text-warning);
    font-size: 0.75rem;
    position: relative;
    z-index: 1;
}

/* Help Commands */
.help-command { color: var(--text-primary); margin: 5px 0; }
.help-description { color: var(--text-secondary); margin-left: 20px; font-size: 0.85rem; }

/* ==========================================================================
   8. Boot Screen & Welcome Popup
   ========================================================================== */
#boot-screen {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    font-family: var(--font-retro);
}

#boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease-out;
}

.boot-content { text-align: center; width: 80%; max-width: 800px; }
.boot-logo { margin-bottom: 30px; }
.boot-ascii {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.1;
    text-shadow: var(--glow-primary);
    white-space: pre;
}

.boot-progress-container {
    width: 100%;
    max-width: 500px;
    margin: 20px auto;
    border: 1px solid var(--text-primary);
    padding: 2px;
    box-shadow: var(--glow-primary);
}

.boot-bar {
    height: 15px;
    width: 0%;
    background: var(--text-primary);
    box-shadow: var(--glow-primary);
    transition: width 0.2s ease-out;
}

.boot-text {
    color: var(--text-secondary);
    font-size: 1.15rem;
    letter-spacing: 2px;
    margin-top: 10px;
    text-shadow: var(--glow-secondary);
    min-height: 24px;
}

/* Welcome Popup */
.welcome-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.5s ease-out;
}

.welcome-popup.hidden { display: none; }

.welcome-content {
    background: linear-gradient(135deg, var(--terminal-bg-gradient-start) 0%, var(--terminal-bg-gradient-mid) 50%, var(--terminal-bg-gradient-start) 100%);
    border: 2px solid var(--text-primary);
    border-radius: 15px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 40px rgba(0, 255, 65, 0.4), inset 0 0 20px rgba(0, 255, 65, 0.1);
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

.welcome-header { margin-bottom: 25px; }
.welcome-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
}

.welcome-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    text-shadow: 0 0 15px rgba(0, 255, 65, 0.7);
    margin: 0;
    letter-spacing: 2px;
}

.welcome-body {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.8;
    margin-bottom: 30px;
}

.welcome-body .highlight-text {
    color: var(--text-secondary);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.welcome-body code {
    background: rgba(0, 255, 65, 0.15);
    color: var(--text-primary);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 65, 0.3);
}

.welcome-tip {
    color: var(--text-warning);
    font-size: 0.85rem;
    margin-top: 20px !important;
}

.welcome-close-btn {
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.2), rgba(0, 255, 65, 0.1));
    border: 2px solid var(--text-primary);
    color: var(--text-primary);
    padding: 15px 40px;
    font-family: var(--font-main);
    font-size: 1rem;
    letter-spacing: 3px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.5);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
}

.welcome-close-btn:hover, .welcome-close-btn:focus-visible {
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.4), rgba(0, 255, 65, 0.2));
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.5);
    transform: scale(1.05);
    outline: none;
}

.welcome-close-btn:active { transform: scale(0.98); }

/* ==========================================================================
   9. Animations
   ========================================================================== */
@keyframes scrollScanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

@keyframes flicker {
    0%, 10%, 20%, 100% { opacity: 0.98; }
    5% { opacity: 0.95; }
    15% { opacity: 0.97; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 5px var(--text-primary); }
    50% { opacity: 0.6; text-shadow: 0 0 15px var(--text-primary); }
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes headerGlow {
    0%, 100% { text-shadow: 0 0 10px var(--text-purple), 0 0 20px var(--text-purple); }
    50% { text-shadow: 0 0 15px var(--text-purple), 0 0 30px var(--text-purple), 0 0 40px var(--text-purple); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Simple Glitch */
@keyframes text-glitch {
    0%, 40%, 80%, 100% { text-shadow: 0 0 5px var(--text-primary); transform: translate(0); }
    20% { text-shadow: -2px 0 5px var(--text-alert), 2px 0 5px var(--text-secondary); transform: translate(-2px, 1px); }
    60% { text-shadow: 2px 0 5px var(--text-alert), -2px 0 5px var(--text-secondary); transform: translate(2px, -1px); }
}

.glitch { animation: text-glitch 0.5s infinite; display: inline-block; }

.easter-egg {
    color: var(--text-purple);
    font-weight: bold;
    animation: headerGlow 2s ease-in-out infinite;
}

/* Reduces intense motion for users with vestibular settings turned on */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   10. Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    #terminal-container {
        width: 100%;
        height: 100vh;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    .boot-ascii { font-size: 8px; }
    .boot-progress-container { width: 80%; max-width: 300px; }
    #terminal-output, #terminal-input { font-size: 0.85rem; }
    .project-item { padding: 10px; }
}

@media (max-width: 480px) {
    .boot-ascii { font-size: 6px; }
    #terminal-header { flex-direction: column; gap: 10px; }
    .welcome-content { padding: 20px; }
}
