/* =========================================================
   LOGIC ISP   Signal buttons
   File: static/css/signal-buttons.css

   One behaviour for every button, link-button and clickable tile:

     HOVER    Only the Wi-Fi signal reacts. Its arcs and dot drop in from
              above, one after another, and rest in the corner. The button
              itself does not change colour, border, shadow or position.
     CLICK    The Wi-Fi signal goes away and rain falls inside the button
              while the action is running (class "is-loading").
     DONE     The rain stops and the button is back to normal.

   The markup (.sb-fx > .sb-wifi + .sb-rain) is added by
   static/js/signal-buttons.js, so templates do not need to change.
   Opt a button out with data-sb="off".

   Tuning knobs (set on :root or on one button):
     --sb-opacity   how strong the Wi-Fi / rain decoration is (default .55)
     --sb-dur       Wi-Fi drop speed (default .22s)
   ========================================================= */

/* The decoration sits BEHIND the label: isolation makes the button its own
   stacking context, so the z-index:-1 layer below stays above the button's
   background but under its text. :where() keeps specificity at zero so a
   page's own rules always win (for example a button that is position:fixed). */
:where(.sb) { isolation: isolate; }
:where(.sb.sb-rel) { position: relative; }

.sb-fx {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--sb-opacity, .55);
}

/* ---------- Wi-Fi signal (hover) ---------- */
.sb-wifi {
  position: absolute;
  right: 10px;
  bottom: -6%;
  height: 92%;
  max-height: 76px;
  aspect-ratio: 1 / 1;
}
.sb-wifi svg { display: block; width: 100%; height: 100%; overflow: visible; }

.sb-wifi path,
.sb-wifi circle {
  opacity: 0;
  transform: translateY(-20px);
}
.sb-wifi path { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; }
.sb-wifi circle { fill: currentColor; }

/* Hover or keyboard focus, but never while loading or disabled. */
.sb:is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]):not(.is-loading) .sb-arc-s {
  animation: sbDrop var(--sb-dur, .22s) ease-out forwards;
}
.sb:is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]):not(.is-loading) .sb-dot {
  animation: sbDrop var(--sb-dur, .22s) ease-out .02s forwards;
}
.sb:is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]):not(.is-loading) .sb-arc-m {
  animation: sbDrop var(--sb-dur, .22s) ease-out .12s forwards;
}
.sb:is(:hover, :focus-visible):not(:disabled):not([aria-disabled="true"]):not(.is-loading) .sb-arc-l {
  animation: sbDrop var(--sb-dur, .22s) ease-out .24s forwards;
}

@keyframes sbDrop {
  0%   { opacity: 0; transform: translateY(-20px); }
  65%  { opacity: 1; transform: translateY(3px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------- Rain (click / loading) ---------- */
.sb-rain { position: absolute; inset: 0; display: none; }
.sb.is-loading .sb-rain { display: block; }

.sb-drop {
  position: absolute;
  top: -15px;
  width: 2px;
  height: 13px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0;
  animation: sbRain .65s linear infinite;
}
@keyframes sbRain {
  0%   { transform: translateY(-10px); opacity: 0; }
  15%  { opacity: .8; }
  85%  { opacity: .8; }
  100% { transform: translateY(var(--sb-fall, 165px)); opacity: 0; }
}

.sb.is-loading { cursor: wait; }

/* Screen-reader announcement ("Processing request"); never visible. */
.sb-live {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The old round spinner some forms used; the rain replaces it. */
.btn-spinner { display: none !important; }

/* ---------- Large clickable tiles (dashboard stat tiles) ---------- */
.stat-tile .sb-fx { color: var(--color-text-muted); opacity: 1; }
.stat-tile .sb-wifi { height: 76px; max-height: none; right: 18px; bottom: -5px; }
.stat-tile .sb-rain { opacity: .45; }

/* ---------- Accessibility and print ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { --sb-dur: .01ms; }
  .sb-drop { animation: none; display: none; }
  /* No falling rain: show the signal glyph, standing still, as the busy marker. */
  .sb.is-loading .sb-wifi path,
  .sb.is-loading .sb-wifi circle { opacity: 1; transform: none; }
}

@media print {
  .sb-fx, .sb-live { display: none !important; }
}
