/* ===========================
   Terminal Portfolio CSS
   Retro CRT Aesthetic
   =========================== */

/* CSS Variables for Themes */
:root {
    /* Matrix Theme (Default) */
    --bg-color: #0c0c0c;
    --text-color: #00ff41;
    --text-dim: #008f11;
    --accent-color: #00ff41;
    --shadow-color: rgba(0, 255, 65, 0.5);
    --glow-color: rgba(0, 255, 65, 0.3);

    /* Font */
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Timing */
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
}

/* Theme Variants */
[data-theme="amber"] {
    --bg-color: #1a0f00;
    --text-color: #ffb000;
    --text-dim: #cc8800;
    --accent-color: #ffb000;
    --shadow-color: rgba(255, 176, 0, 0.5);
    --glow-color: rgba(255, 176, 0, 0.3);
}

[data-theme="cyan"] {
    --bg-color: #001a1a;
    --text-color: #00ffff;
    --text-dim: #00aaaa;
    --accent-color: #00ffff;
    --shadow-color: rgba(0, 255, 255, 0.5);
    --glow-color: rgba(0, 255, 255, 0.3);
}

[data-theme="white"] {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --text-dim: #999999;
    --accent-color: #ffffff;
    --shadow-color: rgba(255, 255, 255, 0.5);
    --glow-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dracula"] {
    --bg-color: #282a36;
    --text-color: #f8f8f2;
    --text-dim: #6272a4;
    --accent-color: #ff79c6;
    --shadow-color: rgba(255, 121, 198, 0.5);
    --glow-color: rgba(255, 121, 198, 0.3);
}

[data-theme="nord"] {
    --bg-color: #2e3440;
    --text-color: #88c0d0;
    --text-dim: #4c566a;
    --accent-color: #88c0d0;
    --shadow-color: rgba(136, 192, 208, 0.5);
    --glow-color: rgba(136, 192, 208, 0.3);
}

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

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

body {
    font-family: var(--font-mono);
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* ===========================
   Boot Screen
   =========================== */
.boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.5s ease 3s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.boot-content {
    text-align: center;
    animation: scanline 0.1s linear infinite;
}

.boot-logo {
    font-size: 0.6rem;
    line-height: 1.2;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px var(--glow-color);
}

.boot-text p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.boot-status {
    color: var(--accent-color);
    font-weight: bold;
}

.boot-progress {
    width: 300px;
    height: 20px;
    border: 2px solid var(--text-color);
    margin: 1rem auto;
    position: relative;
    overflow: hidden;
}

.boot-progress-bar {
    width: 0;
    height: 100%;
    background: var(--accent-color);
    animation: loading 2.5s ease-in-out forwards;
}

@keyframes loading {
    to { width: 100%; }
}

/* ===========================
   Terminal Container
   =========================== */
.terminal-container {
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    max-height: 700px;
    background: var(--bg-color);
    border-radius: 8px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.8),
        0 0 40px var(--shadow-color),
        inset 0 0 80px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    opacity: 0;
    animation: terminalFadeIn 0.5s ease 3.5s forwards;
}

@keyframes terminalFadeIn {
    to { opacity: 1; }
}

/* CRT Screen Effect */
.terminal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* Subtle Flicker Effect */
.terminal-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    z-index: 11;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.27861; }
    5% { opacity: 0.34769; }
    10% { opacity: 0.23604; }
    15% { opacity: 0.90626; }
    20% { opacity: 0.18128; }
    25% { opacity: 0.83891; }
    30% { opacity: 0.65583; }
    35% { opacity: 0.67807; }
    40% { opacity: 0.26559; }
    45% { opacity: 0.84693; }
    50% { opacity: 0.96019; }
    55% { opacity: 0.08594; }
    60% { opacity: 0.20313; }
    65% { opacity: 0.71988; }
    70% { opacity: 0.53455; }
    75% { opacity: 0.37288; }
    80% { opacity: 0.71428; }
    85% { opacity: 0.70419; }
    90% { opacity: 0.7003; }
    95% { opacity: 0.36108; }
    100% { opacity: 0.24387; }
}

/* Reduce flicker intensity */
.terminal-container::after {
    opacity: 0.03;
}

/* ===========================
   Window Header
   =========================== */
