/* JubairOS v2.6 — Theme Engine & CRT System */

:root {
  --bg: #0a0d0a;
  --surface: #111811;
  --surface-2: #162116;
  --border: #1f331f;
  --primary: #00ff66;
  --primary-dim: #00aa44;
  --secondary: #00f0ff;
  --accent: #ffb000;
  --muted: #738a73;
  --text: #c8e6c9;
}

/* Theme Overrides — body class drives all colors */
body.theme-green {
  --bg: #0a0d0a;
  --surface: #111811;
  --surface-2: #162116;
  --border: #1f331f;
  --primary: #00ff66;
  --primary-dim: #00aa44;
  --secondary: #00f0ff;
  --accent: #ffb000;
  --muted: #738a73;
}
body.theme-amber {
  --bg: #0f0e0a;
  --surface: #1a160f;
  --surface-2: #231e12;
  --border: #3d2f12;
  --primary: #ffb000;
  --primary-dim: #cc8800;
  --secondary: #ff8c1a;
  --accent: #00ff66;
  --muted: #9a8b6a;
}
body.theme-cyan {
  --bg: #070d12;
  --surface: #0e1a22;
  --surface-2: #132330;
  --border: #1a3a4a;
  --primary: #00f0ff;
  --primary-dim: #0099aa;
  --secondary: #00ffaa;
  --accent: #ffb000;
  --muted: #6a8a9a;
}
body.theme-obsidian {
  --bg: #050505;
  --surface: #0f0f0f;
  --surface-2: #1a1a1a;
  --border: #2a2a2a;
  --primary: #e8e8e8;
  --primary-dim: #aaaaaa;
  --secondary: #888888;
  --accent: #00ff66;
  --muted: #666666;
}

/* Tailwind override — force utilities to use variables */
.bg-retro-bg { background-color: var(--bg) !important; }
.bg-retro-surface { background-color: var(--surface) !important; }
.border-retro-border { border-color: var(--border) !important; }
.text-retro-green { color: var(--primary) !important; }
.text-retro-dimGreen { color: var(--primary-dim) !important; }
.text-retro-cyan { color: var(--secondary) !important; }
.text-retro-amber { color: var(--accent) !important; }
.text-retro-muted { color: var(--muted) !important; }
.bg-retro-green { background-color: var(--primary) !important; }
.bg-retro-cyan { background-color: var(--secondary) !important; }
.border-retro-green { border-color: var(--primary) !important; }
.hover\:border-retro-green:hover { border-color: var(--primary) !important; }
.hover\:bg-retro-green:hover { background-color: var(--primary) !important; }

/* Global */
body {
  background-color: var(--bg);
  color: var(--primary);
  transition: background-color 0.4s ease, color 0.3s ease;
}

/* Desktop Wallpaper with background.webp */
#desktop {
  background-color: var(--bg);
  background-image: url('background.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: overlay;
}
#desktop.wallpaper-none { background-image: none; }
#desktop.wallpaper-cover { background-image: url('background.webp'); background-size: cover; background-blend-mode: overlay; }
#desktop.wallpaper-contain { background-image: url('background.webp'); background-size: contain; background-repeat: repeat; }
#desktop.wallpaper-grid {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px),
    url('background.webp');
  background-size: 28px 28px, 28px 28px, cover;
  background-blend-mode: normal, normal, overlay;
}

/* CRT & Scanline Effects */
.scanline {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.22) 50%);
  background-size: 100% 3px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.55;
}
@keyframes flicker {
  0% { opacity: 0.97; } 50% { opacity: 1; } 100% { opacity: 0.98; }
}
.crt-flicker {
  position: fixed;
  inset: 0;
  background: rgba(0,255,102,0.015);
  z-index: 9998;
  pointer-events: none;
  animation: flicker 0.16s infinite;
}
.crt-curve {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.9) 100%);
  z-index: 9997;
  pointer-events: none;
}
.crt-curve::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3% / 2%;
  box-shadow: inset 0 0 120px rgba(0,0,0,0.9), inset 0 0 40px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* Toast */
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-item { animation: slideIn 0.3s ease forwards; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Windows */
.os-window {
  box-shadow: 0 14px 36px rgba(0,0,0,0.85), 0 0 0 1px var(--border), 0 0 24px color-mix(in srgb, var(--primary) 10%, transparent);
  transition: box-shadow 0.2s ease;
  backdrop-filter: blur(8px);
}
.os-window.active { box-shadow: 0 18px 40px rgba(0,0,0,0.9), 0 0 0 1px var(--primary), 0 0 28px color-mix(in srgb, var(--primary) 18%, transparent); }
.os-window.dragging { opacity: 0.96; user-select: none; }

/* Window header grab */
.window-header:active { cursor: grabbing; }

/* Taskbar running indicator */
.taskbar-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--primary); display: inline-block; }

/* Browser iframe */
#browser-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* Code editor */
#code-input { tab-size: 2; }
#code-output { white-space: pre-wrap; word-break: break-word; }

/* Range slider theming */
input[type="range"] { accent-color: var(--primary); }

/* Selection */
::selection { background: var(--primary); color: #000; }
