/* ============================================================
   Cosmos — Audiovisual Particle & Sound Sandbox
   Minimalist glass HUD over a fullscreen canvas
   ============================================================ */

:root {
  --bg: #04060f;
  --hud-bg: rgba(10, 13, 24, 0.55);
  --hud-border: rgba(148, 163, 214, 0.16);
  --text: #e7ebf7;
  --muted: #8b93ad;
  --accent: #22d3ee;
  --accent-2: #818cf8;
  --glow: 0 0 14px rgba(34, 211, 238, 0.4);
  --radius: 14px;
  --font: "Inter", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
body.tool-cursor #scene { cursor: grab; }
body.tool-erase #scene { cursor: not-allowed; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.glass {
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ---------- top bar ---------- */

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  pointer-events: none;
  z-index: 10;
}
.hud-top > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 14px;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.5);
  white-space: nowrap;
}
.brand-mark { color: var(--accent); }
.brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
}

.presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: color 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.chip:hover {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.5);
}
.chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.85), rgba(129, 140, 248, 0.85));
  box-shadow: var(--glow);
}
.chip-ico { font-size: 14px; line-height: 1; }

/* ---------- tool palette ---------- */

.tools {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  z-index: 10;
}

.tool {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.tool:hover {
  color: var(--text);
  background: rgba(148, 163, 214, 0.1);
}
.tool.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.3), rgba(129, 140, 248, 0.3));
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: var(--glow);
}
.tool::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: rgba(8, 10, 18, 0.92);
  border: 1px solid var(--hud-border);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.tool:hover::after { opacity: 1; }

/* ---------- control panel ---------- */

.panel {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 236px;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.panel-toggle {
  align-self: flex-end;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin-bottom: 8px;
  transition: color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.panel-toggle:hover {
  color: var(--accent);
  box-shadow: var(--glow);
}
.panel-toggle:active { transform: rotate(45deg); }

.panel-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel.closed .panel-body { display: none; }

.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl > span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.ctl > span b {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0;
}
.ctl input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
.ctl select {
  width: 100%;
  background: rgba(8, 10, 18, 0.8);
  color: var(--text);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: inherit;
}

.ctl-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.hud-btn {
  border: 1px solid var(--hud-border);
  background: rgba(8, 10, 18, 0.6);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.1s;
}
.hud-btn:hover {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: var(--glow);
  color: #fff;
}
.hud-btn:active { transform: scale(0.97); }
#snapshotBtn { grid-column: 1 / -1; }

/* ---------- hint / status ---------- */

.hint {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  pointer-events: none;
  animation: hintPulse 2.6s ease-in-out infinite;
  transition: opacity 0.6s;
  white-space: nowrap;
}
.hint.gone {
  animation: none;
  opacity: 0;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.35; }
}

.statusline {
  position: fixed;
  bottom: 14px;
  left: 16px;
  z-index: 9;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* ---------- help overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }

.overlay-card {
  width: min(480px, calc(100vw - 40px));
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.overlay-card h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 2px;
}
.overlay-card ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.overlay-card li b { color: var(--text); }
.overlay-card .hud-btn { align-self: flex-start; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .brand-sub { display: none; }
  .chip .chip-name { display: none; }
  .chip { padding: 7px 10px; }
  .presets { max-width: 58vw; justify-content: center; }
  .tools {
    top: auto;
    bottom: 16px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    flex-direction: row;
  }
  .tool::after { display: none; }
  .panel {
    top: auto;
    bottom: 82px;
    right: 12px;
    transform: none;
    width: 212px;
  }
  .hint { bottom: 76px; font-size: 12px; }
  .statusline { left: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; }
  * { transition-duration: 0.001s !important; }
}