.window-header {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--text-dim);
    position: relative;
    z-index: 5;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.control-btn.close { background: #ff5f56; }
.control-btn.minimize { background: #ffbd2e; }
.control-btn.maximize { background: #27c93f; }

.window-title {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.window-actions {
    display: flex;
    gap: 10px;
}

.theme-btn, .info-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.theme-btn:hover, .info-btn:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--glow-color);
}

/* ===========================
   Terminal Screen
   =========================== */
.terminal-screen {
    flex: 1;
    padding: 20px;
    padding-bottom: 60px; /* Reduced gap - Space for tips bar + input */
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar */
.terminal-screen::-webkit-scrollbar {
    width: 10px;
}

.terminal-screen::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.terminal-screen::-webkit-scrollbar-thumb {
    background: var(--text-dim);
    border-radius: 5px;
}

.terminal-screen::-webkit-scrollbar-thumb:hover {
    background: var(--text-color);
}

/* ===========================
   Terminal Output
   =========================== */
.terminal-output {
    flex: 1;
    margin-bottom: 20px; /* Reduced margin */
}

.output-line {
    margin: 4px 0;
    line-height: 1.5;
    animation: typeIn 0.05s ease-in-out;
}

@keyframes typeIn {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.output-line.command {
    color: var(--text-dim);
}

.output-line.game-line {
    white-space: pre !important;
    font-family: 'JetBrains Mono', 'Courier New', monospace !important;
    letter-spacing: 0 !important;
    line-height: 1.2 !important;
    word-break: keep-all !important;
    overflow-x: visible !important;
    margin: 0 !important;
}

.output-line.command .prompt {
    color: var(--accent-color);
    margin-right: 8px;
}

.output-line.result {
    color: var(--text-color);
}

.output-line.error {
    color: #ff4444;
}

.output-line.success {
    color: var(--accent-color);
}

.output-line.dim {
    color: var(--text-dim);
}

/* ASCII Art & Pre-formatted */
pre {
    font-family: var(--font-mono);
    margin: 10px 0;
    line-height: 1.2;
    white-space: pre;
}

/* Links in terminal */
a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-color);
    transition: all var(--transition-fast);
}

a:hover {
    text-shadow: 0 0 10px var(--glow-color);
    border-bottom-style: solid;
}

/* ===========================
   Input Line
   =========================== */
.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}

.prompt {
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 0 5px var(--glow-color);
    flex-shrink: 0;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 1rem;
    outline: none;
    caret-color: var(--accent-color);
}

.terminal-input::selection {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* ===========================
   Command Suggestions
   =========================== */
.suggestions {
    position: fixed; /* Changed to fixed to avoid affecting scroll */
    bottom: 160px; /* Fixed distance from viewport bottom */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    width: calc(100% - 80px); /* Responsive width */
    max-width: 400px;
    background: rgba(0, 0, 0, 0.95);
    border: none;
    border-radius: 4px;
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 5px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100; /* High z-index */
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.suggestions.active {
    display: flex;
}

.suggestion-item {
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: background var(--transition-fast);
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--text-dim);
    color: var(--bg-color);
}

/* ===========================
   Terminal Tips
   =========================== */
.terminal-tips {
    position: fixed; /* Changed from absolute to fixed */
    bottom: 50px;
    left: 0;
    right: 0;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border-top: 1px solid var(--text-dim);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: var(--text-dim);
    z-index: 20; /* Higher z-index */
    transition: all 0.3s ease;
}

.terminal-tips .tip-icon {
    font-size: 1.2em;
    animation: pulse 2s ease-in-out infinite;
}

.terminal-tips .tip-text {
    flex: 1;
    opacity: 0.8;
}

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

/* ===========================
   Quick Commands
   =========================== */
.quick-commands {
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid var(--text-dim);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.quick-cmd {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-cmd:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 10px var(--glow-color);
    transform: translateY(-2px);
}

.quick-cmd:active {
    transform: translateY(0);
}

/* ===========================
   Modals
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 40px var(--shadow-color);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h3 {
    color: var(--accent-color);
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--glow-color);
}

.modal-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.modal-content ul {
    margin: 10px 0 10px 20px;
    line-height: 1.8;
}

.modal-content code {
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent-color);
}

.modal-close {
    margin-top: 20px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-family: var(--font-mono);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}

.modal-close:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--glow-color);
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.theme-option {
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--text-dim);
    color: var(--text-color);
    font-family: var(--font-mono);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-option:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--glow-color);
    transform: translateY(-2px);
}

/* ===========================
   Matrix Rain Canvas
   =========================== */
.matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    display: none;
}

.matrix-canvas.active {
    display: block;
}

/* ===========================
   Special Output Styles
   =========================== */
.ascii-box {
    border: 1px solid var(--text-dim);
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.info-box {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--accent-color);
    padding: 10px 15px;
    margin: 10px 0;
}

.blog-item,
.event-item {
    margin: 15px 0;
    padding: 10px;
    border-left: 2px solid var(--text-dim);
    transition: border-color var(--transition-fast);
}

.blog-item:hover,
.event-item:hover {
    border-left-color: var(--accent-color);
}

.blog-item h4,
.event-item h4 {
    color: var(--accent-color);
    margin-bottom: 5px;
}

.blog-item .meta,
.event-item .meta {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin: 5px 0;
}

/* Loading Spinner */
.loading {
    display: inline-block;
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .terminal-container {
        max-width: 100%;
        height: 95vh;
        border-radius: 0;
    }

    .terminal-screen {
        padding: 15px;
    }

    .window-header {
        padding: 8px 12px;
    }

    .window-title {
        font-size: 0.75rem;
    }

    .boot-logo {
        font-size: 0.4rem;
    }

    .quick-commands {
        padding: 10px;
        gap: 5px;
    }

    .quick-cmd {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .theme-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .terminal-input-line {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }

    .prompt {
        display: block;
    }

    .modal-content {
        padding: 20px;
    }
}

/* ===========================
   Utility Classes
   =========================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.bold { font-weight: bold; }
.dim { color: var(--text-dim); }
.accent { color: var(--accent-color); }
.glow { text-shadow: 0 0 10px var(--glow-color); }
