/* 
 * CLI Terminal Styles
 * Baran Bingöl's personal website
 * Based on Factory Design System
 */

/* ===== RESET ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== BASE VARIABLES ===== */
:root {
    --font-mono: 'Berkeley Mono', 'SF Mono', Monaco, Consolas, 'Liberation Mono', Courier, monospace;
    --font-size: 14px;
    --line-height: 1.5;
    
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ===== THEME: DEFAULT (Synthwave - Kavinsky vibes) ===== */
.theme-default {
    --bg-primary: #0d0221;
    --bg-secondary: #12052e;
    --bg-tertiary: #1a0a3e;
    --bg-hover: #240f52;
    
    --text-primary: #ff006e;
    --text-secondary: #8338ec;
    --text-muted: #3a86ff;
    
    --accent: #ff006e;
    --accent-hover: #fb5607;
    
    --border: #3a0ca3;
    --border-strong: #4361ee;
    
    --success: #06ffa5;
    --error: #ff006e;
    --warning: #ffbe0b;
    --link: #00f5ff;
    
    --title-btn-close: #ff006e;
    --title-btn-min: #ffbe0b;
    --title-btn-max: #06ffa5;
}

/* ===== THEME: MATRIX (Classic green-on-black hacker) ===== */
.theme-matrix {
    --bg-primary: #0a0a0a;
    --bg-secondary: #0d0d0d;
    --bg-tertiary: #141414;
    --bg-hover: #1a1a1a;
    
    --text-primary: #00ff41;
    --text-secondary: #00cc33;
    --text-muted: #008f11;
    
    --accent: #00ff41;
    --accent-hover: #39ff14;
    
    --border: #003b00;
    --border-strong: #00570a;
    
    --success: #00ff41;
    --error: #ff3333;
    --warning: #ffff00;
    --link: #00ff41;
    
    --title-btn-close: #ff3333;
    --title-btn-min: #ffff00;
    --title-btn-max: #00ff41;
}

/* ===== THEME: NORD (Arctic, icy blues - calm and minimal) ===== */
.theme-nord {
    --bg-primary: #2e3440;
    --bg-secondary: #3b4252;
    --bg-tertiary: #434c5e;
    --bg-hover: #4c566a;
    
    --text-primary: #eceff4;
    --text-secondary: #e5e9f0;
    --text-muted: #d8dee9;
    
    --accent: #88c0d0;
    --accent-hover: #81a1c1;
    
    --border: #4c566a;
    --border-strong: #5e81ac;
    
    --success: #a3be8c;
    --error: #bf616a;
    --warning: #ebcb8b;
    --link: #88c0d0;
    
    --title-btn-close: #bf616a;
    --title-btn-min: #ebcb8b;
    --title-btn-max: #a3be8c;
}

/* ===== THEME: DRACULA (Purple-heavy, vampire aesthetic) ===== */
.theme-dracula {
    --bg-primary: #282a36;
    --bg-secondary: #21222c;
    --bg-tertiary: #343746;
    --bg-hover: #44475a;
    
    --text-primary: #f8f8f2;
    --text-secondary: #e9e9e4;
    --text-muted: #6272a4;
    
    --accent: #bd93f9;
    --accent-hover: #ff79c6;
    
    --border: #44475a;
    --border-strong: #6272a4;
    
    --success: #50fa7b;
    --error: #ff5555;
    --warning: #f1fa8c;
    --link: #8be9fd;
    
    --title-btn-close: #ff5555;
    --title-btn-min: #f1fa8c;
    --title-btn-max: #50fa7b;
}

/* ===== THEME: MONOKAI (Classic warm editor theme) ===== */
.theme-monokai {
    --bg-primary: #272822;
    --bg-secondary: #1e1f1c;
    --bg-tertiary: #3e3d32;
    --bg-hover: #49483e;
    
    --text-primary: #f8f8f2;
    --text-secondary: #cfcfc2;
    --text-muted: #75715e;
    
    --accent: #f92672;
    --accent-hover: #fd971f;
    
    --border: #49483e;
    --border-strong: #75715e;
    
    --success: #a6e22e;
    --error: #f92672;
    --warning: #e6db74;
    --link: #66d9ef;
    
    --title-btn-close: #f92672;
    --title-btn-min: #e6db74;
    --title-btn-max: #a6e22e;
}

/* ===== THEME: SOLARIZED (Warm, low contrast) ===== */
.theme-solarized {
    --bg-primary: #002b36;
    --bg-secondary: #073642;
    --bg-tertiary: #0a4050;
    --bg-hover: #094959;
    
    --text-primary: #839496;
    --text-secondary: #93a1a1;
    --text-muted: #586e75;
    
    --accent: #2aa198;
    --accent-hover: #cb4b16;
    
    --border: #073642;
    --border-strong: #586e75;
    
    --success: #859900;
    --error: #dc322f;
    --warning: #b58900;
    --link: #268bd2;
    
    --title-btn-close: #dc322f;
    --title-btn-min: #b58900;
    --title-btn-max: #859900;
}

/* ===== THEME: CYBERPUNK (Neon yellow + magenta on dark) ===== */
.theme-cyberpunk {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-hover: #252535;
    
    --text-primary: #fcee0a;
    --text-secondary: #ff2a6d;
    --text-muted: #05d9e8;
    
    --accent: #fcee0a;
    --accent-hover: #ff2a6d;
    
    --border: #2a2a3a;
    --border-strong: #ff2a6d;
    
    --success: #05d9e8;
    --error: #ff2a6d;
    --warning: #fcee0a;
    --link: #05d9e8;
    
    --title-btn-close: #ff2a6d;
    --title-btn-min: #fcee0a;
    --title-btn-max: #05d9e8;
}

/* ===== THEME: GRUVBOX (Retro, earthy tones) ===== */
.theme-gruvbox {
    --bg-primary: #1d2021;
    --bg-secondary: #282828;
    --bg-tertiary: #3c3836;
    --bg-hover: #504945;
    
    --text-primary: #ebdbb2;
    --text-secondary: #d5c4a1;
    --text-muted: #928374;
    
    --accent: #fe8019;
    --accent-hover: #fabd2f;
    
    --border: #3c3836;
    --border-strong: #665c54;
    
    --success: #b8bb26;
    --error: #fb4934;
    --warning: #fabd2f;
    --link: #83a598;
    
    --title-btn-close: #fb4934;
    --title-btn-min: #fabd2f;
    --title-btn-max: #b8bb26;
}

/* ===== BASE STYLES ===== */
html {
    height: 100%;
}

body {
    /* Use dvh for mobile browsers to account for address bar; fallback to vh */
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-mono);
    font-size: var(--font-size);
    line-height: var(--line-height);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Allow mobile browsers to detect scroll for address bar hide */
    overflow-x: hidden;
    overflow-y: auto;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ===== TERMINAL CONTAINER ===== */
.terminal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Use dvh for proper mobile viewport handling; fallback to vh */
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-lg);
    background: var(--bg-primary);
}

