/*
  =========================================================
      QUANTUM/DOS RETRO STYLES + MAC WINDOW CONTROLS
      The "One CSS to rule them all."
      Hidden ASCII for watchers:

         .-.
        (   )
         |-|
         |~|   QUANTUM VISIONS
         |~|   SHIFTING REALITIES
         `-'   FOR THE CURIOUS . . .
  =========================================================
*/

/* =========================================================
   CSS VARIABLES - Color Palette & Typography
   ========================================================= */
:root {
  /* Core Retro Palette */
  --crt-black: #0a0a0a;
  --crt-dark: #121212;
  --phosphor-gray: #a8a8a8;
  --phosphor-green: #00ff64;
  --quantum-green: #00ff9d;
  --quantum-cyan: #00ffff;
  --quantum-purple: #c084fc;
  --quantum-amber: #f59e0b;
  --error-red: #ff5f57;
  --warning-yellow: #febc2e;
  --success-green: #28c840;

  /* Glow intensities */
  --glow-subtle: 0.3;
  --glow-medium: 0.5;
  --glow-strong: 0.8;

  /* Typography scale */
  --font-bios: 'WebPlusIBMBIOS', 'Courier New', monospace;
  --font-dos: 'WebPlusIBMVGA', 'Courier New', monospace;
  --font-ide: 'Syne Mono', 'WebPlusIBMVGA', monospace;
  --font-system: 'Ubuntu Mono', monospace;

  /* Animation timings */
  --flicker-fast: 0.08s;
  --flicker-slow: 0.15s;
  --glitch-interval: 6s;
  --scan-speed: 4s;
}

/* Global font settings */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* =========================================================
   NOISE OVERLAY - Controlled Chaos Film Grain
   ========================================================= */
.noise-overlay::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 3;
  animation: noiseShift 0.5s steps(10) infinite;
}

@keyframes noiseShift {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2%, -2%); }
  20% { transform: translate(2%, 2%); }
  30% { transform: translate(-3%, 1%); }
  40% { transform: translate(1%, -3%); }
  50% { transform: translate(-1%, 3%); }
  60% { transform: translate(3%, -1%); }
  70% { transform: translate(-2%, 2%); }
  80% { transform: translate(2%, -2%); }
  90% { transform: translate(-1%, -1%); }
}

/* =========================================================
   DEAD PIXELS EFFECT - Subtle CRT Defects
   ========================================================= */
.dead-pixels::after {
  content: "";
  position: fixed;
  width: 2px; height: 2px;
  background: var(--crt-black);
  box-shadow:
    127px 89px var(--crt-black),
    892px 234px var(--crt-black),
    456px 678px var(--crt-black),
    1024px 123px var(--crt-black),
    234px 890px var(--crt-black),
    678px 456px var(--crt-black),
    345px 567px var(--crt-black),
    789px 123px var(--crt-black),
    901px 789px var(--crt-black),
    123px 345px var(--crt-black),
    567px 901px var(--crt-black),
    890px 567px var(--crt-black);
  pointer-events: none;
  z-index: 4;
}

/* --- 1. DOS Retro & Scanlines + Flicker --- */

