/* Physics Type */

:root {
  --font-body:    'Space Grotesk', system-ui, sans-serif;
  --font-display: 'Unbounded', system-ui, sans-serif;
  --glow: rgba(139, 92, 246, 0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--slate);
  color: var(--cloud);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── SKIP + HEADER ───────────────────────────────────────── */

.skip-link {
  position: absolute; top: -4rem; left: 1rem;
  background: var(--violet); color: var(--cloud);
  padding: 0.5rem 1rem; border-radius: 0 0 0.5rem 0.5rem;
  font-size: 0.875rem; text-decoration: none; z-index: 200;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--slate-raised);
  gap: 1rem;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8rem; }
.back-link { color: var(--violet-muted); text-decoration: none; transition: color 0.15s; }
.back-link:hover { color: var(--cloud); }
.brand-sep { color: var(--slate-raised); }
.brand-name { color: var(--violet-bright); font-weight: 600; }

.header-actions { display: flex; gap: 0.5rem; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--slate-raised);
  color: var(--violet-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 0.5rem;
  font: 500 0.78rem var(--font-body);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--violet); color: var(--cloud); }

/* ── MAIN LAYOUT ─────────────────────────────────────────── */

.main-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-width: 0;
  cursor: crosshair;
  overflow: hidden;
}

#canvas-wrap canvas { display: block; }

/* ── CONTROLS PANEL ──────────────────────────────────────── */

.controls-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--slate-panel);
  border-left: 1px solid var(--slate-raised);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.ctrl-group { display: flex; flex-direction: column; gap: 0.35rem; }

.panel-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--violet-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.val-badge { color: var(--violet-bright); font-size: 0.7rem; font-weight: 500; }

.panel-divider {
  height: 1px;
  background: var(--slate-raised);
  margin: 0.25rem 0;
}

.text-input {
  background: var(--slate-raised);
  border: 1px solid var(--slate-raised);
  color: var(--cloud);
  font: 500 0.875rem var(--font-body);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  width: 100%;
  transition: border-color 0.15s;
  letter-spacing: 0.05em;
}
.text-input:hover { border-color: var(--violet-deep); }
.text-input:focus { outline: 2px solid var(--cyan); outline-offset: 2px; border-color: transparent; }

.ctrl-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 0.3rem;
  background: var(--slate-raised);
  border-radius: 999px; cursor: pointer; margin-top: 0.3rem;
}
.ctrl-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--violet); border: 2px solid var(--cloud);
}
.ctrl-range::-moz-range-thumb {
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: var(--violet); border: 2px solid var(--cloud);
}

/* ── MATERIAL PRESETS ────────────────────────────────────── */

.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.preset-btn {
  background: var(--slate-raised);
  border: 1px solid transparent;
  color: var(--violet-muted);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font: 500 0.7rem var(--font-body);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.preset-btn:hover { border-color: var(--violet); color: var(--cloud); }
.preset-btn.is-active {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--violet);
  color: var(--violet-bright);
}

/* ── MAGNETISM TOGGLE ────────────────────────────────────── */

.mag-group {
  display: flex;
  margin-top: 0.2rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--slate-raised);
}

.mag-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--slate-raised);
  color: var(--violet-muted);
  padding: 0.4rem 0;
  font: 500 0.7rem var(--font-body);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mag-btn:last-child { border-right: none; }
.mag-btn:hover { background: var(--slate-raised); color: var(--cloud); }
.mag-btn.is-active {
  background: rgba(139, 92, 246, 0.2);
  color: var(--violet-bright);
}
.mag-btn[data-mag="repel"].is-active {
  background: rgba(52, 224, 232, 0.15);
  color: var(--cyan);
}

/* ── MINI TOGGLE (bumpers) ───────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.mini-toggle { flex-shrink: 0; }

.mini-toggle input[type="checkbox"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.mini-track {
  display: block;
  width: 28px; height: 16px;
  background: var(--slate-raised);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.mini-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--violet-muted);
  transition: transform 0.2s, background 0.2s;
}
.mini-toggle input:checked + .mini-track { background: var(--violet); }
.mini-toggle input:checked + .mini-track::after {
  transform: translateX(12px);
  background: var(--cloud);
}
.mini-toggle input:focus-visible + .mini-track {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ── HINT ────────────────────────────────────────────────── */

.hint {
  font-size: 0.68rem;
  color: var(--violet-muted);
  line-height: 1.55;
}

/* ── FOOTER ──────────────────────────────────────────────── */

.site-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--slate-raised);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.site-footer a { color: var(--violet-muted); text-decoration: none; transition: color 0.15s; }
.site-footer a:hover { color: var(--cloud); }

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

@media (max-width: 700px) {
  .main-layout { flex-direction: column; }
  .controls-panel {
    width: 100%; border-left: none; border-top: 1px solid var(--slate-raised);
    flex-direction: row; flex-wrap: wrap; padding: 1rem; gap: 0.75rem;
  }
  .ctrl-group { min-width: 140px; flex: 1; }
  .panel-divider { display: none; }
  .site-header { padding: 0.9rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
