@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Fira+Code:wght@400;600&display=swap');

:root {
  --bg-color: #0f172a; /* Slate 900 */
  --bg-gradient: radial-gradient(circle at top right, #1e293b, #0f172a);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-gps: #10b981; /* Emerald */
  --accent-dr: #f59e0b;  /* Amber */
  --accent-ekf: #3b82f6; /* Blue */
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

/* Content Panel */
.content-panel {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

p {
  margin-bottom: 1rem;
  color: #cbd5e1;
}

.highlight {
  color: #38bdf8;
  font-weight: 600;
}

.math {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  color: #f1f5f9;
}

/* Simulation Panel */
.simulation-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

canvas {
  width: 100%;
  height: 400px;
  background: #000;
  border-radius: 1rem;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}

.legend {
  display: flex;
  justify-content: space-around;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot.gt { background: #fff; }
.dot.dr { background: var(--accent-dr); }
.dot.gps { background: var(--accent-gps); }
.dot.ekf { background: var(--accent-ekf); box-shadow: 0 0 10px var(--accent-ekf); }

/* Real-time Math Display */
.live-math {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 0.75rem;
  padding: 1rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.matrix-display {
  border-collapse: collapse;
  margin-top: 0.5rem;
  color: #a7f3d0;
}
.matrix-display td {
  padding: 0.2rem 0.6rem;
  text-align: right;
  border-left: 1px solid rgba(255,255,255,0.1);
  border-right: 1px solid rgba(255,255,255,0.1);
}
.matrix-display tr:first-child td {
  border-top: 1px solid rgba(255,255,255,0.1);
}
.matrix-display tr:last-child td {
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

button {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

button:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

button:active {
  transform: scale(0.95);
}

/* Analogies box */
.analogy-box {
  border-left: 4px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
  padding: 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  margin: 1rem 0;
}

/* SVG styles */
.diagram-svg {
  width: 100%;
  max-width: 400px;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

/* Step-by-step buttons */
.step-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.step-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}
#btnStepUpdate {
  background: linear-gradient(135deg, #10b981, #059669);
}
#btnStepUpdate:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
}
.secondary-btn {
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
}
.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Math box for live numerical tracking */
.math-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.75rem;
  border-radius: 0.5rem;
  transition: background-color 0.3s;
}
.math-title {
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
}
.highlight-flash {
  animation: flashBg 0.5s ease-out;
}
@keyframes flashBg {
  0% { background-color: rgba(250, 204, 21, 0.3); }
  100% { background-color: rgba(255, 255, 255, 0.03); }
}
