/* ═══════════════════════════════════════════════════════════════════
 * KNOX UI KIT — kit-orb.css
 * The Knox avatar orb: breathing core, counter-rotating orbital arcs,
 * canvas particle swarm (kit-orb.js), halo, hover flare, and
 * idle / thinking / alert states.
 *
 * Everything animates via transform/opacity only — compositor cheap.
 * Colors come from the ambient --accent-* theme vars, so the orb
 * re-skins itself per data-knox-theme like every other component.
 * ═══════════════════════════════════════════════════════════════════ */

.knox-orb {
  --orb-size: 96px;
  /* State-tunable knobs (JS reads --orb-particle-speed for canvas) */
  --orb-breathe-dur: 4.6s;
  --orb-ring1-dur: 14s;
  --orb-ring2-dur: 22s;
  --orb-ring3-dur: 36s;
  --orb-c1: var(--accent-1);
  --orb-c2: var(--accent-2);
  --orb-c3: var(--accent-3);
  --orb-glow: var(--glow);
  --orb-glow-soft: var(--glow-soft);
  --orb-particle-speed: 1;

  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Halo — slow ambient pulse behind everything ─────────────────── */
.knox-orb .orb-halo {
  position: absolute;
  inset: calc(var(--orb-size) * -0.38);
  border-radius: 50%;
  background: radial-gradient(circle,
    var(--orb-glow-soft) 0%,
    var(--glow-faint) 45%,
    transparent 70%);
  animation: orb-halo calc(var(--orb-breathe-dur) * 1.6) ease-in-out infinite;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
@keyframes orb-halo {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.16); }
}

/* ── Particle canvas (drawn by kit-orb.js) ───────────────────────── */
.knox-orb .orb-particles {
  position: absolute;
  inset: calc(var(--orb-size) * -0.42);
  width: calc(var(--orb-size) * 1.84);
  height: calc(var(--orb-size) * 1.84);
  max-width: none;
  pointer-events: none;
}

/* ── Orbital arc rings — counter-rotating comet trails ───────────── */
.knox-orb .orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.4px solid transparent;
  pointer-events: none;
  will-change: transform;
}
.knox-orb .orb-ring-1 {
  inset: calc(var(--orb-size) * -0.10);
  border-top-color: var(--orb-c1);
  border-right-color: color-mix(in srgb, var(--orb-c1) 25%, transparent);
  animation: orb-spin var(--orb-ring1-dur) linear infinite;
  filter: drop-shadow(0 0 4px var(--orb-glow-soft));
}
.knox-orb .orb-ring-2 {
  inset: calc(var(--orb-size) * -0.22);
  border-bottom-color: var(--orb-c3);
  border-left-color: color-mix(in srgb, var(--orb-c3) 22%, transparent);
  animation: orb-spin var(--orb-ring2-dur) linear infinite reverse;
  opacity: 0.85;
}
.knox-orb .orb-ring-3 {
  inset: calc(var(--orb-size) * -0.30);
  border: 1px solid color-mix(in srgb, var(--orb-c1) 14%, transparent);
  border-top-color: color-mix(in srgb, var(--orb-c2) 45%, transparent);
  animation: orb-spin var(--orb-ring3-dur) linear infinite;
  opacity: 0.7;
}
@keyframes orb-spin { to { transform: rotate(360deg); } }

/* ── Core — layered breathing sphere ─────────────────────────────── */
.knox-orb .orb-core {
  position: absolute;
  inset: calc(var(--orb-size) * 0.14);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%,
      rgba(255, 255, 255, 0.85) 0%,
      var(--orb-c3) 12%,
      var(--orb-c1) 42%,
      var(--orb-c2) 68%,
      #0b0710 100%);
  box-shadow:
    0 0 calc(var(--orb-size) * 0.28) var(--orb-glow),
    0 0 calc(var(--orb-size) * 0.55) var(--orb-glow-soft),
    inset 0 0 calc(var(--orb-size) * 0.14) rgba(0, 0, 0, 0.55);
  animation: orb-breathe var(--orb-breathe-dur) ease-in-out infinite;
  will-change: transform;
  transition: box-shadow 0.45s ease;
}
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.055); }
}

