/* ===== VARIABLES ===== */
:root {
    --bg-page: #0d1117;
    --bg-section: #161b22;
    --text-color: #c9d1d9;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --border: #30363d;

    /* Vim theme */
    --bg-vim: #1e1e1e;
    --keyword: #569cd6;
    --string: #ce9178;
    --comment: #6a9955;
    --variable: #9cdcfe;
    --type: #4ec9b0;
    --line-num: #858585;
    --vim-status: #007acc;
}

/* ===== GLOBAL RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-page);
    color: var(--text-color);
    font-family: 'Consolas', 'Courier New', 'Liberation Mono', monospace;
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #8dbcff;
}

/* ===== TOP-RIGHT CONTROLS ===== */
.top-controls {
    position: fixed;
    top: 2.5rem;
    right: 2.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.ctrl-btn {
    background: var(--bg-section);
    color: var(--text-color);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.ctrl-btn:hover {
    background: var(--border);
    border-color: var(--accent);
}

.ctrl-btn svg {
    display: block;
}

/* ===== HERO ===== */
#hero {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 6rem;
    padding-right: 2rem;
    padding-left: 2rem;
    padding-bottom: 1rem;
}

.hero-inner h1 {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f0f6fc;
}

.tagline {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.hero-links {
    margin-top: 1.5rem;
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-links a {
    color: var(--accent);
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s;
}

.hero-links a:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent);
}

/* ===== SECTIONS ===== */
.section {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 2rem;
}

.section h2 {
    font-size: 1.5rem;
    color: #f0f6fc;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.section h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.section p {
    color: var(--text-muted);
}

#about p {
    text-align: justify;
}

.section ul {
    list-style: none;
    padding: 0;
}

.section li {
    padding: 0.2rem 0;
    color: var(--text-muted);
}

.section li::before {
    content: "• ";
    color: var(--accent);
}

/* ===== SKILL GRID ===== */
.skill-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 540px) {
    .skill-grid { grid-template-columns: 1fr; }
}

/* ===== PROJECTS ===== */
.projects-filter {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.projects-filter-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.projects-filter-row + .projects-filter-row {
    margin-top: 0.35rem;
}

.projects-filter-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 3.5rem;
}

.tag-options,
.active-tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.projects-filter-row-active {
    width: 100%;
    padding-top: 0.65rem;
    padding-bottom: 0.55rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.tag-chip,
.active-tag {
    background: var(--bg-section);
    color: var(--text-color);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.3;
}

.tag-chip {
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.tag-chip:hover,
.tag-chip:focus-visible {
    border-color: var(--accent);
}

.tag-chip.is-active {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-section));
}

.active-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.active-tag-remove {
    border: none;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.active-tag-remove:hover,
.active-tag-remove:focus-visible {
    color: var(--accent);
}

.active-tags-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.clear-tags-btn {
    border: 1px solid var(--border);
    background: var(--bg-section);
    color: var(--text-color);
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.clear-tags-btn:hover,
.clear-tags-btn:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-section));
}

.clear-tags-btn[disabled] {
    opacity: 0.45;
    cursor: default;
}

.project-filter-count {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.project {
    margin-bottom: 2rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-section);
}

.project.is-hidden {
    display: none;
}

.project-tech {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.project-date {
    display: block;
    font-size: 0.78rem;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

/* ===== FULLSCREEN VIM OVERLAY ===== */
.vim-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-vim);
}

.vim-overlay.active {
    display: flex;
}

.vim-frame {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-vim);
    position: relative;
}

/* Vim tab bar */
.vim-tabline {
    display: flex;
    align-items: center;
    background: #252526;
    border-bottom: 1px solid #1a1a1a;
    user-select: none;
    flex-shrink: 0;
}

.vim-tab {
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--line-num);
    background: transparent;
    border-right: 1px solid #1a1a1a;
    cursor: default;
}

.vim-tab.active {
    color: var(--text-color);
    background: var(--bg-vim);
}

.vim-tabline-fill {
    flex: 1;
}

.vim-close-btn {
    background: none;
    border: none;
    color: var(--line-num);
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    line-height: 0;
}

.vim-close-btn:hover {
    color: #ff5f57;
}

