/* HUD control panel styles for particle trails */

:root {
  --accent: hsl(200, 90%, 62%);
  --glass: rgba(14, 16, 22, 0.74);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e7e9ef;
  --muted: #8b90a0;
}

[hidden] { display: none !important; }

body { overflow: hidden; }

#stage {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- panel ---------- */
#hud {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font: 12px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  user-select: none;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.hud-hidden #hud {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

#hud header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 6px 14px;
}

#hud h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  transition: color 0.5s;
}

#stats {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- buttons ---------- */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.iconbtn:hover { background: rgba(255, 255, 255, 0.13); color: #fff; }
.iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.iconbtn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.iconbtn.small { width: 28px; height: 28px; border-color: transparent; background: none; }
.iconbtn.small svg { width: 15px; height: 15px; }
.iconbtn.active { color: var(--accent); border-color: var(--accent); }
.iconbtn.rec { color: #ff4d5e; border-color: #ff4d5e; animation: pulse 1.2s infinite; }
.textbtn { padding: 0 12px; }

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 6px 12px 10px;
}

.presets {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}
.presets select { flex: 1; max-width: none; height: 34px; }
.presets .iconbtn:not(.textbtn) { width: 34px; flex: none; }

.userbar { align-items: center; margin-top: -4px; }
.userbar span { flex: 1; color: var(--muted); font-size: 11px; }
.userbar .iconbtn { height: 28px; }

/* section lock button (inside the section header) */
.lockbtn {
  display: inline-flex;
  margin: 0 10px 0 auto;
  padding: 3px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.lockbtn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lockbtn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.lockbtn.on { color: var(--accent); }

input[type=text] {
  min-width: 0;
  width: 55%;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  outline: none;
  user-select: text;
}
input[type=text]:focus { border-color: var(--accent); }

/* ---------- sections ---------- */
#hudBody {
  overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

details.section { border-bottom: 1px solid var(--line); }
details.section:last-child { border-bottom: none; }

details.section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cfd3dd;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}
details.section[open] > summary::after { transform: rotate(45deg); }
details.section > summary:hover { color: #fff; }

.section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 12px;
}

/* ---------- rows ---------- */
.row label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #c4c8d2;
}
.row output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.row.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.row.inline label { margin: 0; }

select {
  min-width: 0;
  max-width: 62%;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  outline: none;
  cursor: pointer;
}
select:focus-visible { border-color: var(--accent); }
select option { background: #16181f; color: var(--text); }

input[type=color] {
  -webkit-appearance: none;
  appearance: none;
  width: 46px;
  height: 24px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type=color]::-moz-color-swatch { border: none; border-radius: 4px; }

/* range : the input itself is the track, filled up to --p */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  margin: 6px 0 2px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), rgba(255, 255, 255, 0.14) var(--p, 50%));
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
}
input[type=range]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}
input[type=range]::-moz-range-track { background: transparent; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent); }
input[type=range].hue-track {
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

/* toggle switch */
.switch { cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  position: relative;
  flex: none;
  width: 30px;
  height: 17px;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(13px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); }

/* shortcuts list */
.shortcuts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  color: #c4c8d2;
}
.shortcuts kbd {
  justify-self: start;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  font: 11px/1.4 ui-monospace, Consolas, monospace;
  color: var(--text);
}

/* ---------- floating toggle ---------- */
#hudToggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 11;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: opacity 0.3s, background 0.15s;
}
#hudToggle svg { width: 19px; height: 19px; }
body:not(.hud-hidden) #hudToggle { opacity: 0; pointer-events: none; }
body.hud-hidden.idle #hudToggle { opacity: 0.25; }
body.hud-hidden.idle #hudToggle:hover { opacity: 1; }

/* ---------- presentation mode ---------- */
.presenting #hud,
.presenting #hudToggle { display: none; }
.presenting.idle,
.presenting.idle #stage { cursor: none; }

/* ---------- overlays ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  padding: 8px 16px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text);
  font: 13px system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#flash {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#flash.go { animation: flash 0.45s ease-out; }

#recDot {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  color: #ff4d5e;
  font: 600 12px system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0.05em;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  animation: pulse 1.2s infinite;
  pointer-events: none;
}

@keyframes flash { from { opacity: 0.6; } to { opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.45; } }
