:root {
    --bg-color: #000000;
    --bg-color-light: #0a0a0a;
    --text-color: #ffffff;
    --accent-color: #00ee00; 
    --text-dim: #888888;
    --crt-scanline: rgba(0, 238, 0, 0.2);
    --font-size-base: 16px;
    --font-size-multiplier: 1.25;
    --font-family: 'VT323', monospace;
}

/* --- GLOBAL --- */
* { box-sizing: border-box; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

body, html {
    margin: 0; padding: 0; height: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: calc(var(--font-size-base) * var(--font-size-multiplier));
    line-height: 1.4;
    overflow: hidden;
}

/* --- CRT SIMULATION --- */
#crt-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(var(--crt-scanline) 50%, transparent 50%);
    background-size: 100% 4px;
    pointer-events: none; z-index: 9999;
}
#crt-flicker {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 9998;
    background: rgba(0, 238, 0, 0.03);
    animation: flicker 0.15s infinite;
}
@keyframes flicker { 0% { opacity: 0.1; } 50% { opacity: 0; } 100% { opacity: 0.1; } }

/* --- MAIN TUI STRUCTURE --- */
#tui-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    border: 2px solid var(--accent-color); 
    margin: 4px;
    padding: 2px;
}

/* UI Visibility - NO TRANSITIONS */
.interface-element { opacity: 0; }
.interface-active { opacity: 1; } 

/* Top Menu Bar */
#menu-bar {
    background: var(--accent-color); color: var(--bg-color);
    padding: 2px 1rem; text-transform: uppercase; font-weight: bold;
    display: flex; gap: 2rem; flex-shrink: 0;
    font-size: var(--font-size-base);
}
.menu-item { cursor: pointer; }
.menu-item:hover { text-decoration: underline; }

/* --- THEME PANEL (Centered Modal) --- */
.theme-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--bg-color);
    border: 2px solid var(--accent-color);
    z-index: 2000;
    padding: 0;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 8px 8px 0 rgba(0, 0, 0, 0.5);
}
.theme-panel.hidden { display: none; }

.theme-panel-header {
    background: var(--accent-color);
    color: var(--bg-color);
    padding: 8px 12px;
    font-weight: bold;
    font-size: var(--font-size-base);
    text-align: center;
    position: relative;
}
.theme-panel-close {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: calc(var(--font-size-base) + 2px);
    line-height: 1;
}
.theme-panel-close:hover {
    opacity: 0.7;
}

.theme-section {
    padding: 12px 16px;
    border-bottom: 1px dashed var(--accent-color);
}
.theme-section:last-child { border-bottom: none; }

.theme-section-title {
    font-size: calc(var(--font-size-base) - 2px);
    color: var(--accent-color);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.theme-presets {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.theme-preset-btn {
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 10px;
    font-family: 'Fira Code', monospace;
    font-size: calc(var(--font-size-base) - 2px);
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
}
.theme-preset-btn:hover, .theme-preset-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

.theme-color-row, .theme-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: calc(var(--font-size-base) - 1px);
    color: var(--text-dim);
}
.theme-color-row:last-child, .theme-toggle-row:last-child { margin-bottom: 0; }

.theme-color-row input[type="color"] {
    width: 50px;
    height: 24px;
    border: 1px solid var(--accent-color);
    background: var(--bg-color);
    cursor: pointer;
    padding: 0;
}
.theme-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.theme-color-row input[type="color"]::-webkit-color-swatch { border: none; }

.toggle-btn {
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    color: var(--text-dim);
    padding: 4px 12px;
    font-family: 'Fira Code', monospace;
    font-size: calc(var(--font-size-base) - 2px);
    cursor: pointer;
    min-width: 50px;
}
.toggle-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

.theme-font-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.font-btn {
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    color: var(--text-dim);
    padding: 6px 8px;
    font-size: calc(var(--font-size-base) - 3px);
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.font-btn:hover {
    background: var(--bg-color-light);
}
.font-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

.theme-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: calc(var(--font-size-base) - 2px);
    color: var(--text-dim);
}
.theme-slider-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--accent-color);
    border-radius: 2px;
    cursor: pointer;
}
.theme-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border: 2px solid var(--bg-color);
    border-radius: 0;
    cursor: pointer;
}