/* Pixel-based DOS-like font with Polish characters support */
@font-face {
    font-family: 'WebPlusIBMVGA';
    src: url('../fonts/WebPlus_IBM_VGA_8x16.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'WebPlusIBMEGA';
    src: url('../fonts/WebPlus_IBM_EGA_8x14.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'WebPlusIBMBIOS';
    src: url('../fonts/WebPlus_IBM_BIOS.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'WebPlusIBMBIOS2Y';
    src: url('../fonts/WebPlus_IBM_BIOS-2y.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'WebPlusIBMVGA9x8';
    src: url('../fonts/WebPlus_IBM_VGA_9x8-2x.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* Attempt to fix zoom on various devices */
@viewport {
    zoom: 1;
    min-zoom: 1;
    max-zoom: 1;
}

body {
    margin: 0;
    padding: 0;
    background: #000;
    height: 100vh;
    overflow: hidden;
    image-rendering: auto;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    zoom: reset;
    /* Vignette effect - darker corners for authentic CRT feel */
    box-shadow: inset 0 0 200px rgba(0,0,0,0.9), inset 0 0 100px rgba(0,0,0,0.6);
}

/* Force pixel ratio on hi-dpi screens */
@media screen and (min-resolution: 1dppx) {
    html {
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
    }
}

/* Subtle scanlines layering - minimal, no phosphor glow */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
      linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.15) 50%); /* horizontal scanlines only */
    z-index: 2;
    background-size: 100% 2px;
    pointer-events: none;
    /* No phosphor glow - keeping it minimal and authentic */
}

/* Enhanced flicker overlay with variable timing for authenticity */
body::after {
    content: "";
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(18,16,16,0.1);
    opacity: 0;
    z-index: 2;
    pointer-events: none;
    animation: flickerEnhanced 0.11s infinite, flickerBurst 7s infinite;
}

@keyframes flickerEnhanced {
    0%   { opacity: 0.27; }
    15%  { opacity: 0.15; }
    30%  { opacity: 0.35; }
    45%  { opacity: 0.08; }
    60%  { opacity: 0.25; }
    75%  { opacity: 0.12; }
    100% { opacity: 0.28; }
}

/* Random burst flickers for more authentic CRT behavior */
@keyframes flickerBurst {
    0%, 90% { filter: brightness(1); }
    91% { filter: brightness(0.5); }
    92% { filter: brightness(1.2); }
    93% { filter: brightness(0.7); }
    94%, 100% { filter: brightness(1); }
}

.screen {
    height: 100vh; width: 100vw;
    background-color: #000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: hidden;
    position: relative;
    padding: 20px;
    /* Barrel distortion for CRT screen curvature illusion */
    border-radius: 3% / 2%;
    transform: perspective(800px) rotateX(0deg);
    animation: subtleCurvature 15s ease-in-out infinite, randomGlitch 8s infinite;
}

/* VGA virtual viewport opt-in: pages that want a fixed 640×480 (or 320×240)
   grid scaled to the actual screen layer their own #terminal-container size
   in their per-page <style>. The shared bits live here:
     - .retro-screen centres its child grid cell so transform:scale stays
       symmetric around the middle (no left/top drift).
     - --vga-scale is set by setupVgaScaling() in retro-terminal-engine.js
       on load + resize.
   Per-page styles (e.g. bios.html) reference --vga-scale in their own
   #terminal-container { transform: scale(var(--vga-scale, 1)) } block. */
.retro-screen {
    display: grid;
    place-items: center;
}

/* Subtle curvature animation to simulate CRT bulge */
@keyframes subtleCurvature {
    0%, 100% {
        border-radius: 3% / 2%;
        transform: perspective(800px) rotateX(0deg);
    }
    50% {
        border-radius: 2.5% / 1.8%;
        transform: perspective(820px) rotateX(0.3deg);
    }
}

/* Random glitch effects - horizontal tears */
@keyframes randomGlitch {
    0%, 85%, 100% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
    86% {
        clip-path: inset(20% 0 60% 0);
        transform: translateX(-3px);
    }
    87% {
        clip-path: inset(40% 0 30% 0);
        transform: translateX(3px);
    }
    88% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
    90% {
        clip-path: inset(60% 0 10% 0);
        transform: translateX(-2px);
    }
    91% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
}

/* Optional "retro-screen" layering */
.retro-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
      linear-gradient(rgba(255,255,255,0.07) 50%, rgba(0,0,0,0.05) 50%),
      linear-gradient(90deg, rgba(255,255,255,0.07) 1px, transparent 1px);
    background-size: 100% 4px, 4px 100%;
    opacity: 0.2;
    pointer-events: none;
    z-index: 1;
}

/* Traveling scan line effect - DISABLED (too distracting)
.screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    opacity: 0.4;
    pointer-events: none;
    z-index: 10;
    animation: scanlineRoll 4s linear infinite;
}
*/

@keyframes scanlineRoll {
    0% {
        top: -3px;
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

.bios-content {
    position: relative;
    z-index: 2;
    color: #a8a8a8;
    text-shadow: 0 0 1px rgba(168,168,168,0.5);
    animation: textGlitchRandom 12s infinite;
}

/* Random text glitch effect - subtle RGB split only */
@keyframes textGlitchRandom {
    0%, 92%, 100% {
        text-shadow: 0 0 1px rgba(168,168,168,0.5);
        transform: translateX(0);
    }
    93% {
        text-shadow:
            1px 0 1px rgba(255,0,0,0.6),
            -1px 0 1px rgba(0,255,255,0.6);
        transform: translateX(-1px);
    }
    94% {
        text-shadow:
            -1px 0 1px rgba(255,0,0,0.6),
            1px 0 1px rgba(0,255,255,0.6);
        transform: translateX(1px);
    }
    95% {
        text-shadow: 0 0 1px rgba(168,168,168,0.5);
        transform: translateX(0);
    }
}

/* Hide scrollbar if needed */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
    white-space: nowrap !important;
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
}

/* Tab button styling for console-y look */
.tab-button {
    box-shadow: 0 0 15px rgba(255,255,255,0.15);
    transition: all 0.3s ease;
}
.tab-button:hover {
    box-shadow: 0 0 25px rgba(0,255,157,0.3);
}
.tab-button.active-tab {
    box-shadow: 0 0 30px rgba(0,255,157,0.4), inset 0 0 15px rgba(0,255,157,0.2);
    border: 1px solid rgba(0,255,157,0.6);
    background: rgba(0,255,157,0.1);
}

/* Glassmorphism styles */
.glassmorphism {
    background: rgba(30,41,59,0.5);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 32px 0 rgba(31,38,135,0.37);
}

.glassmorphic-header {
    background: rgba(45, 45, 45, 0.6) !important;
    backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.glassmorphic-content {
    background: rgba(30, 30, 30, 0.3);
    backdrop-filter: blur(10px);
}

/* Code text style */
pre {
    margin: 0;
    padding: 0;
    color: #a8a8a8;
    font-family: 'WebPlusIBMVGA', 'WebPlusIBMBIOS', monospace;
    font-size: 26px;
    line-height: 1.2;
    white-space: pre;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Console cursor blink */
.cursor {
    animation: blink 1.2s step-end infinite;
    color: #a8a8a8;
}
@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 1; }
    51% { opacity: 0; }
    100% { opacity: 0; }
}

/* CRT shutdown effect (vertical collapse) */
.crt-shutdown {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(255,255,255,0.2));
    animation: crtOff 1s ease-in forwards;
    pointer-events: none;
    z-index: 1000;
}
@keyframes crtOff {
    0%   { transform: scaleY(1);   opacity: 1; }
    60%  { transform: scaleY(0.001); opacity: 0.8; }
    100% { transform: scaleY(0);   opacity: 0; }
}

/* Flicker brightness for CRT vibe */
@keyframes crtFlicker {
    0%   { filter: brightness(1); }
    25%  { filter: brightness(0.8); }
    50%  { filter: brightness(0.4); }
    75%  { filter: brightness(0.6); }
    100% { filter: brightness(1); }
}

/* Quantum transition & prompt fade if needed */
@keyframes quantumTransition {
    0%   { transform: scale(1); filter: brightness(1); }
    50%  { transform: scale(1.5); filter: brightness(2) blur(10px); }
    100% { transform: scale(2); filter: brightness(0); }
}
@keyframes promptFade {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

/* Year or era color classes (if you want to style time periods) */
.year {
    font-size: 0.8em;
    opacity: 0.7;
    color: #888;
}
.era-1986 { color: #33ff33; text-shadow: 0 0 5px #33ff33; }
.era-1995 { color: #00a4ff; text-shadow: 0 0 5px #00a4ff; }
.era-2000 { color: #ffffff; text-shadow: 0 0 5px #ffffff; }
.era-2010 { color: #4287f5; text-shadow: 0 0 8px #4287f5; }
.era-2020 { color: #00ff9d; text-shadow: 0 0 12px #00ff9d; }
.era-2025 { 
    color: #00ffff;
    text-shadow: 0 0 15px #00ffff, 0 0 25px #00ffff;
    animation: futurePulse 2s infinite;
}
@keyframes futurePulse {
    0%   { opacity: 0.8; transform: scale(1); }
    50%  { opacity: 1;   transform: scale(1.1); }
    100% { opacity: 0.8; transform: scale(1); }
}

#dosPrompt {
  transition: transform 0.8s ease-in-out;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 90vw;
  line-height: 1.4;
}

.quantum-glitch-container {
  position: relative;
  display: inline-block; /* ensures we can glitch over it */
}


/* --- 2. QUANTUMOS "MAC" WINDOW & TASKBAR --- */

/* Desktop background (semi-opaque) */
.desktop {
    height: 100vh;
    background: rgba(32,32,32,0.1);
    overflow: hidden;
    position: relative;
}

/* Top bar / Taskbar */
.taskbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 32px;
    background: rgba(32,32,32,0.5);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    padding: 0 10px;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

/* The main "window" in the center (like an app) */
.window {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 85vh;
    background: rgba(30, 30, 30, 0.6);
    border-radius: 8px;
    box-shadow:
        0 0 30px rgba(0, 255, 157, 0.2),
        0 0 60px rgba(0, 0, 0, 0.5),
        inset 0 0 60px rgba(0, 255, 100, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chromaticAberration 10s ease-in-out infinite;
}

/* Chromatic aberration for extra CRT authenticity */
@keyframes chromaticAberration {
    0%, 100% {
        filter: blur(0px) contrast(1);
        box-shadow:
            0 0 30px rgba(0, 255, 157, 0.2),
            0 0 60px rgba(0, 0, 0, 0.5),
            inset 0 0 60px rgba(0, 255, 100, 0.05);
    }
    50% {
        filter: blur(0.3px) contrast(1.05);
        box-shadow:
            0 0 35px rgba(0, 255, 157, 0.25),
            0 0 70px rgba(0, 0, 0, 0.6),
            inset 0 0 70px rgba(0, 255, 100, 0.08),
            inset -2px 0 5px rgba(255, 0, 0, 0.1),
            inset 2px 0 5px rgba(0, 0, 255, 0.1);
    }
}

/* Window header bar (like Mac) */
.window-header {
    height: 42px;
    background: #2d2d2d;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    padding: 0 10px;
    justify-content: space-between;
}

/* Window title text */
.window-title {
    color: #fff;
    font-family: 'Ubuntu Mono', monospace;
    font-size: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Group of the 3 "Mac" circles */
.window-controls {
    display: flex;
    gap: 8px;
}

/* The circles themselves */
.control-btn {
    width: 16px; height: 16px;
    border-radius: 50%;
    position: relative; /* needed if we do ::before or ::after for icons */
    cursor: pointer;
}

/* Specific colors for each circle */
.close { background: #ff5f57; }
.minimize { background: #febc2e; }
.maximize { background: #28c840; }

/* For the system menu (logo + label) */
.system-menu {
    display: flex;
    gap: 15px;
    align-items: center;
}

.system-menu img {
    height: 24px;
    width: auto;
    object-fit: contain;
}

/* The clock/time on the right side */
.system-time {
    color: #fff;
    font-family: 'Ubuntu Mono', monospace;
    font-size: 20px;
    margin-left: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Base icon styling */
.control-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 14px;
  height: 14px;
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.control-btn:hover::before {
  opacity: 0.8;
  transform: translate(-50%, -50%) scale(1);
}

.control-btn.close:hover::before {
  background-image: url("https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/github.svg");
  filter: invert(1);
}

.control-btn.minimize:hover::before {
  background-image: url("https://huggingface.co/favicon.ico");
  background-size: 95% 95%;
  filter: brightness(1.2) contrast(1.2);
}

.control-btn.maximize:hover::before {
  background-image: url("https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/linkedin.svg");
  filter: invert(1);
}

/* Button text colors */
.control-btn.close span { color: #ff5f57; }
.control-btn.minimize span { color: #febc2e; }
.control-btn.maximize span { color: #28c840; }
/* =========================================================
   VHS TRACKING EFFECT - Random Horizontal Distortion
   ========================================================= */
@keyframes vhsTracking {
  0%, 95%, 100% {
    clip-path: inset(0);
    transform: translateX(0);
  }
  96% {
    clip-path: inset(15% 0 75% 0);
    transform: translateX(-4px);
  }
  97% {
    clip-path: inset(50% 0 30% 0);
    transform: translateX(6px);
  }
  98% {
    clip-path: inset(80% 0 5% 0);
    transform: translateX(-3px);
  }
}

.vhs-effect {
  animation: vhsTracking 15s infinite;
}

/* =========================================================
   CHROMATIC ABERRATION - Text RGB Split Effect
   ========================================================= */
.chromatic-text {
  text-shadow:
    -1px 0 rgba(255, 0, 0, 0.3),
    1px 0 rgba(0, 255, 255, 0.3);
  animation: chromaticShift 8s ease-in-out infinite;
}

@keyframes chromaticShift {
  0%, 100% {
    text-shadow:
      -1px 0 rgba(255, 0, 0, 0.3),
      1px 0 rgba(0, 255, 255, 0.3);
  }
  50% {
    text-shadow:
      -2px 0 rgba(255, 0, 0, 0.5),
      2px 0 rgba(0, 255, 255, 0.5);
  }
}

/* ============================================================
   MOBILE SUPPORT - INTENTIONALLY DIFFICULT, NOT BROKEN
   ============================================================ */

/* Mobile-specific optimizations (tablet and phone) */
@media screen and (max-width: 768px) {
  /* Reduce font sizes slightly for mobile readability */
  pre {
    font-size: 18px;
    line-height: 1.1;
  }

  .window-title {
    font-size: 16px;
  }

  .system-time {
    font-size: 16px;
  }

  /* Make window fit better on small screens */
  .window {
    width: 95vw;
    height: 90vh;
    top: 52%;
  }

  /* Adjust window header for mobile */
  .window-header {
    height: 36px;
    padding: 0 8px;
  }

  .window-controls {
    gap: 6px;
  }

  .control-btn {
    width: 14px;
    height: 14px;
  }

  /* Make taskbar more compact on mobile */
  .taskbar {
    height: 28px;
    padding: 0 8px;
  }

  /* Tab buttons - slightly smaller but still accessible */
  .tab-button {
    font-size: 18px;
    padding: 6px 10px;
  }

  /* Ensure tabs container is touch-scrollable */
  .hide-scrollbar {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* IDE container adjustments */
  #ide-container {
    padding: 4px;
  }

  /* Reduce padding in terminal for more space */
  #terminal-content {
    padding: 8px;
    font-size: 12px;
  }

  /* Make Monaco editor more mobile-friendly */
  #monaco-editor {
    font-size: 12px;
  }

  /* Adjust screen padding */
  .screen {
    padding: 10px;
  }

  /* Make "next" button more prominent on mobile */
  #quantumCanvas + button {
    font-size: 16px;
    padding: 8px 16px;
    background: rgba(0, 255, 157, 0.2);
    border: 1px solid rgba(0, 255, 157, 0.6);
    color: #00ff9d;
    border-radius: 4px;
  }
}

/* Phone-specific (very small screens) */
@media screen and (max-width: 480px) {
  pre {
    font-size: 14px;
  }

  .window-title {
    font-size: 14px;
  }

  .system-time {
    font-size: 14px;
  }

  .tab-button {
    font-size: 16px;
    padding: 4px 8px;
  }

  /* Hide some decorative elements on very small screens */
  .system-menu img {
    display: none;
  }

  /* Make control buttons slightly larger for easier tapping */
  .control-btn {
    width: 16px;
    height: 16px;
  }
}

/* Touch device optimizations - keep CRT effects but optimize */
@media (hover: none) and (pointer: coarse) {
  /* Reduce some heavy effects on touch devices for performance */
  body::before {
    /* Lighter scanlines for better mobile performance */
    opacity: 0.3;
  }

  body::after {
    /* Lighter flicker on mobile */
    animation: flickerMobile 0.2s infinite;
  }

  @keyframes flickerMobile {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.05; }
  }

  /* Ensure touch targets are at least 44x44px (iOS guideline) */
  .tab-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .control-btn {
    min-width: 44px;
    min-height: 44px;
    /* Make the visible circle smaller but keep touch area large */
    background-clip: content-box;
    padding: 14px;
  }

  /* Disable hover effects on touch devices */
  .tab-button:hover:not(.active-tab),
  .control-btn:hover::before {
    /* Inherit default state, no hover effects */
    opacity: inherit;
    transform: inherit;
  }

  /* Make tap feedback more obvious */
  .tab-button:active {
    transform: scale(0.95);
    opacity: 0.7;
  }

  .control-btn:active {
    transform: scale(0.9);
  }
}

/* Landscape mobile - different approach */
@media screen and (max-width: 896px) and (orientation: landscape) {
  .window {
    width: 98vw;
    height: 95vh;
  }

  .taskbar {
    height: 24px;
  }

  #terminal-content {
    font-size: 11px;
  }
}

/* High DPI mobile screens - keep sharpness */
@media screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px),
       screen and (min-resolution: 192dpi) and (max-width: 768px) {
  /* Ensure fonts stay crisp on retina mobile */
  pre, .window-title, .system-time {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* =========================================================
   TERMINAL SIDE-BY-SIDE LAYOUT
   ========================================================= */
/* Smooth transitions for terminal show/hide */
#terminal-area {
  transition: width 0.3s ease-in-out, opacity 0.2s ease-in-out;
}

#editor-area {
  transition: width 0.3s ease-in-out;
}

/* Ensure content wrapper uses flexbox properly */
#content-wrapper {
  display: flex;
  flex-direction: row;
  width: 100%;
}

/* Mobile responsive - stack vertically on small screens when in infinity tab */
@media screen and (max-width: 768px) {
  #content-wrapper {
    flex-direction: column;
  }

  /* On mobile, terminal takes full width when visible */
  #terminal-area:not(.hidden) {
    width: 100% !important;
    border-left: none;
    border-top: 1px solid #4a5568;
  }

  #editor-area {
    width: 100% !important;
  }
}

/* ========================================
   ENHANCED TRANSITION EFFECTS
   ======================================== */

/* CRT shutdown effect (dramatic vertical collapse with bright line) */
.crt-shutdown {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    pointer-events: none;
    z-index: 1000;
}

.crt-shutdown::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 49%,
        rgba(255,255,255,0.9) 49.5%,
        rgba(255,255,255,1) 50%,
        rgba(255,255,255,0.9) 50.5%,
        transparent 51%,
        transparent 100%
    );
    animation: crtCollapseBeam 0.8s cubic-bezier(0.55, 0, 1, 0.45) forwards;
    box-shadow: 0 0 50px rgba(255,255,255,0.8);
}

.crt-shutdown::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    animation: crtFadeIn 0.3s ease-in 0.5s forwards;
    opacity: 0;
}

@keyframes crtCollapseBeam {
    0% {
        transform: scaleY(1);
        opacity: 1;
    }
    50% {
        transform: scaleY(0.8);
        opacity: 1;
        filter: brightness(1.5);
    }
    80% {
        transform: scaleY(0.02);
        opacity: 1;
        filter: brightness(2);
    }
    100% {
        transform: scaleY(0.001);
        opacity: 0.3;
        filter: brightness(3);
    }
}

@keyframes crtFadeIn {
    to { opacity: 1; }
}

/* Quantum glitch effect (screen tears and RGB split) */
.quantum-glitch {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 999;
    background:
        linear-gradient(to bottom, rgba(0, 255, 157, 0.10), rgba(255, 0, 128, 0.08)),
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.06) 3px 4px);
    animation: quantumGlitch 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chat-glitch-active {
    animation: chatSignalDrift 0.18s steps(2, end) 7;
}

.chat-glitch-text,
.chat-message.assistant.glitch {
    color: #00fff0 !important;
    text-shadow:
        2px 0 rgba(255, 0, 96, 0.9),
        -2px 0 rgba(0, 255, 157, 0.7),
        0 0 12px rgba(0, 255, 240, 0.55);
    animation: chatTextGlitch 0.11s steps(2, end) 11;
}

@keyframes chatSignalDrift {
    0%, 100% { filter: none; transform: translate(0, 0); }
    30% { filter: hue-rotate(70deg) saturate(1.7); transform: translate(-1px, 1px); }
    60% { filter: hue-rotate(210deg) saturate(1.4); transform: translate(2px, -1px); }
}

@keyframes chatTextGlitch {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-1px); }
    50% { transform: translateX(2px); }
    75% { transform: translateX(-2px); }
}

