/* --- BASE & TYPOGRAPHY --- */
html {
    scroll-behavior: smooth;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body {
    margin: 0;
    padding: 0;
    background-color: #09090b;
    color: #d4d4d8;
    overflow-x: hidden;
    height: 100vh;
}

/* --- THEME VARIABLES --- */
:root {
    --theme-hex: rgba(34, 211, 238, 0.4);
    --theme-hex-solid: rgb(34, 211, 238);
}

/* --- CRT EFFECT (Linux Mode Default) --- */
.crt::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0), rgba(255, 255, 255, 0.01));
    z-index: 100;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* --- ANIMATIONS --- */
.blink {
    animation: blinker 1s step-start infinite;
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glitch-item {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.7s ease-out;
}

.glitch-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- DYNAMIC GLOWS --- */
.text-glow-theme {
    text-shadow: 0 0 10px var(--theme-hex);
}

/* --- TERMINAL PANELS (Base for Linux) --- */
.terminal-panel {
    background: rgba(15, 15, 18, 0.8);
    border: 1px solid rgba(39, 39, 42, 0.8);
    border-radius: 0.5rem;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.terminal-panel:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
    /* Will be overridden by JS for theme color */
    transform: translateY(-2px);
}


/* ==========================================================================
   OS SPECIFIC WRAPPERS & WINDOW MANAGER
   ========================================================================== */

/* The main hidden layout */
.desktop-environment {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    position: relative;
}

/* Base Window (The draggable container) */
.app-window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Centered initially */
    width: clamp(320px, 80vw, 1200px);
    max-width: none;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    resize: both;
    /* Allow resizing */
    min-width: 320px;
    min-height: 400px;
    transition: transform 0.1s ease;
}

/* If dragging happened, JS adds inline left/top, so we remove transform to stop jumping */
.app-window[style*="left"] {
    transform: none;
}

/* The actual scrollable content Area inside the window */
.app-content {
    flex-grow: 1;
    overflow-y: auto;
    height: 100%;
    width: 100%;
    position: relative;
}


/* --- LINUX MODE --- */
.os-linux .app-window {
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    height: 100vh;
    max-width: none;
    resize: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
}

.os-linux .app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}


/* --- MACOS MODE --- */
.os-mac {
    background-image: url('https://images.unsplash.com/photo-1620641788421-7a1c342ea42e?q=80&w=2574&auto=format&fit=crop');
    /* Abstract Ventura */
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.os-mac .crt::before {
    display: none;
}

.os-mac .app-window {
    border-radius: 12px;
    background-color: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.os-mac .app-content {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 0;
    height: 100%;
}

.os-mac .app-content::-webkit-scrollbar {
    width: 8px;
}

.os-mac .app-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.os-mac .mac-titlebar {
    display: flex;
    height: 38px;
    background: rgba(45, 45, 45, 0.9);
    border-bottom: 1px solid #111;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.os-mac .mac-menu-bar {
    display: flex;
    height: 28px;
    background: rgba(30, 30, 30, 0.7);
    backdrop-filter: blur(20px);
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    justify-content: space-between;
}

.os-mac .mac-dock {
    display: flex;
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(40, 40, 40, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px;
    gap: 8px;
    z-index: 9999;
}

.os-mac .dock-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, margin 0.2s;
    cursor: pointer;
}

.os-mac .dock-icon:hover {
    transform: scale(1.3) translateY(-10px);
    margin: 0 10px;
}

.os-mac #main-nav {
    position: sticky !important;
    top: 0;
    margin-top: 0 !important;
    border-radius: 0;
}

.os-mac #status-bar {
    display: none;
}


/* --- WINDOWS 11 MODE --- */
.os-windows {
    background-image: url('https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=2564&auto=format&fit=crop');
    /* Bloom-like abstract */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

.os-windows .crt::before {
    display: none;
}

.os-windows .app-window {
    border-radius: 8px;
    background-color: rgba(32, 32, 32, 0.7);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

.os-windows .app-content {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 0;
    height: 100%;
}

.os-windows .app-content::-webkit-scrollbar {
    width: 14px;
}

.os-windows .app-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    background-clip: padding-box;
    border: 4px solid transparent;
    border-radius: 10px;
}

.os-windows .app-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.os-windows .win-titlebar {
    display: flex;
    height: 32px;
    align-items: center;
    justify-content: space-between;
    padding-left: 12px;
    flex-shrink: 0;
}

.win-controls {
    display: flex;
    height: 100%;
}

.win-control-btn {
    width: 46px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    transition: background 0.1s;
    cursor: pointer;
}

.win-control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.win-control-btn.close:hover {
    background: #e81123;
    color: white;
}

.os-windows .win-taskbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(28, 28, 28, 0.85);
    backdrop-filter: blur(30px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.os-windows .taskbar-icon {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    cursor: pointer;
    position: relative;
}

.os-windows .taskbar-icon:hover {
    background: rgba(255, 255, 255, 0.08);
}

.os-windows.light-mode .taskbar-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.os-windows .taskbar-icon.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    border-radius: 2px;
    background: #0078D4;
}

/* Enhancements for Desktop Text */
#win-typewriter-container {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.os-windows.light-mode #win-typewriter-container {
    text-shadow: none;
}

#win-weather-widget {
    background: rgba(20, 20, 20, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.os-windows.light-mode #win-weather-widget {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #111;
}

.os-windows #main-nav {
    position: sticky !important;
    top: 0;
    margin-top: 0 !important;
    border-radius: 0;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.os-windows #status-bar {
    display: none;
}

/* --- ANDROID MODE --- */
.os-android {
    background-image: url('https://images.unsplash.com/photo-1550684848-fac1c5b4e853?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: Roboto, sans-serif;
}

.os-android .crt::before {
    display: none;
}

.os-android .app-window {
    border-radius: 24px;
    background-color: #121212;
    border: 8px solid #000;
    box-shadow: 0 0 0 2px #333, 0 20px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    width: 380px !important;
    height: 800px !important;
    min-width: 320px;
    max-height: 90vh;
    overflow: hidden;
}

.os-android .app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.os-android .app-content::-webkit-scrollbar {
    width: 4px;
}

.os-android .app-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.android-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: #000;
    color: #fff;
    cursor: grab;
}

.android-status-bar:active {
    cursor: grabbing;
}

.android-nav-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 48px;
    background: #000;
    border-top: 1px solid #222;
}

.android-nav-bar .nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.android-nav-bar .nav-btn:active {
    background-color: rgba(255, 255, 255, 0.1);
}

.os-android #main-nav {
    position: sticky !important;
    top: 0;
    margin-top: 0 !important;
    border-radius: 0;
    background: #1e1e1e;
}

.os-android #status-bar {
    display: none;
}