/* The floating-button dock: ONE place the round buttons on the right-hand edge live, so they stack and never sit on each other.
 *
 * public/hl-float-dock.js builds #hl-float-dock and moves the buttons into it (Reina's chat button, the Reina bar button, the
 * owner app's hold-to-talk button). The dock is a column that grows upward from the bottom-right corner; a button that is hidden
 * takes no room, so there is never a gap or a button on top of another. A new floating button joins by carrying data-hl-float="N"
 * (N is its place in the stack, 0 at the bottom). Nothing here needs a per-button offset.
 *
 * Numbers set on :root that a page can change:
 *   --hl-float-edge   distance from the right edge and from the bottom
 *   --hl-float-gap    space between two buttons
 *   --hl-float-inset-right  width of a column the page keeps on the right edge (the desk's round tabs), so the panels stay clear of it
 *   --hl-float-btn-right    where the round buttons themselves sit from the right edge; by default the same as the panels
 *   --hl-float-clear  height of the page's own bottom bar (the owner app's tab bar); the dock sits above it
 *   --hl-float-z      stacking level; a page whose sheets must cover the buttons lowers it
 * --hl-float-h is written by the script: the height of the stack. Panels that open from the buttons sit above it.
 */
:root {
  --hl-float-edge: 16px;
  --hl-float-gap: 12px;
  --hl-float-clear: 0px;
  --hl-float-h: 0px;
  --hl-float-base: calc(var(--hl-float-edge) + max(var(--hl-float-clear), var(--rna-lift, 0px)) + env(safe-area-inset-bottom, 0px));
  --hl-float-inset-right: 0px;
  --hl-float-right: calc(var(--hl-float-edge) + var(--hl-float-inset-right) + env(safe-area-inset-right, 0px));
  --hl-float-btn-right: var(--hl-float-right);
  /* Where a panel that opens from the buttons should end: just above the top one. */
  --hl-float-top: calc(var(--hl-float-base) + var(--hl-float-h) + var(--hl-float-gap));
}

#hl-float-dock {
  position: fixed; z-index: var(--hl-float-z, 99990);
  right: var(--hl-float-btn-right); bottom: var(--hl-float-base);
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: var(--hl-float-gap);
  margin: 0; padding: 0; background: none; border: 0;
  pointer-events: none; /* the empty space around the buttons is the page's */
}
#hl-float-dock > * { pointer-events: auto; }
#hl-float-dock > [data-hl-float] {
  position: relative; inset: auto; margin: 0; flex: none;
}
/* The small x that hides the Reina buttons on a phone rides just above the stack and covers none of it. */
#hl-float-dock > #rnaFabHide { position: absolute; inset: auto 2px calc(100% + 8px) auto; }
/* While the Reina bar's sheet is open on a phone, the sheet and its scrim are above the buttons. */
@media (max-width: 640px) {
  #hl-float-dock:has(.rm-fab[aria-expanded="true"]) { z-index: min(var(--hl-float-z, 99990), 45); }
}

/* Panels that open from the buttons: above the stack, on the same right edge, so nothing overlaps. */
html #rnaPanel { right: var(--hl-float-right); bottom: var(--hl-float-top); }
@media (min-width: 641px) {
  html .rm-panel, html .rm-owner.rm-panel { right: var(--hl-float-right); bottom: var(--hl-float-top); max-height: min(640px, calc(100vh - var(--hl-float-top) - 16px)); }
}
html .reina-panel { bottom: var(--hl-float-top); }

@media print { #hl-float-dock { display: none !important; } }
