/*
 * a right-side settings column, dChrono-style: a fixed vertical strip
 * that scrolls internally (rather than the panels wrapping sideways)
 * once the stacked panels are taller than the viewport.
 */
.debug-palette {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
}
.debug-palette .panel {
  --button-min: 4.5em;
  width: 180px;
  flex-shrink: 0;
}

/* Debug is a single-height full-width bar; the row below it is
   double-height, same band regardless of its column count — see
   dPanel's --button-height (and why --ar: auto has to go with it). */
.debug-palette .group-master {
  --button-height: 20px;
  --ar: auto;
}
.debug-palette .group-secondary {
  --button-height: 40px;
  --ar: auto;
}

/* dPanel's .group itself carries the rounded corners (buttons have
   none of their own — see dpanel-buttons.css) via border-radius +
   overflow:hidden. Only the true outer edges of the whole button
   stack should round: Debug's top corners always, and its bottom
   corners too but only when it's the only row showing (Debug off) —
   once the secondary row appears below it, that row's own bottom
   corners take over instead and the seam between them stays square. */
.debug-palette .group-master {
  border-radius: 6px;
}
body.debug .debug-palette .group-master {
  border-radius: 6px 6px 0 0;
}
.debug-palette .group-secondary {
  border-radius: 0 0 6px 6px;
}

/* the secondary button row (Run/Mouse/Rotation, Edit/Z-Depth/Reset)
   and the Edit panel only appear once Debug is toggled on — Debug
   alone is the one thing that's always visible, as its own
   full-width row. The button row needs its display value kept as
   grid (dPanel's .group is a grid), the panel as block. */
.debug-palette .panel.logo-controls,
.debug-palette .group.logo-controls {
  display: none;
}
body.debug .debug-palette .panel.logo-controls {
  display: block;
}
body.debug .debug-palette .group.logo-controls {
  display: grid;
}

/* Edit can additionally be hidden via its own [data-panel-toggle]
   button; this state isn't persisted to the hash */
body.debug .debug-palette .panel.logo-controls.panel-hidden {
  display: none;
}

/* MouseContext and Rotation are different: their visibility is
   hash-driven (#mouse, #rotation — see syncHash()/applyHashState())
   and independent of Debug entirely, so a shared link can show just
   these live readouts without the debug palette's buttons */
.debug-palette #panel-mousecontext,
.debug-palette #panel-rotation {
  display: none;
}
body.mouse-panel .debug-palette #panel-mousecontext {
  display: block;
}
body.rotation-panel .debug-palette #panel-rotation {
  display: block;
}

/* while Debug is off, the Debug panel itself (button + LED) fades
   out entirely shortly after appearing rather than sitting fully
   opaque over the logo, and comes back on hover — scoped to just
   that panel, not the whole palette, so Mouse/Rotation stay fully
   visible on their own even after Debug has faded away */
body:not(.debug) .debug-palette #panel-debug {
  animation: debug-palette-idle 0.4s ease-in 0.6s forwards;
}
body:not(.debug) .debug-palette #panel-debug:hover {
  animation: none;
  opacity: 1;
}
@keyframes debug-palette-idle {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* a plain caption for a control within a panel's body — distinct from
   dPanel's glowing .vfd readouts, so it doesn't compete with them for
   boldness/glow; this is just a quiet Montserrat label above a fader */
.panel .field-label {
  color: #ffffff;
  font-family: Montserrat, sans-serif;
  font-size: 10px;
  margin: 0.5em 0 0.15em;
}
.panel .field-label:first-child {
  margin-top: 0;
}

.panel > header .header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel > header .led {
  margin: 0;
}

/* the palette is all controls; without JS none of them work, so it
   stays hidden until index.js marks the page with .logo-js */
html:not(.logo-js) .debug-palette {
  display: none;
}

/* a button row that is its own panel body (Disassemble), not stacked
   under a Debug row, rounds on every corner */
.debug-palette .group-alone {
  border-radius: 6px;
}

/* Play and Replay sit with the seed they play, shown by Seed */
.debug-palette .seed-actions {
  margin-top: 6px;
}

/* Seed: a VFD readout that takes typing. The browser's caret is hidden in
   favour of a blinking block at the end of the digits, where typing goes
   (debug.js keeps it there). */
.seed-field {
  min-height: 1.2em;
  cursor: text;
}
.seed-input {
  outline: none;
  caret-color: transparent;
  white-space: nowrap;
  -webkit-user-select: text;
  user-select: text;
}
.seed-field:focus-within::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.85em;
  margin-left: 0.1em;
  vertical-align: -0.05em;
  background-color: currentColor;
  box-shadow: 0 0 4px currentColor;
  animation: seed-cursor 1s steps(1) infinite;
}
@keyframes seed-cursor {
  50% {
    opacity: 0;
  }
}
