/* ═══════════════════════════════════════════════════════════
   CPU Simulator — Explainer / Watch Mode Styles
   Cinematic dark aesthetic. Core Dump inspired.
═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────
   WATCH MODE ROOT
   When body.watch-mode is active, hide the
   normal app layout and show the explainer.
───────────────────────────────────────── */

body.watch-mode .app-main,
body.watch-mode .control-bar,
body.watch-mode .instruction-panel,
body.watch-mode #breadboard-root {
  display: none !important;
}

/* ─────────────────────────────────────────
   EXPLAINER CONTAINER
───────────────────────────────────────── */

#explainer-root {
  display: none;
  position: fixed;
  inset: 0;
  top: 52px; /* below header */
  background: #06090f;
  flex-direction: column;
  z-index: 800;
}

body.watch-mode #explainer-root {
  display: flex;
}

/* ─────────────────────────────────────────
   CANVAS STAGE
───────────────────────────────────────── */

#explainer-canvas-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #06090f;
  cursor: default;
}

#explainer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Click-to-advance ripple hint */
#explainer-canvas-wrap.awaiting-click {
  cursor: pointer;
}

#explainer-click-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.08em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

#explainer-canvas-wrap.awaiting-click #explainer-click-hint {
  opacity: 1;
  animation: hint-pulse 2s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%,100% { opacity: 0.45; }
  50%      { opacity: 0.9; }
}

/* ─────────────────────────────────────────
   CONTROLS BAR (bottom)
───────────────────────────────────────── */

#explainer-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: linear-gradient(0deg, rgba(6,9,15,0.98) 0%, rgba(6,9,15,0.85) 80%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 20px 12px;
  gap: 8px;
  z-index: 10;
  transition: opacity 0.4s ease;
}

#explainer-controls.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Progress bar */
#explainer-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 20px;
}

#explainer-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

#explainer-progress-bar:hover {
  height: 5px;
}

#explainer-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4488ff, #00ddff);
  border-radius: 2px;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* Chapter markers on progress bar */
.explainer-chapter-mark {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: 1.5px solid rgba(255,255,255,0.6);
  pointer-events: none;
  transition: background 0.2s;
}

.explainer-chapter-mark.passed {
  background: #4488ff;
  border-color: #4488ff;
}

#explainer-time-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  min-width: 38px;
  text-align: right;
}

/* Buttons row */
#explainer-btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
}

/* Play / Pause */
#explainer-btn-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

#explainer-btn-play:hover {
  background: rgba(68, 136, 255, 0.25);
  border-color: #4488ff;
  transform: scale(1.08);
}

#explainer-btn-play:active {
  transform: scale(0.95);
}

/* Step buttons */
.explainer-step-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.explainer-step-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.35);
}

/* Spacer */
#explainer-btn-spacer {
  flex: 1;
}

/* Episode selector */
#explainer-episode-select {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  height: 30px;
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

#explainer-episode-select:hover {
  border-color: rgba(68,136,255,0.6);
}

/* Speed control */
#explainer-speed-select {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  height: 30px;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  min-width: 62px;
}

#explainer-speed-select:hover {
  border-color: rgba(68,136,255,0.6);
}

/* Chapter label tooltip */
#explainer-chapter-label {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Narration toggle */
#explainer-btn-narration {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}

#explainer-btn-narration:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
}

#explainer-btn-narration.active {
  background: rgba(68,136,255,0.2);
  border-color: #4488ff;
  color: #79b8ff;
}

/* Fullscreen */
#explainer-btn-fullscreen {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  padding: 0;
}

#explainer-btn-fullscreen:hover {
  background: rgba(255,255,255,0.12);
}

/* Close button */
#explainer-btn-close {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,80,80,0.35);
  background: rgba(255,80,80,0.08);
  color: rgba(255,130,130,0.85);
  font-size: 12px;
  cursor: pointer;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

#explainer-btn-close:hover {
  background: rgba(255,80,80,0.18);
  border-color: rgba(255,80,80,0.6);
}

/* ─────────────────────────────────────────
   SCENE LOADING INDICATOR
───────────────────────────────────────── */

#explainer-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #06090f;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#explainer-loader.visible {
  opacity: 1;
  pointer-events: all;
}

.explainer-loader-dots {
  display: flex;
  gap: 8px;
}

.explainer-loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4488ff;
  animation: loader-bounce 1.2s ease-in-out infinite;
}

.explainer-loader-dot:nth-child(2) { animation-delay: 0.2s; }
.explainer-loader-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loader-bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40%         { transform: translateY(-10px); opacity: 1; }
}

/* ─────────────────────────────────────────
   MOBILE RESPONSIVE
───────────────────────────────────────── */

@media (max-width: 700px) {
  #explainer-root {
    top: 40px; /* thinner header on mobile */
  }

  #explainer-controls {
    padding: 0 8px 6px;
    gap: 6px;
  }

  #explainer-chapter-label,
  #explainer-btn-narration {
    display: none;
  }

  #explainer-btn-play {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .explainer-ctrl-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  #explainer-progress-bar {
    height: 4px;
  }

  #explainer-time-label {
    font-size: 10px;
  }

  #explainer-speed-select {
    font-size: 11px;
    padding: 2px 4px;
  }
}