/* Vim body fills remaining space */
.vim-frame .vim-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 0; /* force flex child to shrink */
    min-height: 0;
}

/* ===== VIM BODY ===== */
.vim-body {
    display: flex;
    flex-direction: column;
    height: 480px;
}

.workspace {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    min-height: 0;
}

.buffer {
    display: none;
    line-height: 1.6;
}

.buffer.active {
    display: block;
    counter-reset: line;
}

/* Line numbers via CSS counter */
.line {
    display: flex;
    counter-increment: line;
}

.line::before {
    content: counter(line);
    color: var(--line-num);
    min-width: 30px;
    text-align: right;
    margin-right: 15px;
    user-select: none;
    flex-shrink: 0;
}

.code {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Syntax tokens */
.kw  { color: var(--keyword); font-weight: bold; }
.str { color: var(--string); }
.com { color: var(--comment); font-style: italic; }
.var { color: var(--variable); }
.typ { color: var(--type); }

/* Vim status bar */
.vim-status {
    background: var(--vim-status);
    color: white;
    padding: 4px 15px;
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Command line + autocomplete wrapper */
.vim-cmd-wrapper {
    position: relative;
}

.vim-cmd-container {
    background: var(--bg-vim);
    padding: 4px 10px;
    display: flex;
    align-items: center;
}

#cmd-input {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1em;
    width: 100%;
    outline: none;
}

/* ===== AUTOCOMPLETE BOX ===== */
.autocomplete-box {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 10px;
    background: #252526;
    border: 1px solid var(--border);
    border-radius: 4px;
    max-width: 280px;
    font-size: 0.9em;
    z-index: 20;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
}

.autocomplete-box .ac-item {
    padding: 4px 12px;
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
}

.autocomplete-box .ac-item.active {
    background: var(--vim-status);
    color: white;
}

/* ===== HELP OVERLAY ===== */
#help-overlay {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2d2d30;
    border: 1px solid var(--vim-status);
    padding: 20px 28px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10;
    max-width: 90%;
    font-size: 1rem;
}

#help-overlay h3 {
    margin-bottom: 0.8rem;
    color: var(--keyword);
}

#help-overlay ul {
    list-style: none;
    padding: 0;
}

#help-overlay li {
    margin-bottom: 6px;
}

#help-overlay li::before {
    content: none;
}

#help-overlay code {
    color: var(--variable);
    font-weight: bold;
}

.help-hint {
    color: var(--comment);
    font-size: 0.85em;
    font-style: italic;
    margin-top: 1rem;
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .hero-inner h1 { font-size: 2rem; }
    .section { padding: 2rem 1.2rem; }

    .projects-filter {
        gap: 0.35rem;
    }

    .projects-filter-row {
        gap: 0.4rem;
    }

    .projects-filter-row + .projects-filter-row {
        margin-top: 0.25rem;
    }

    .projects-filter-label {
        min-width: 0;
    }
}

/* ===== LIGHT MODE ===== */
body.light {
    --bg-page: #ffffff;
    --bg-section: #f6f8fa;
    --text-color: #1f2328;
    --text-muted: #656d76;
    --accent: #0969da;
    --border: #d0d7de;

    /* Vim theme — light */
    --bg-vim: #ffffff;
    --keyword: #0550ae;
    --string: #0a3069;
    --comment: #6e7781;
    --variable: #953800;
    --type: #116329;
    --line-num: #8c959f;
    --vim-status: #0969da;
}

body.light .hero-inner h1,
body.light .section h2 {
    color: #1f2328;
}

body.light .hero-links a:hover {
    background: rgba(9, 105, 218, 0.08);
}

/* Vim chrome overrides for light mode */
body.light .vim-tabline {
    background: #f6f8fa;
    border-bottom-color: #d0d7de;
}

body.light .vim-tab {
    border-right-color: #d0d7de;
}

body.light .vim-tab.active {
    background: #ffffff;
}

body.light .vim-cmd-container {
    background: var(--bg-vim);
}

body.light .autocomplete-box {
    background: #f6f8fa;
    border-color: #d0d7de;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

body.light #help-overlay {
    background: #f6f8fa;
    border-color: var(--vim-status);
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
