/* SPDX-License-Identifier: MIT */
:root {
  --glass: rgba(10, 14, 34, 0.58);
  --glass-edge: rgba(150, 190, 255, 0.22);
  --ink: #e8eeff;
  --dim: #9fb0d8;
  --gold: #ffd36b;
  --cyan: #74e3ff;
  --on: rgba(116, 227, 255, 0.22);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05060f; color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; cursor: grab; }
#view:active { cursor: grabbing; }

.glass { background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 12px;
  backdrop-filter: blur(10px) saturate(1.3); -webkit-backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35); }

button { font: inherit; color: var(--ink); background: transparent; border: 0; cursor: pointer; border-radius: 8px; }
button:hover { background: rgba(255, 255, 255, 0.08); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
button[aria-pressed="true"] { background: var(--on); color: #fff; }
.icon { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.big { width: 44px; height: 44px; }
.icon.big svg { width: 24px; height: 24px; }
.text { padding: 6px 10px; height: 36px; font-weight: 600; letter-spacing: 0.04em; }
.text.sm { padding: 2px 8px; height: 28px; }
#tour-play .pause { display: none; }
#tour-play[aria-pressed="true"] .pause { display: block; }
#tour-play[aria-pressed="true"] .play { display: none; }
#tour-play svg.play { fill: currentColor; }
#snd .off { display: none; }
#snd[aria-pressed="false"] .off { display: block; }
#snd[aria-pressed="false"] .on { display: none; }

/* the HUD: in the spirit of the cartridge's glass panels */
#hud { position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  padding: 10px 14px 10px; min-width: 210px; font: 12px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  pointer-events: none; }
#hud .brand { font-weight: 800; letter-spacing: 0.22em; color: var(--gold); margin-bottom: 4px; font-size: 11px; }
#hud dl { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; margin: 0; }
#hud dt { color: var(--dim); }
#hud dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#hud .gpu { margin-top: 4px; color: var(--dim); font-size: 10px; text-align: right; }

#topbar { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
#show-hud { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: none; opacity: 0.35; }
#show-hud:hover { opacity: 1; }

#dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 24px); }
#dock .grp { display: flex; align-items: center; gap: 2px; padding: 0 6px; }
#dock .grp + .grp { border-left: 1px solid var(--glass-edge); }
select { font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-edge);
  border-radius: 8px; height: 32px; padding: 0 6px; }
select option { background: #101530; }
.slider { display: inline-flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--dim); margin: 0 4px; }
.slider input { width: 64px; }
@media (max-width: 1180px) { .slider { display: none; } }
input[type="range"] { accent-color: var(--cyan); }
#vol { width: 80px; }
.iters { display: inline-flex; align-items: center; gap: 2px; font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--dim); }
#it-mul { min-width: 38px; text-align: center; }

#caption { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: 86px; max-width: min(560px, calc(100vw - 32px));
  padding: 14px 18px 12px; border-radius: 14px; background: linear-gradient(180deg, rgba(8, 10, 28, 0.72), rgba(8, 10, 28, 0.5));
  border: 1px solid var(--glass-edge); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(10px); transition: opacity 0.9s ease, transform 0.9s ease; pointer-events: none; }
#caption.on { opacity: 1; transform: none; }
#caption .kind { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--cyan); letter-spacing: 0.08em; text-transform: uppercase; }
#caption h2 { margin: 2px 0 6px; font-size: 22px; font-weight: 700; color: var(--gold); letter-spacing: 0.01em; }
#caption p { margin: 0; color: #dfe6ff; font-size: 14.5px; line-height: 1.5; }

.panel { position: fixed; right: max(12px, env(safe-area-inset-right)); top: 60px; width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 170px); overflow: auto; padding: 14px 16px; }
.phead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.phead h3 { margin: 0; font-size: 16px; color: var(--gold); }
.phead span { color: var(--dim); font-size: 12px; }
#stop-list { list-style: none; margin: 0; padding: 0; }
#stop-list button { width: 100%; display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: baseline; text-align: left; padding: 7px 8px; }
#stop-list .n { color: var(--dim); font: 12px ui-monospace, Menlo, monospace; }
#stop-list .z { color: var(--dim); font: 11px ui-monospace, Menlo, monospace; }
#stop-list li.cur button { background: var(--on); }
#help p { color: #d5ddf5; }
#help table { border-collapse: collapse; width: 100%; font-size: 13px; }
#help td { padding: 3px 4px; vertical-align: top; }
#help td:first-child { color: var(--cyan); font: 12px ui-monospace, Menlo, monospace; white-space: nowrap; padding-right: 12px; }
#help .small { font-size: 12px; color: var(--dim); }
#help a { color: var(--cyan); }

#julia-box { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: 86px; width: 220px; padding: 6px; }
#julia-box canvas { width: 206px; height: 206px; display: block; border-radius: 8px; }
#julia-box .lbl { font-size: 10px; color: var(--dim); text-align: center; margin-top: 3px; }
#fatal { position: fixed; inset: 30% 10% auto; padding: 20px; text-align: center; }

/* the sound hint: shown until the music is actually heard (or when it failed) */
#snd-hint { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; font-weight: 600; z-index: 5;
  animation: snd-pulse 2.4s ease-in-out infinite; }
#snd-hint[hidden] { display: none; }
#snd-hint svg { width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#snd-hint[data-state="error"] { animation: none; border-color: rgba(255, 120, 120, 0.6); }
#snd-hint[data-state="error"] svg { stroke: #ff8a8a; }
#snd[data-state="waiting"], #snd[data-state="starting"] { color: var(--gold); }
#snd[data-state="error"] { color: #ff8a8a; }
@keyframes snd-pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 211, 107, 0.18), 0 6px 30px rgba(0, 0, 0, 0.35); } }
@media (prefers-reduced-motion: reduce) { #snd-hint { animation: none; } }

#hud, #topbar, #dock { transition: opacity 0.8s ease; }
body.idle #topbar, body.idle #dock, body.idle #hud { opacity: 0; pointer-events: none; }
body.idle #view { cursor: none; }
body.bare #hud, body.bare #topbar, body.bare #dock, body.bare #stops, body.bare #help, body.bare #julia-box { display: none; }
body.bare #show-hud { display: inline-grid; }

@media (max-width: 760px) {
  #hud { min-width: 0; font-size: 11px; padding: 8px 10px; }
  #hud dl dt:nth-of-type(n+4), #hud dl dd:nth-of-type(n+4) { display: none; }
  #dock { gap: 2px; padding: 4px; bottom: max(8px, env(safe-area-inset-bottom)); }
  #dock .grp { padding: 0 2px; }
  #dock .grp + .grp { border-left: 0; }
  .slider, #vol { display: none; }
  #caption { bottom: 128px; left: 12px; right: 12px; max-width: none; padding: 10px 14px; }
  #caption h2 { font-size: 18px; }
  #caption p { font-size: 13px; }
  #julia-box { width: 140px; bottom: 128px; }
  #julia-box canvas { width: 126px; height: 126px; }
}
@media (prefers-reduced-motion: reduce) { #caption { transition: none; } }