/* Main Stage */
#main-stage {
    flex-grow: 1; display: flex;
    border-top: 2px solid var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
    overflow: hidden;
    position: relative;
}

/* LEFT PANE (Navigation) */
#nav-pane {
    width: 280px; background: var(--bg-color);
    border-right: 2px solid var(--accent-color);
    display: flex; flex-direction: column; flex-shrink: 0;
    /* NO TRANSITION on width anymore */
}
#nav-pane.booting { width: 0; border-right: none; }

/* Files section (60% of nav pane) */
.nav-files-section {
    flex: 6;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    background: var(--text-color); color: var(--bg-color);
    padding: 2px 8px; text-align: center; font-weight: bold; text-transform: uppercase;
    flex-shrink: 0;
    font-size: var(--font-size-base);
}
.nav-list { list-style: none; padding: 1rem; margin: 0; overflow-y: auto; flex: 1; font-size: var(--font-size-base); }
.nav-item {
    padding: 4px 8px; cursor: pointer; display: flex; justify-content: space-between;
    margin-bottom: 2px; color: var(--text-dim);
}
.nav-item:hover, .nav-item.active { background: var(--accent-color); color: var(--bg-color); }
.nav-item-disabled {
    cursor: default; opacity: 0.4;
}
.nav-item-disabled:hover { background: transparent; color: var(--text-dim); }
.dir-label { color: var(--accent-color); }
.nav-item:hover .dir-label, .nav-item.active .dir-label { color: var(--bg-color); }
.nav-item-disabled:hover .dir-label { color: var(--accent-color); }

/* --- TABLE OF CONTENTS (40% of nav pane) --- */
.toc-section {
    flex: 4;
    min-height: 0;
    border-top: 1px dashed var(--accent-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.toc-section.hidden { display: none; }
.toc-header {
    font-size: var(--font-size-base);
}
.toc-list {
    list-style: none;
    padding: 0.5rem;
    margin: 0;
    overflow-y: auto;
    font-size: calc(var(--font-size-base) - 2px);
    flex: 1;
}
.toc-item {
    padding: 2px 6px;
    cursor: pointer;
    color: var(--text-dim);
    display: flex;
    align-items: flex-start;
    line-height: 1.4;
}
.toc-item:hover { color: var(--accent-color); }
.toc-item:hover .toc-prefix { color: var(--accent-color); }
.toc-prefix {
    flex-shrink: 0;
    color: var(--accent-color);
    white-space: pre;
    font-size: calc(var(--font-size-base) - 2px);
}
.toc-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Hierarchy levels */
.toc-item.toc-level-1 { font-weight: bold; color: var(--text-color); }
.toc-item.toc-level-3 { font-size: calc(var(--font-size-base) - 3px); }
.toc-item.toc-level-4 { font-size: calc(var(--font-size-base) - 4px); opacity: 0.8; }

/* --- PANEL VISIBILITY STATES --- */
/* Classes applied to #tui-container */

/* Nav hidden - TOC expands to full height */
.nav-hidden .nav-files-section { display: none; }
.nav-hidden .toc-section { 
    flex: 1; 
    border-top: none;
}
.nav-hidden #nav-pane { width: 280px; } /* Keep pane visible for TOC */

/* TOC hidden */
.toc-hidden .toc-section { display: none !important; }
.toc-hidden .nav-files-section { flex: 1; }

/* Both hidden - hide entire nav pane */
.nav-hidden.toc-hidden #nav-pane { display: none; }

/* --- FOCUS MODE --- */
/* Focus mode: hide nav files, keep TOC, hide status bar extras */
.focus-mode .nav-files-section { display: none; }
.focus-mode .toc-section { 
    flex: 1; 
    border-top: none;
}
.focus-mode #system-stats,
.focus-mode #status-text,
.focus-mode #clock { display: none !important; }
.focus-mode #breadcrumb { flex: 1; }
.focus-mode #blog-content article {
    max-width: 75ch; /* Standard readable line length */
    margin: 0 auto;
    padding: 0 2rem;
}

/* Focus mode + TOC hidden: hide nav pane entirely, center content */
.focus-mode.toc-hidden #nav-pane { display: none; }
.focus-mode.toc-hidden #blog-content article {
    max-width: 75ch;
    margin: 0 auto;
}