@keyframes quantumGlitch {
    0%, 100% {
        clip-path: inset(0 0 0 0);
        transform: translate(0, 0);
    }
    10% {
        clip-path: inset(10% 0 85% 0);
        transform: translate(-5px, 5px);
        filter: hue-rotate(90deg);
    }
    15% {
        clip-path: inset(50% 0 30% 0);
        transform: translate(5px, -3px);
    }
    20% {
        clip-path: inset(80% 0 0 0);
        transform: translate(-3px, 2px);
        filter: hue-rotate(180deg);
    }
    25% {
        clip-path: inset(20% 0 60% 0);
        transform: translate(2px, -5px);
    }
    30% {
        clip-path: inset(0 0 50% 0);
        transform: translate(-8px, 0);
    }
    35% {
        clip-path: inset(60% 0 10% 0);
        transform: translate(5px, 3px);
        filter: hue-rotate(270deg);
    }
    40% {
        clip-path: inset(40% 0 40% 0);
        transform: translate(-2px, -4px);
    }
}

.quantum-rgb-split {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 998;
    animation: rgbSplit 0.6s ease-out 0.8s;
    opacity: 0;
}

@keyframes rgbSplit {
    0% { opacity: 0; }
    20% {
        opacity: 1;
        filter:
            drop-shadow(-3px 0 0 rgba(255,0,0,0.8))
            drop-shadow(3px 0 0 rgba(0,255,255,0.8));
    }
    40% {
        filter:
            drop-shadow(-5px 0 0 rgba(255,0,0,1))
            drop-shadow(5px 0 0 rgba(0,255,255,1));
    }
    60% {
        filter:
            drop-shadow(-2px 0 0 rgba(255,0,0,0.6))
            drop-shadow(2px 0 0 rgba(0,255,255,0.6));
    }
    100% { opacity: 0; }
}

