:root {
    --bg-color: #000000;
    --border-color: #444444;
    --text-color: #cccccc;
    --accent-color: #ffffff;
    --hover-color: #aaaaaa;
}

body.theme-cyan {
    --accent-color: #00ffff;
    --text-color: #00ffff;
    --border-color: #005555;
}

body.theme-green {
    --accent-color: #00ff00;
    --text-color: #aaddaa;
    --border-color: #005500;
}

body.theme-amber {
    --accent-color: #ffaa00;
    --text-color: #ddccaa;
    --border-color: #553300;
}

body.theme-magenta {
    --accent-color: #ff00ff;
    --text-color: #ddaadd;
    --border-color: #550055;
}

body,
html {
    margin: 0;
    padding: 0;
    font-family: "Courier New", Courier, monospace;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
}

/* Background Canvas */
#glcanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
}

/* CRT Scanline Overlay */
#crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 5000;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.crt-active #crt-overlay {
    opacity: 1;
}

/* Top and Bottom taskbars */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease-out;
}

body[data-booting="true"] .top-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
}

.top-bar-title {
    font-weight: bold;
    color: var(--accent-color);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-bar-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.top-bar-controls button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    padding: 2px 5px;
}

.top-bar-controls button:hover {
    color: var(--hover-color);
    border-color: var(--hover-color);
}

.top-bar-controls button.min-btn,
.top-bar-controls button.max-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    padding: 0;
    /* Override default button padding */
}

.top-bar-controls button.min-btn:hover,
.top-bar-controls button.max-btn:hover {
    background: var(--hover-color);
    color: var(--bg-color);
}

.theme-btn {
    width: 12px;
    height: 12px;
    padding: 0 !important;
    border-radius: 50%;
    opacity: 0.7;
}

.theme-btn:hover {
    opacity: 1;
    border-color: white;
}

.theme-btn.active {
    opacity: 1;
    box-shadow: 0 0 5px var(--accent-color);
}

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 10px;
    z-index: 1000;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease-out;
}

body[data-booting="true"] .bottom-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}



.taskbar-items {
    display: flex;
    gap: 10px;
    margin-left: 20px;
}

.taskbar-item {
    padding: 5px 15px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.taskbar-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Desktop container */
.desktop {
    position: absolute;
    top: 30px;
    /* Below top bar */
    bottom: 40px;
    /* Above bottom bar */
    left: 0;
    right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Allowed vertical scroll, block horizontal */
    transition: opacity 0.3s ease;
}

/* Creates the vertical scrolling canvas space */
.desktop::after {
    content: "";
    display: block;
    width: 100%;
    height: 1500px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
}

/* Fullscreen UI Hiding */
body.fullscreen .top-bar {
    transform: translateY(-30px);
    /* Move entirely off screen */
    transition: transform 0.3s ease;
}

/* Invisible hit area so you don't have to touch the exact pixel */
body.fullscreen .top-bar::after {
    content: '';
    position: absolute;
    top: 100%;
    /* Hangs below the hidden bar */
    left: 0;
    width: 100%;
    height: 15px;
    /* 15px hover trigger zone */
    background: transparent;
}

body.fullscreen .top-bar:hover {
    transform: translateY(0);
}

body.fullscreen .bottom-bar {
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

body.fullscreen .desktop {
    opacity: 0;
    pointer-events: none;
}

#fs-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 15px 30px;
    font-weight: bold;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

body.fullscreen.show-toast #fs-toast {
    opacity: 1;
}



/* The Box Module (Windows) */
.box {
    position: absolute;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 10;
    resize: both;
    overflow: hidden;
    /* transition rules for the bloom effect */
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.6s ease-out;
}

/* Boot Sequence Hiding */
body[data-booting="true"] .box:not(#win-terminal) {
    opacity: 0;
    pointer-events: none;
    transform: translateY(40px) scale(0.9);
}

.box.is-dragging {
    transition: none;
    opacity: 0.9;
}

.box-header {
    padding: 8px 15px;
    border-bottom: 1px dashed var(--border-color);
    color: var(--accent-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.box-header:active {
    cursor: grabbing;
}

.window-controls button {
    background: none;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    padding: 0 5px;
}

.window-controls button:hover {
    color: var(--hover-color);
}

.close-win-btn {
    background: var(--bg-color) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--accent-color) !important;
    font-weight: bold;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.close-win-btn:hover {
    background: var(--accent-color) !important;
    color: var(--bg-color) !important;
}

.box-content {
    padding: 15px;
    overflow: auto;
    flex-grow: 1;
    /* Fills remaining space in resized window */
}

.box-content.no-padding {
    padding: 0;
    /* Used for the iframe so it touches the edges */
    overflow: hidden;
}




/* Iframe Styling */
iframe {
    width: 100%;
    height: 100%;
    min-height: 160px;
    /* Base height for the widget */
    border: none;
    display: block;
    pointer-events: auto;
    /* Required for interaction */
}

.box.is-dragging iframe {
    pointer-events: none;
}

/* Prevent iframe from stealing mouse events during drag */

/* Hyperlink Header Styling */
.header-link {
    display: inline-block;
    color: var(--accent-color);
    text-decoration: none;
    position: relative;
    cursor: pointer;
}

/* The invisible underline */
.header-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: var(--accent-color);
    transition: width 0.3s ease-out;
    /* The smooth slide-in effect */
}

/* On hover, expand the line to full width */
.header-link:hover::after {
    width: 100%;
}

/* =========================================
   Blog Widget (Fixed Layout)
   ========================================= */
.blog-index-menu {
    position: fixed;
    top: 30px;
    /* Below top bar */
    bottom: 40px;
    /* Above bottom bar */
    left: 0;
    width: 33%;
    background: rgba(0, 0, 0, 0.95);
    border-right: 1px solid var(--accent-color);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    color: var(--text-color);
    overflow: hidden;
}

.blog-index-menu.open {
    transform: translateX(0);
}

.blog-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--accent-color);
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 2px;
    color: var(--accent-color);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.blog-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.blog-list li {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transform: translateX(-50px);
    transition: transform 0.4s ease, opacity 0.4s ease, background-color 0.2s, color 0.2s;
}

.blog-index-menu.open .blog-list li {
    opacity: 0.8;
    transform: translateX(0);
}

.blog-list li:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.blog-list li.active {
    background: var(--accent-color);
    color: var(--bg-color);
    opacity: 1;
    font-weight: bold;
}

/* Blog Reader Fixed Pane */
#win-blog-reader {
    position: fixed !important;
    /* Override standard .box relative behavior if any */
    top: 30px !important;
    right: 0 !important;
    left: auto !important;
    bottom: 40px;
    width: 67% !important;
    height: calc(100vh - 70px) !important;
    margin: 0;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--accent-color);
    z-index: 99;
    /* Just below index menu */
    display: flex;
    flex-direction: column;
}

