/* 
  Minimalist Light-Theme Design System for 3D Stack Simulator
  Colors: Clean porcelain, subtle slate borders, pastel accents
*/

:root {
  --bg-canvas: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-subtle: #e2e8f0;
  --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;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 24px rgba(59, 130, 246, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: 'DM Sans', 'Lexend', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background architectural grid */
.bg-grid-pattern {
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(148, 163, 184, 0.18) 1px, transparent 0);
  background-size: 28px 28px;
}

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

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

/* Floating 3D canvas viewport container */
#viewport-container {
  position: relative;
  width: 100%;
  height: 520px;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 1024px) {
  #viewport-container {
    height: 580px;
  }
}

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

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

/* 3D Character Speech / Status Bubble */
.character-speech-bubble {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 9999px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 20;
}

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

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

/* Floating Viewport Overlay Toolbar */
.viewport-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  z-index: 10;
}

.cam-btn {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 9999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.cam-btn.active {
  background: #0f172a;
  color: #ffffff;
}

/* Minimalist Button System */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  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-push {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-push:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-pop {
  background: #f43f5e;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}
.btn-pop:hover:not(:disabled) {
  background: #e11d48;
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.35);
}

.btn-peek {
  background: #8b5cf6;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}
.btn-peek:hover:not(:disabled) {
  background: #7c3aed;
  box-shadow: 0 6px 16px rgba(139, 92, 246, 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 */
.memory-array-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 4px;
}

.memory-slot {
  flex: 1;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.memory-box {
  width: 100%;
  height: 52px;
  border-radius: 10px;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  font-size: 15px;
  color: #64748b;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.memory-box.filled {
  border-style: solid;
  border-color: #3b82f6;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.12);
  transform: translateY(-2px);
}

.memory-box.tos {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.memory-box.peeked {
  border-color: #8b5cf6;
  background: #f5f3ff;
  color: #5b21b6;
  animation: pulse-peek 1.2s infinite alternate;
}

@keyframes pulse-peek {
  0% { transform: scale(1); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2); }
  100% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.35); }
}

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

.memory-pointer-tag {
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  color: #10b981;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

.code-line.active-line {
  background: rgba(59, 130, 246, 0.35);
  color: #ffffff;
  border-left: 3px solid #60a5fa;
  font-weight: 600;
}

/* Operation Log */
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  font-size: 12px;
  transition: background 0.15s ease;
}

.log-item:hover {
  background: #f8fafc;
}

.tag-push {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
}

.tag-pop {
  background: #fff1f2;
  color: #9f1239;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
}

.tag-peek {
  background: #f5f3ff;
  color: #5b21b6;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