/* Audio feedback preparation (for future implementation) */
.transition-audio-ready {
    /* Placeholder for audio feedback hooks */
    --beep-frequency: 1000;
    --shutdown-tone: 800;
    --glitch-noise: white;
}


/* =========================================================
   CUSTOMIZE SIDEBAR
   ========================================================= */
:root {
    --glass-blur: 15px;
    --glass-transparency: 0.7;
}

.glassmorphic {
    backdrop-filter: blur(var(--glass-blur)) !important;
    background: rgba(13, 17, 23, var(--glass-transparency)) !important;
}

.customize-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.75);
    backdrop-filter: blur(25px);
    font-family: var(--font-ide);
    color: #fff;
}

.customize-sidebar.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.customize-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--quantum-green);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.toggle-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toggle-btn:hover {
    opacity: 1;
    color: var(--error-red);
}

.open-sidebar-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    background: rgba(13, 17, 23, 0.5);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

.open-sidebar-btn:hover {
    background: rgba(13, 17, 23, 0.8);
    border-color: var(--quantum-green);
    color: var(--quantum-green);
    transform: rotate(90deg);
}

.control-group {
    margin-bottom: 25px;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: #aaa;
}

.glass-input {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 10px;
    border-radius: 4px;
    font-family: inherit;
}

.glass-input option {
    background: #111;
    color: #fff;
}

.glass-slider {
    width: 100%;
    accent-color: var(--quantum-green);
}

/* Surface Themes */
body.surface-01 { background: #000; }
body.surface-02 { background: radial-gradient(circle at center, #0a192f 0%, #000000 100%); }
body.surface-03 { background: linear-gradient(45deg, #090a0f, #1a202c); }
body.surface-04 { background: repeating-linear-gradient(0deg, #000, #000 2px, #050505 2px, #050505 4px); }
body.surface-05 { background: radial-gradient(circle at 50% 0%, #1f2937 0%, #000 80%); }
