/* 
  mergesort-style.css
  Minimalist Light-Theme Design System for Full-Screen 3D Merge Sort Simulator
  Left Sidebar (Operations & Array Generator), Right Sidebar (1D Array & Algorithm Trace), Center (3D Arena)
*/

:root {
  --bg-canvas: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-subtle: rgba(226, 232, 240, 0.9);
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-cyan: #06b6d4;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.11);
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: 'DM Sans', 'Lexend', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Fullscreen 3D Viewport */
#viewport-container {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #f1f5f9 100%);
}

#three-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
  outline: none;
  cursor: grab;
}

#three-canvas:active {
  cursor: grabbing;
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  border-radius: 18px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-lg);
}

/* In-Canvas Floating Sidebars Layout */
.hud-sidebar-left {
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 16px;
  width: 320px;
  max-width: calc(50vw - 24px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 25;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.hud-sidebar-right {
  position: absolute;
  top: 16px;
  bottom: 16px;
  right: 16px;
  width: 330px;
  max-width: calc(50vw - 24px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 25;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

/* Top Center Floating Strip */
.hud-center-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 30;
  width: max-content;
  max-width: calc(100vw - 680px);
}

/* Allow interactive HUD components to receive clicks and prevent dragging canvas */
.hud-interactive {
  pointer-events: auto !important;
  user-select: none;
}

/* Bottom Center Floating Hint */
.hud-center-bottom {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  white-space: nowrap;
}

/* 3D Character Speech / Status Bubble */
.character-speech-bubble {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  padding: 8px 20px;
  border-radius: 9999px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 620px;
  text-align: center;
}

.character-speech-bubble.active {
  opacity: 1;
  transform: translateY(0);
}

.character-speech-bubble .bot-icon-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0284c7;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* Camera Bar Buttons */
.cam-btn {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9999px;
  color: var(--text-muted);
  cursor: pointer !important;
  pointer-events: auto !important;
  transition: all 0.2s ease;
  user-select: none;
}

.cam-btn:hover {
  color: var(--text-main);
  background: rgba(241, 245, 249, 0.9);
}

.cam-btn.active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

#toggle-fullscreen, #toggle-sfx {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Minimalist Button System */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.btn-action:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.25);
}
.btn-primary:hover:not(:disabled) {
  background: #0369a1;
  box-shadow: 0 5px 14px rgba(2, 132, 199, 0.35);
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}
.btn-success:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 5px 14px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}
.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

/* 1D Memory Array Visualization for Merge Sort */
.array-strip {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
  overflow-x: auto;
  padding: 6px 2px 14px 2px;
}

.array-bar-card {
  flex: 1;
  min-width: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bar-box {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  position: relative;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.bar-box.comparing {
  border-color: #f59e0b !important;
  background: #fef3c7 !important;
  color: #b45309 !important;
  transform: translateY(-4px);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.bar-box.active-sub {
  border-color: #38bdf8;
  background: #f0f9ff;
}

.bar-box.sorted {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
}

.bar-pointer {
  font-size: 9px;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  height: 14px;
  line-height: 14px;
}

.bar-index {
  font-size: 10px;
  font-family: 'Fira Code', monospace;
  color: #94a3b8;
}

/* Auxiliary / Temp Array slots */
.temp-array-strip {
  display: flex;
  gap: 5px;
  width: 100%;
  overflow-x: auto;
  padding: 4px 0;
}

.temp-slot {
  flex: 1;
  height: 32px;
  border-radius: 6px;
  border: 1.5px dashed #cbd5e1;
  background: rgba(248, 250, 252, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  transition: all 0.2s ease;
}

.temp-slot.filled {
  border-style: solid;
  border-color: #0284c7;
  background: #e0f2fe;
  color: #0369a1;
}

/* Pseudocode block & live line highlighting */
.code-container {
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.45;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  overflow-x: auto;
}

.code-line {
  display: block;
  padding: 1px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.code-line.active-line {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  font-weight: 600;
  border-left: 3px solid #38bdf8;
  padding-left: 8px;
}

/* Log Item Entries */
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  font-size: 11px;
}

.tag-divide {
  background: #f0f9ff;
  color: #0369a1;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

.tag-compare {
  background: #fef3c7;
  color: #b45309;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

.tag-merge {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