/* RIGHT PANE (Content & Boot Stage) */
#content-pane {
    flex-grow: 1; overflow-y: auto; padding: 2rem;
    background-color: var(--bg-color-light);
    display: flex; flex-direction: column;
}
#content-pane.boot-mode {
    justify-content: center;
    align-items: center;
}

/* --- BOOT & LOGO STYLES --- */
#boot-terminal {
    text-align: left;
    width: fit-content;
    max-width: 95%;
}
.boot-line { margin-bottom: 4px; white-space: pre; font-family: 'Fira Code', monospace; }
.boot-highlight { color: var(--accent-color); font-weight: bold; }
.blinking-cursor {
    display: inline-block; width: 8px; height: 14px; background: var(--accent-color);
    animation: blink 0.5s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* THE ANSI BLOCK LOGO STYLES */
.logo-line {
    font-family: 'Fira Code', monospace;
    white-space: pre;
    color: var(--accent-color);
    font-size: 10px; 
    line-height: 1;
    font-weight: bold;
    margin: 0; padding: 0; letter-spacing: 0;
}

/* --- BLOG POST STYLES --- */
#blog-content { display: none; } /* No Animation */

h1.post-title { font-size: 1.8rem; text-transform: uppercase; margin: 0 0 1rem 0; color: var(--accent-color); }
h2 { font-size: 1.4rem; color: var(--accent-color); margin: 2rem 0 1rem 0; border-bottom: 1px dashed var(--accent-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.2rem; color: var(--text-color); margin: 1.5rem 0 0.75rem 0; }
h4 { font-size: 1rem; color: var(--text-dim); margin: 1rem 0 0.5rem 0; text-transform: uppercase; }

.ascii-box { border: 1px solid var(--accent-color); padding: 1rem; margin-bottom: 2rem; position: relative; }
.ascii-box::before { content: "[ METADATA ]"; position: absolute; top: -0.7em; left: 1rem; background: var(--bg-color-light); padding: 0 8px; color: var(--accent-color); font-weight: bold; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; color: var(--text-dim); }
.meta-label { text-transform: uppercase; color: var(--accent-color); }

article p { margin-bottom: 1.5rem; text-align: justify; line-height: 1.6; }
article a { color: var(--accent-color); text-decoration: none; border-bottom: 1px dashed var(--accent-color); }
article a:hover { background: var(--accent-color); color: var(--bg-color); }
article strong { color: var(--accent-color); font-weight: bold; }
article em { color: var(--text-color); font-style: italic; }

.ascii-separator { text-align: center; color: var(--accent-color); margin: 3rem 0; font-weight: bold; letter-spacing: 2px; }

/* --- CODE BLOCKS --- */
.code-block {
    background: var(--bg-color-light);
    border: 1px solid var(--accent-color);
    border-left: 3px solid var(--accent-color);
    padding: 1rem;
    padding-top: 1.5rem; /* Extra space for the title */
    margin: 1.5rem 0;
    margin-top: 2rem; /* Extra margin to ensure title is visible */
    overflow: visible; /* Allow title to show above */
    position: relative;
    max-width: 100%;
}
.code-block::before {
    content: "[ CODE ]";
    position: absolute;
    top: -0.7em;
    left: 1rem;
    background: var(--bg-color-light);
    padding: 0 8px;
    color: var(--accent-color);
    font-weight: bold;
    font-size: 0.75rem;
    z-index: 1; /* Ensure it's above other elements */
}
.code-block[data-lang]::before {
    content: "[ " attr(data-lang) " ]";
    text-transform: uppercase;
}
.code-block code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-color);
    background: none;
    padding: 0;
    white-space: pre;
    display: block;
    overflow-x: auto; /* Horizontal scroll on the code itself */
}

/* --- INLINE CODE --- */
.inline-code {
    background: var(--bg-color-light);
    border: 1px solid var(--text-dim);
    padding: 2px 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
    border-radius: 2px;
}

/* --- BLOCKQUOTES --- */
blockquote {
    border-left: 3px solid var(--accent-color);
    background: var(--bg-color-light);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    color: var(--text-dim);
    font-style: italic;
}

