:root {
  --font-monospace: 'Courier New', Courier, monospace;
  --font-sans: system-ui, -apple-system, sans-serif;
  
  /* Precision Sequential Phase Durations */
  --dur-p1: 3.2s; 
  --dur-p2: 4.2s; 
  --dur-p3: 3.5s; 

  /* DEFAULT DARK MODE THEME VARIABLE SETS */
  --bg-html-body: #06070a;
  --bg-preloader-mask: rgba(4, 5, 7, 0.99);
  --bg-window-shell: #0f111a;
  --bg-bar-header: #171924;
  --bg-sidebar-ide: #0c0d14;
  --text-primary-color: #f1f5f9;
  --text-muted-color: #64748b;
  --accent-green: #10b981;
  --accent-cyan: #06b6d4;
  --accent-orange: #f59e0b;
  --ui-border-line: #212534;
  --ui-box-shadow: rgba(0, 0, 0, 0.65);
  --bg-term-embedded: #07080d;

  /* PHASE 3 GLOW SPECS */
  --glow-green: #22c55e;
  --bg-tester-custom: #1a1c23;
  --bg-progress-track: #262936;
}

/* THEME INTERACTION RE-ROUTING */
#theme-switch:checked ~ :root,
#theme-switch:checked ~ * {
  /* LIGHT MODE THEME VARIABLE SETS */
  --bg-html-body: #f8fafc;
  --bg-preloader-mask: rgba(241, 245, 249, 0.99);
  --bg-window-shell: #ffffff;
  --bg-bar-header: #e2e8f0;
  --bg-sidebar-ide: #f1f5f9;
  --text-primary-color: #0f172a;
  --text-muted-color: #64748b;
  --accent-green: #16a34a;
  --accent-cyan: #0891b2;
  --accent-orange: #ea580c;
  --ui-border-line: #cbd5e1;
  --ui-box-shadow: rgba(15, 23, 42, 0.05);
  --bg-term-embedded: #f1f5f9;
  --bg-tester-custom: #ffffff;
  --bg-progress-track: #e2e8f0;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  background-color: var(--bg-html-body); color: var(--text-primary-color);
  font-family: var(--font-sans); overflow-x: hidden; min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.theme-checkbox { display: none; }

/* Floating Interactive Theme Control Capsule */
.theme-toggle-widget {
  position: fixed; top: 24px; right: 24px; width: 44px; height: 44px;
  border-radius: 50%; background-color: var(--bg-window-shell); border: 1px solid var(--ui-border-line);
  box-shadow: 0 4px 14px var(--ui-box-shadow); display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10000; user-select: none; transition: transform 0.2s ease;
}
.theme-toggle-widget:hover { transform: scale(1.05); }
.theme-toggle-widget .sun-icon { display: none; font-size: 1.15rem; }
.theme-toggle-widget .moon-icon { display: block; font-size: 1.15rem; }

#theme-switch:checked + .theme-toggle-widget .sun-icon { display: block; }
#theme-switch:checked + .theme-toggle-widget .moon-icon { display: none; }


/* 1. STRUCTURAL PRELOADER OVERLAY WINDOW CONTAINMENT */
.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: var(--bg-preloader-mask); display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 9990;
  animation: exitOverlay 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  animation-delay: calc(var(--dur-p1) + var(--dur-p2) + var(--dur-p3));
}

.window-shell {
  width: 100%; background-color: var(--bg-window-shell);
  border: 1px solid var(--ui-border-line); border-radius: 12px;
  box-shadow: 0 24px 60px var(--ui-box-shadow); display: flex; flex-direction: column;
  position: absolute;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: background-color 0.3s, border-color 0.3s;
}

/* App Box Layout Scales */
.box-status { max-width: 580px; height: 260px; overflow: hidden; }
.box-tester { max-width: 640px; height: 280px; overflow: hidden; }
.box-ide { 
  max-width: 720px; 
  height: 420px; 
  position: relative; 
  overflow: visible !important; 
  z-index: 10;}