.terminal {
    width: 100%;
    max-width: 1000px;
    /* Use dvh for proper mobile viewport handling; fallback to vh */
    height: 80vh;
    height: 80dvh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    background: var(--bg-secondary);
    box-shadow: 
        0 0 0 1px var(--border),
        0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* ===== TITLE BAR ===== */
.terminal-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.title-buttons {
    display: flex;
    gap: 8px;
}

.title-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    cursor: default;
}

.title-btn.close { background: #ff5f56; }
.title-btn.minimize { background: #ffbd2e; }
.title-btn.maximize { background: #27c93f; }

.title-text {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 1;
    text-align: center;
}

.title-link {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

.title-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.title-actions {
    display: flex;
    gap: var(--space-sm);
}

.help-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.help-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* ===== TERMINAL BODY ===== */
.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    background: var(--bg-secondary);
}

.terminal-body::-webkit-scrollbar {
    width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.terminal-body::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== OUTPUT ===== */
#output {
    white-space: pre-wrap;
    word-wrap: break-word;
}

#output .prompt {
    color: var(--accent);
    font-weight: 600;
}

#output .cmd {
    color: var(--accent);
}

#output .accent {
    color: var(--accent);
}

#output .muted {
    color: var(--text-muted);
}

#output .error {
    color: var(--error);
}