/* Inner nucleus shimmer — second rhythm so it feels alive */
.knox-orb .orb-core::after {
  content: '';
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 40%,
    rgba(255, 255, 255, 0.55) 0%,
    color-mix(in srgb, var(--orb-c3) 55%, transparent) 40%,
    transparent 75%);
  animation: orb-nucleus calc(var(--orb-breathe-dur) * 0.62) ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes orb-nucleus {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50%      { opacity: 1;    transform: scale(1.10); }
}

/* Specular glint sweep — rare, subtle */
.knox-orb .orb-glint {
  position: absolute;
  inset: calc(var(--orb-size) * 0.14);
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: screen;
}
.knox-orb .orb-glint::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -80%;
  width: 55%;
  height: 160%;
  transform: rotate(24deg) translateX(0);
  background: linear-gradient(90deg,
    transparent 0%, rgba(255, 255, 255, 0.28) 50%, transparent 100%);
  animation: orb-glint 9s ease-in-out infinite;
}
@keyframes orb-glint {
  0%, 74%  { transform: rotate(24deg) translateX(-60%); opacity: 0; }
  80%      { opacity: 1; }
  92%, 100% { transform: rotate(24deg) translateX(420%); opacity: 0; }
}

/* ── Label (optional, Cinzel) ────────────────────────────────────── */
.knox-orb .orb-label {
  position: absolute;
  top: calc(100% + var(--orb-size) * 0.30);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: calc(var(--orb-size) * 0.15);
  font-weight: 700;
  letter-spacing: 0.42em;
  padding-left: 0.42em; /* optically re-centre the tracking */
  text-transform: uppercase;
  white-space: nowrap;
  background: linear-gradient(100deg, #ffffff 0%, var(--orb-c3) 55%, var(--orb-c1) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 14px var(--orb-glow-soft));
}

/* ── Hover flare ─────────────────────────────────────────────────── */
.knox-orb:hover .orb-halo { opacity: 1; transform: scale(1.28); animation-play-state: paused; }
.knox-orb:hover .orb-core {
  box-shadow:
    0 0 calc(var(--orb-size) * 0.42) var(--orb-glow),
    0 0 calc(var(--orb-size) * 0.85) var(--orb-glow-soft),
    inset 0 0 calc(var(--orb-size) * 0.14) rgba(0, 0, 0, 0.55);
}

/* ── States ──────────────────────────────────────────────────────── */
/* thinking: everything quickens — double-time breathe, fast rings   */
.knox-orb[data-state="thinking"] {
  --orb-breathe-dur: 1.6s;
  --orb-ring1-dur: 4.5s;
  --orb-ring2-dur: 7s;
  --orb-ring3-dur: 12s;
  --orb-particle-speed: 2.6;
}
/* alert: red tinge + urgent pulse                                    */
.knox-orb[data-state="alert"] {
  --orb-c1: #ff4757;
  --orb-c2: #c2273a;
  --orb-c3: #ff8a94;
  --orb-glow: rgba(255, 71, 87, 0.6);
  --orb-glow-soft: rgba(255, 71, 87, 0.2);
  --orb-breathe-dur: 1.1s;
  --orb-ring1-dur: 3.5s;
  --orb-ring2-dur: 5.5s;
  --orb-ring3-dur: 9s;
  --orb-particle-speed: 3.2;
}

@media (prefers-reduced-motion: reduce) {
  .knox-orb .orb-halo,
  .knox-orb .orb-ring,
  .knox-orb .orb-core,
  .knox-orb .orb-core::after,
  .knox-orb .orb-glint::before { animation: none !important; }
}