.blog-content {
    overflow-y: auto;
    padding: 30px;
    font-family: inherit;
    line-height: 1.6;
}

#blog-metadata {
    margin-bottom: 20px;
    font-size: 12px;
}

.meta-row {
    display: flex;
    margin-bottom: 5px;
}

.meta-row span:first-child {
    width: 120px;
    color: var(--accent-color);
}

#blog-article-body h2 {
    color: var(--accent-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
}

#blog-article-body h3 {
    color: var(--accent-color);
    margin-top: 25px;
    margin-bottom: 10px;
}

#blog-article-body p {
    margin-bottom: 15px;
    opacity: 0.9;
}

#blog-article-body code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border: 1px solid var(--border-color);
}



/* =========================================
   Terminal Widget (consolidated from inline)
   ========================================= */
.terminal-content {
    padding: 10px;
    font-size: 12px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
    background: var(--bg-color);
    color: var(--accent-color);
    display: flex;
    flex-direction: column;
}

.terminal-history {
    white-space: pre-wrap;
    margin-bottom: 5px;
}

.terminal-input-row {
    display: flex;
}

.terminal-prompt {
    color: var(--accent-color);
    margin-right: 5px;
    white-space: nowrap;
}

.terminal-input-field {
    background: transparent;
    border: none;
    color: var(--accent-color);
    outline: none;
    font-family: inherit;
    font-size: 12px;
    flex-grow: 1;
    caret-color: var(--accent-color);
}

/* =========================================
   Custom Scrollbar (Retro theme)
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-left: 1px solid var(--border-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

::-webkit-scrollbar-corner {
    background: var(--bg-color);
}

/* Firefox scrollbar — scoped to scrollable containers */
body,
.desktop,
.box-content,
.blog-list,
.blog-content,
.terminal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-color);
}

/* =========================================
   Scroll Hint
   ========================================= */
.scroll-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent-color);
    font-size: 11px;
    opacity: 0.4;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: scrollPulse 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scrollPulse {

    0%,
    100% {
        opacity: 0.2;
        transform: translateX(-50%) translateY(0);
    }

    50% {
        opacity: 0.6;
        transform: translateX(-50%) translateY(5px);
    }
}

/* =========================================
   Utility Classes (extracted from inline styles)
   ========================================= */
.top-bar-left {
    display: flex;
    align-items: baseline;
}

.top-btn-blog {
    cursor: pointer;
    margin-left: 20px;
    font-size: 14px;
    opacity: 0.8;
}

.thought-stream-text {
    font-size: 11px;
    font-family: monospace;
    white-space: pre-wrap;
    overflow-y: auto;
}

.close-btn-inline {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-weight: bold;
    cursor: pointer;
    padding: 0;
}

.blog-separator {
    border-color: var(--border-color);
    opacity: 0.3;
    margin-bottom: 20px;
}

/* =========================================
   Mobile Responsiveness
   ========================================= */
@media (max-width: 768px) {

    /* Stack the blog layout on mobile */
    .blog-index-menu {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--accent-color);
        bottom: auto;
        height: 50vh;
        z-index: 101;
    }

    #win-blog-reader {
        width: 100% !important;
        height: 100vh !important;
        top: 0 !important;
        border-left: none;
        z-index: 102;
    }

    /* Make default window boxes fill mobile screens */
    .box {
        width: 95% !important;
        left: 2.5% !important;
        position: relative !important;
        top: auto !important;
        margin-bottom: 10px;
    }

    /* Stack windows vertically on mobile */
    .desktop {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 10px 0;
    }

    /* Disable drag cursors on mobile */
    .box-header {
        cursor: default;
    }

    .box-header:active {
        cursor: default;
    }

    /* Make top bar scrollable on small screens */
    .top-bar {
        padding: 0 10px;
        overflow-x: auto;
    }

    .top-bar-right {
        gap: 8px;
    }

    .top-bar-controls {
        gap: 4px;
    }

    /* Hide scroll hint on mobile (already stacked) */
    .scroll-hint {
        display: none;
    }
}