/* Control Header Elements */
.mac-header {
  background-color: var(--bg-bar-header); padding: 12px 16px;
  display: flex; align-items: center; border-bottom: 1px solid var(--ui-border-line); position: relative;
  border-top-left-radius: 11px; border-top-right-radius: 11px;
}
.mac-dots { display: flex; gap: 8px; }
.mac-dots span { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.md-close { background-color: #ef4444; }
.md-min { background-color: #eab308; }
.md-max { background-color: #22c55e; }
.mac-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--font-monospace); font-size: 0.8rem; color: var(--text-muted-color);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%;
}

.mac-body { padding: 24px; font-size: 0.95rem; line-height: 1.6; flex-grow: 1; }


/* 2. REFINED PHYSICAL WINDOW PIPELINE (STRICT TIMELINE SEQUENCING)*/

/* PHASE 1: Profile Initialization App Box Status */
.phase-1 {
  animation: lifecycleFirstWindow var(--dur-p1) step-end forwards;
}
.p1-t1 { width: 0; animation: typeLineCharacter 0.6s steps(25) forwards; animation-delay: 0.3s; }
.p1-t2 { width: 0; animation: typeLineCharacter 0.6s steps(25) forwards; animation-delay: 1.1s; }

/* PHASE 2: Visual Studio Code Framework App Box Simulation */
.phase-2 {
  animation: lifecycleMiddleWindow var(--dur-p2) step-end forwards;
  animation-delay: var(--dur-p1);
}
.ide-wrapper { display: flex; flex-grow: 1; height: calc(100% - 41px); overflow: hidden; border-bottom-left-radius: 11px; border-bottom-right-radius: 11px; }

.ide-sidebar-nav {
  width: 160px; background-color: var(--bg-sidebar-ide); border-right: 1px solid var(--ui-border-line);
  padding: 16px 8px; font-size: 0.8rem; color: var(--text-muted-color); user-select: none;
}
.sb-node { padding: 4px 8px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; }
.sb-node.active { color: var(--text-primary-color); font-weight: 500; }
.sb-node.active-file { background-color: rgba(6, 182, 212, 0.08); color: var(--accent-cyan); }
.indent { margin-left: 12px; }

.ide-code-container { flex-grow: 1; display: flex; flex-direction: column; background-color: rgba(0,0,0,0.01); }
#theme-switch:checked ~ .loading-overlay .ide-code-container { background-color: #fafafa; }
.ide-tab-header { display: flex; background-color: var(--bg-sidebar-ide); border-bottom: 1px solid var(--ui-border-line); }
.tab-pill { padding: 6px 14px; font-size: 0.75rem; color: var(--text-muted-color); border-right: 1px solid var(--ui-border-line); }
.tab-pill.active { background-color: var(--bg-window-shell); color: var(--text-primary-color); border-top: 2px solid var(--accent-cyan); }

/* Text Script Space Layout */
.ide-code-workspace { padding: 20px; font-size: 0.85rem; line-height: 1.5; position: relative; height: 160px; }
.syntax-row { margin-bottom: 2px; white-space: nowrap; }
.syntax-row.ind { padding-left: 20px; }
.k-word { color: #f43f5e; } .k-func { color: #3b82f6; } .k-prop { color: var(--accent-orange); } .k-str { color: var(--accent-green); } .k-bool { color: #a855f7; }

.ide-curtain-mask {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-color: var(--bg-window-shell); transform-origin: right;
  animation: exposeIdeCode var(--dur-p2) steps(25) forwards;
}

.ide-embedded-terminal {
  background-color: var(--bg-term-embedded); border-top: 1px solid var(--ui-border-line);
  height: calc(100% - 197px); display: flex; flex-direction: column;
}
.term-nav {
  padding: 6px 16px; font-size: 0.7rem; color: var(--text-primary-color);
  font-weight: bold; letter-spacing: 0.5px; border-bottom: 1px solid var(--ui-border-line);
}
.term-scroller {
  padding: 10px 16px; font-size: 0.8rem; line-height: 1.4; opacity: 0;
  animation: fadeTerminalRun 0.2s step-end forwards;
  animation-delay: calc(var(--dur-p1) + 1.8s);
}
.term-line { margin-bottom: 3px; white-space: nowrap; overflow: hidden; }


/* 2b. DYNAMIC POPUP AVATARS ENGINE (IMAGE 2 REPLICA) */
.avatar-container {
  position: absolute;
  top: -90.5px; 
  left: 0;
  width: 100%;
  height: 100px;
  pointer-events: none;
  z-index: 5; 
  display: flex;
  justify-content: space-between;
  padding: 0 40px;
}

.avatar-card {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  animation: popAvatarUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
}

.avatar-dev { animation-delay: calc(var(--dur-p1) + 0.3s); }
.avatar-tester { flex-direction: row-reverse; animation-delay: calc(var(--dur-p1) + 0.7s); }

.avatar-img {
  width: 110px; 
  height: auto;
  pointer-events: auto;
  filter: drop-shadow(0 10px 10px rgba(0,0,0,0.3));
}
.avatar-tester .avatar-img {
  width: 95px;
}
.speech-bubble {
  background-color: var(--text-primary-color);
  color: var(--bg-window-shell);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  margin-bottom: 20px;
  white-space: nowrap;
}

@keyframes popAvatarUp {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* 3. PHASE 3 DESIGN UPGRADE*/
.phase-3 {
  animation: lifecycleMiddleWindow var(--dur-p3) step-end forwards;
  animation-delay: calc(var(--dur-p1) + var(--dur-p2));
  background-color: var(--bg-tester-custom);
  overflow: hidden;
}
.testing-status-header { letter-spacing: 1px; }
.uppercase-title { text-transform: uppercase; font-weight: 600; font-size: 0.85rem; letter-spacing: 1px; }
.testing-body { padding: 28px 24px; }
.font-light { font-weight: 300; opacity: 0.9; }
.system-log { width: 0; color: #4ade80; opacity: 0.95; margin-top: 8px; }
.phase-3 .p3-r1 { animation: typeLineCharacter 0.6s steps(40) forwards; animation-delay: calc(var(--dur-p1) + var(--dur-p2) + 0.3s); }

.test-row-layout { 
  display: flex; 
  flex-direction: column;   
  align-items: flex-start;  
  gap: 4px;                 
  width: 100%; 
  opacity: 0; 
  margin-top: 6px; 
}

.test-right { 
  margin-left: 20px; 
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.passed-badge {
    width: 16px; 
    height: 16px;
    object-fit: contain;
    background: transparent !important; 
}
.phase-3 .p3-r2 { animation: revealMetricsGraph 0.1s step-end forwards; animation-delay: calc(var(--dur-p1) + var(--dur-p2) + 1.2s); }
.test-left { color: #4ade80; }
.env-tag { color: #93c5fd; font-weight: bold; }
.success-glow { color: #22c55e; font-weight: bold; text-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }

.dynamic-progress {
  border-top: none; margin-top: 28px; padding-top: 0; background-color: var(--bg-progress-track);
  height: 8px; border-radius: 4px; overflow: hidden; opacity: 0;
  animation: revealMetricsGraph 0.2s forwards; animation-delay: calc(var(--dur-p1) + var(--dur-p2) + 1.6s);
}
.glowing-fill {
  height: 100%; width: 0%; background-color: var(--glow-green); border-radius: 4px; box-shadow: 0 0 12px var(--glow-green);
  animation: incrementMetricsGraph 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: calc(var(--dur-p1) + var(--dur-p2) + 1.8s);
}


/* 4. ANIMATION TIMELINE TRANSITION KEYFRAMES*/
@keyframes typeLineCharacter {
  from { width: 0; border-right: 2px solid var(--accent-green); }
  to { width: 100%; border-right: 2px solid transparent; }
}
@keyframes exposeIdeCode {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0); display: none; }
}
@keyframes fadeTerminalRun { to { opacity: 1; } }
@keyframes revealMetricsGraph { to { opacity: 1; } }
@keyframes incrementMetricsGraph { to { width: 100%; } }

@keyframes lifecycleFirstWindow {
  0% { opacity: 1; visibility: visible; pointer-events: auto; }
  100% { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes lifecycleMiddleWindow {
  0% { opacity: 1; visibility: visible; pointer-events: auto; }
  100% { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes exitOverlay {
  to { opacity: 0; transform: scale(1.02); visibility: hidden; pointer-events: none; }
}

/* Micro-Utilities */
.font-mono { font-family: var(--font-monospace); }
.terminal-line { white-space: nowrap; overflow: hidden; margin-bottom: 8px; }
.cmd-color { color: var(--accent-cyan); }
.success-color { color: var(--accent-green) !important; }

/* 5. CROSS-DEVICE VIEWPORT COMPATIBILITY BREAKPOINTS */
@media (max-width: 768px) {
  .box-status, .box-tester { height: auto; min-height: 250px; left: 16px; right: 16px; width: auto; }
  .box-ide { height: 400px; left: 16px; right: 16px; width: auto; }
  .ide-sidebar-nav { display: none; } 
  .mac-body, .ide-code-workspace { padding: 16px; font-size: 0.85rem; }
  .test-row-layout { flex-direction: column; align-items: flex-start; gap: 4px; }
  .test-right { margin-left: 20px; }
  
  /* Make bubbles cleaner on mobile viewports */
  .avatar-dev { left: 10px; }
  .avatar-tester { right: 10px; }
  .speech-bubble { font-size: 0.75rem; padding: 6px 10px; }
  .character-emoji { font-size: 1.8rem; }
}

/* Isolated Mobile Layout Optimization */
@media (max-width: 500px) {
    .loading-overlay {
        padding: 12px !important;
    }

    .window-shell.box-status, 
    .window-shell.box-tester, 
    .window-shell.box-ide {
        left: 12px !important;
        right: 12px !important;
        width: calc(100% - 24px) !important;
        position: absolute !important;
    }

    .ide-code-workspace {
        font-size: 0.72rem !important;
    }

    .ide-embedded-terminal, 
    .term-scroller {
        font-size: 0.72rem !important;
    }

    .tab-pill {
        padding: 6px 8px !important;
        font-size: 0.68rem !important;
    }

    .avatar-container {
        padding: 0 15px !important;
        top: -91px !important;
    }
    
    .avatar-img {
        width: 85px !important; 
    }
    .avatar-tester .avatar-img {
        width: 75px !important; 
    }
    
    .speech-bubble {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
        margin-bottom: 12px !important;
    }
    .term-line.success-color {
        font-size: 0.58rem !important;
        line-height: 1.3 !important;
        letter-spacing: -0.2px !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
    }
    .terminal-line.cmd-color.font-light,
    .terminal-line.system-log.p3-r1,
    .test-left {
        font-size: 0.58rem !important;
        letter-spacing: -0.2px !important;
    }
    .test-right {
        margin-left: 20px !important;          
        display: inline-flex !important;
        gap: 4px !important;           
    }

    /* Microscopic scaling for the badge image on mobile screens */
    .passed-badge {
        width: 11px !important; 
        height: 11px !important;
    }
}