/* --- LISTS --- */
.styled-list {
    margin: 1rem 0 1.5rem 0;
    padding-left: 1.5rem;
}
.styled-list li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    position: relative;
}
ol.styled-list {
    list-style: none;
    counter-reset: item;
}
ol.styled-list li {
    counter-increment: item;
}
ol.styled-list li::before {
    content: counter(item) ".";
    color: var(--accent-color);
    font-weight: bold;
    position: absolute;
    left: -1.5rem;
}
ul.styled-list {
    list-style: none;
}
ul.styled-list li::before {
    content: "─";
    color: var(--accent-color);
    position: absolute;
    left: -1.2rem;
}

/* --- IMAGES --- */
.image-container {
    margin: 2rem 0;
    border: 1px solid var(--accent-color);
    background: var(--bg-color-light);
    padding: 1rem;
    max-width: 100%;
}
.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: grayscale(20%) contrast(1.1);
}
.image-container figcaption {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    font-style: italic;
}
.image-container figcaption:empty {
    display: none;
}

/* --- MATH (KaTeX) --- */
.math-block {
    background: var(--bg-color-light);
    padding: 1rem;
    margin: 0.5rem 0;
    text-align: center;
    overflow-x: auto;
}
.math-inline {
    background: var(--bg-color-light);
    padding: 1px 4px;
    border-radius: 2px;
}

/* KaTeX overrides for retro terminal look */
.math-block .katex,
.math-inline .katex {
    color: var(--accent-color);
    font-family: 'VT323', monospace !important;
}
.math-block .katex {
    font-size: 1.4em;
}
.math-inline .katex {
    font-size: 1.2em;
}
/* Override KaTeX font families */
.katex .mathnormal,
.katex .mathit,
.katex .mathrm,
.katex .mathbf,
.katex .mathsf,
.katex .mathtt,
.katex .mathbb,
.katex .mathcal,
.katex .mathfrak,
.katex .mathscr {
    font-family: 'VT323', monospace !important;
}
/* Make math slightly pixelated/crisp */
.math-block .katex,
.math-inline .katex {
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    text-rendering: optimizeSpeed;
}
/* Error state */
.math-error {
    color: #ff6b6b;
    font-family: var(--font-family);
    font-style: italic;
}

#status-bar {
    background: var(--accent-color);
    color: var(--bg-color);
    padding: 2px 1rem;
    display: flex;
    gap: 1rem;
    font-weight: bold;
    flex-shrink: 0;
    font-size: var(--font-size-base);
}
#breadcrumb {
    flex-shrink: 0;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#system-stats {
    flex-shrink: 0;
    font-size: calc(var(--font-size-base) - 2px);
    opacity: 0.8;
}
#status-text {
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#clock { flex-shrink: 0; }

/* --- LOGO WATERMARK --- */


@media (max-width: 800px) {
    #main-stage { flex-direction: column; }
    #nav-pane { 
        width: 100%; 
        max-height: 250px;
        border-right: none; 
        border-bottom: 2px solid var(--accent-color); 
    }
    #nav-pane.booting { max-height: 0; border-bottom: none; }
    #menu-bar { gap: 0.5rem; font-size: calc(var(--font-size-base) - 2px); padding: 2px 0.5rem; }
    .logo-line { font-size: 5px; }
    
    /* Mobile: Nav hidden - show TOC only if enabled */
    .nav-hidden #nav-pane { display: none; }
    .nav-hidden:not(.toc-hidden) #nav-pane { 
        display: flex; 
        width: 100%;
        max-height: 200px;
    }
    .nav-hidden.toc-hidden #nav-pane { display: none; }
    
    /* Mobile: Focus mode - keep full width content */
    .focus-mode #nav-pane { 
        width: 100%;
        max-height: 180px; 
    }
    .focus-mode .nav-files-section { display: none; }
    .focus-mode #blog-content article {
        max-width: 100%; /* Full width on mobile */
        padding: 0;
    }
    .focus-mode.toc-hidden #nav-pane { display: none; }
    .focus-mode #system-stats,
    .focus-mode #status-text,
    .focus-mode #clock { display: none !important; }
    
    #system-stats { display: none; } /* Always hide system stats on mobile */
    #breadcrumb { max-width: 150px; font-size: calc(var(--font-size-base) - 2px); }
    #status-bar { font-size: calc(var(--font-size-base) - 2px); }
}
