/**
 * The HAL pulse — base class sb-pulse.
 *
 * The module's effect standard: an element wears BOTH the base
 * class and its roster attribute —
 *
 *   <div class="sb-pulse" data-sb-pulse='["is-thinking"]'>
 *
 * — and the activator (sb-effects.js) toggles sb-pulse--active
 * whenever the element carries any class the roster names.
 *
 * THE EFFECT LAW: an effect DECORATES its host; it never becomes
 * it. The base class establishes inert plumbing only — never
 * geometry, never layout — and everything visible renders on a
 * pseudo-element. (This file's first draft made the base class
 * the lamp itself; bound to a block by the effects field, it
 * shrank the block to a 16px orb.)
 *
 * The lamp keeps its original semantic, re-seated: a dark orb in
 * the host's top-right corner that reads as "present but
 * resting", so activation is a lamp lighting rather than an
 * element appearing. Lit, it breathes on one animation while a
 * second walks its color through the logo's inks — the Three
 * Amigos (red #d73647, blue #005a9c, orange #f8991d) and the
 * green underline (#008457) — everything keyed off currentColor
 * so one walk drives core and halo together.
 */

.sb-pulse {
  --sb-pulse-size: 16px;
  position: relative;
}

.sb-pulse::after {
  content: "";
  position: absolute;
  top: var(--sb-pulse-inset, 8px);
  right: var(--sb-pulse-inset, 8px);
  width: var(--sb-pulse-size);
  height: var(--sb-pulse-size);
  border-radius: 50%;
  background: radial-gradient(circle, #334155, #111827);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 1;
}

.sb-pulse--sm { --sb-pulse-size: 10px; }
.sb-pulse--lg { --sb-pulse-size: 28px; }

.sb-pulse--active::after {
  color: #d73647;
  background: radial-gradient(
    circle,
    color-mix(in srgb, currentColor 55%, white),
    currentColor
  );
  box-shadow: none;
  animation:
    sb-pulse-breathe 2s ease-in-out infinite,
    sb-pulse-amigos 8s ease-in-out infinite;
}

/* The breathing glow rides currentColor so it never needs to know
   which brand ink the cycle is wearing this second. */
@keyframes sb-pulse-breathe {
  0%, 100% {
    box-shadow:
      0 0 10px color-mix(in srgb, currentColor 50%, transparent),
      0 0 20px color-mix(in srgb, currentColor 30%, transparent),
      inset 0 0 8px rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow:
      0 0 16px color-mix(in srgb, currentColor 75%, transparent),
      0 0 32px color-mix(in srgb, currentColor 45%, transparent),
      inset 0 0 10px rgba(255, 255, 255, 0.4);
  }
}

/* Red -> blue -> orange -> green, two seconds an ink. */
@keyframes sb-pulse-amigos {
  0%, 100% { color: #d73647; }
  25%      { color: #005a9c; }
  50%      { color: #f8991d; }
  75%      { color: #008457; }
}

/* A vestibular-safe pulse: no throb, just the slow color walk. */
@media (prefers-reduced-motion: reduce) {
  .sb-pulse--active::after {
    animation: sb-pulse-amigos 12s ease-in-out infinite;
    box-shadow: 0 0 10px
      color-mix(in srgb, currentColor 40%, transparent);
  }
}