#output .success {
    color: var(--success);
}

#output .warning {
    color: var(--warning);
}

#output .bold {
    font-weight: 600;
}

#output .white {
    color: var(--text-primary);
}

#output .bold.white {
    font-weight: 600;
    color: var(--text-primary);
}

#output a {
    color: var(--link);
}

#output a:hover {
    color: var(--accent-hover);
}

.ascii-art {
    font-size: 10px;
    line-height: 1.1;
    letter-spacing: -0.5px;
    white-space: pre;
    overflow-x: auto;
    display: block;
}

/* ===== INPUT LINE ===== */
.terminal-input {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
}

.input-prompt {
    color: var(--accent);
    font-weight: 600;
    margin-right: var(--space-sm);
    user-select: none;
}

#command-form {
    flex: 1;
    display: flex;
}

#command-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size);
    outline: none;
    caret-color: var(--accent);
}

#command-input::placeholder {
    color: var(--text-muted);
}

.cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ===== TERMINAL STATUS BAR ===== */
.terminal-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    user-select: none;
}

.status-left,
.status-center,
.status-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.status-center {
    color: var(--text-muted);
}

.status-hint {
    opacity: 0.7;
}

.status-sep {
    color: var(--border-strong);
}

.status-model {
    color: var(--accent);
}

/* ===== COMMAND SHORTCUTS ===== */
.command-shortcuts {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.cmd-shortcut {
    padding: var(--space-xs) var(--space-md);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cmd-shortcut:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.cmd-shortcut:active,
.cmd-shortcut.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* ===== MUSIC PLAYER ===== */
.music-player {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: 1100;
    display: none;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    min-width: 200px;
}

.music-player.visible {
    display: flex;
}

.music-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.music-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.music-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.music-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.music-btn svg {
    width: 14px;
    height: 14px;
}

.music-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.music-btn.playing {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.music-btn .icon {
    display: none;
}

.music-btn.playing .icon-pause {
    display: block;
}

.music-btn:not(.playing) .icon-play {
    display: block;
}
.music-volume {
    border-top: 1px solid var(--border);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
}
.music-volume input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    cursor: pointer;
}
.music-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    margin-top: -4px;
}
.music-volume input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.music-volume input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
}
.music-volume input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .terminal-wrapper {
        padding: var(--space-md);
    }
    
    .terminal {
        /* Use dvh for mobile address bar; fallback to vh */
        height: 85vh;
        height: 85dvh;
        max-height: none;
        border-radius: var(--radius-md);
    }
    
    .ascii-art {
        font-size: 8px;
        white-space: pre;
        overflow-x: auto;
    }
    
    .command-shortcuts {
        flex-wrap: wrap;
    }
    
    .terminal-status {
        font-size: 10px;
    }
    
    .status-center {
        display: none;
    }
    
    .music-player {
        right: var(--space-md);
        bottom: var(--space-md);
    }
}

@media (max-width: 480px) {
    :root {
        --font-size: 13px;
    }
    
    .terminal-wrapper {
        padding: var(--space-sm);
    }
    
    .terminal {
        /* Use dvh for mobile address bar; fallback to vh */
        height: 90vh;
        height: 90dvh;
        border-radius: var(--radius-sm);
    }
    
    .title-text {
        font-size: 11px;
    }
    
    .ascii-art {
        font-size: 5px;
        letter-spacing: -1px;
        white-space: pre;
        overflow-x: auto;
    }
    
    .cmd-shortcut {
        padding: var(--space-xs) var(--space-sm);
        font-size: 11px;
    }
    
    .terminal-status {
        font-size: 9px;
        padding: var(--space-xs) var(--space-sm);
    }
    
    .status-left {
        display: none;
    }
    
    #command-input {
        font-size: 16px; /* Prevents mobile browser zoom on focus */
    }
}

/* ===== POP-IN ANIMATION ===== */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.terminal-pop-in {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .cursor {
        animation: none;
        opacity: 1;
    }
    
    .terminal-pop-in {
        animation: none;
        opacity: 1;
        transform: scale(1);
    }
}

#command-input:focus {
    outline: none;
}

.cmd-shortcut:focus-visible,
.help-btn:focus-visible,
.music-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
