/* =============================================
   ARCANE PARTICLE SYSTEM — STYLES
   ============================================= */

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

:root {
  --glass-bg: rgba(8, 4, 20, 0.55);
  --glass-border: rgba(160, 100, 255, 0.25);
  --accent: #c084fc;
  --accent2: #fb923c;
  --text: rgba(230, 210, 255, 0.92);
  --text-dim: rgba(180, 160, 220, 0.6);
  --radius: 14px;
  --blur: blur(18px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
}

/* ── Canvas ── */
#canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ── Webcam (hidden, MediaPipe only) ── */
#webcam {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 200px;
  height: 150px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  opacity: 0.4;
  z-index: 10;
  transform: scaleX(-1); /* mirror */
}

/* ── Gesture HUD (top-center) ── */
#gesture-hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.15);
  transition: all 0.3s ease;
}

#gesture-icon {
  font-size: 1.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--accent));
  transition: all 0.3s ease;
}

#gesture-label {
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.6);
}

/* ── Control Panel (left side) ── */
#control-panel {
  position: fixed;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  z-index: 20;
  width: 230px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow:
    0 0 30px rgba(192, 132, 252, 0.08),
    0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#control-panel.collapsed #panel-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: default;
}

.panel-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

#toggle-panel {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#toggle-panel:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#panel-body {
  max-height: 600px;
  opacity: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-size: 0.74rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
}

.control-group label span {
  color: var(--accent2);
  font-weight: 600;
}

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(160, 100, 255, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}
input[type="range"]:hover {
  background: rgba(160, 100, 255, 0.35);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.7);
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.7);
}

/* Toggle row */
.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle {
  position: absolute;
  inset: 0;
  background: rgba(160, 100, 255, 0.2);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.3s;
  border: 1px solid var(--glass-border);
}
.slider-toggle::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}
.toggle-switch input:checked + .slider-toggle {
  background: rgba(192, 132, 252, 0.35);
  border-color: var(--accent);
}
.toggle-switch input:checked + .slider-toggle::before {
  transform: translateX(16px);
  background: var(--accent);
  box-shadow: 0 0 6px rgba(192, 132, 252, 0.8);
}

/* Reset button */
#reset-btn {
  width: 100%;
  padding: 9px;
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
#reset-btn:hover {
  background: rgba(192, 132, 252, 0.25);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.3);
  transform: translateY(-1px);
}
#reset-btn:active {
  transform: translateY(0);
}

/* ── Gesture Legend (bottom-right) ── */
#gesture-legend {
  position: fixed;
  bottom: 170px;
  right: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 12px 14px;
}

.legend-item {
  font-size: 0.72rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.04em;
}

.legend-item span {
  font-size: 1rem;
  line-height: 1;
}

/* ── Scrollbar hide ── */
::-webkit-scrollbar { display: none; }

/* ── Loading screen ── */
#loading {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.8s ease;
}
#loading.hidden {
  opacity: 0;
  pointer-events: none;
}
#loading p {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: pulse 1.5s ease-in-out infinite;
}
.loading-ring {
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
