/* ============================================================
   Inteliora Analyst Beings — motion graphics around PNG portraits
   State machine: idle | thinking | speaking
   Drives from [data-being][data-state] attributes on .being-frame
   ============================================================ */

/* Tint per being (used by halo / rim / particles) */
.being-frame[data-being="argus"]     { --being-hue:  168; --being-c:#3DF2D6; }
.being-frame[data-being="cormorant"] { --being-hue:  205; --being-c:#7FB3E8; }
.being-frame[data-being="ledger"]    { --being-hue:   30; --being-c:#E8B97A; }
.being-frame[data-being="kestrel"]   { --being-hue:   14; --being-c:#F5A28A; }

/* ============================================================
   Frame — outer container that holds the PNG and FX layers
   ============================================================ */
.being-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255,255,255,0.03), transparent 60%),
    linear-gradient(180deg, #0B1116 0%, #06090C 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 40px 80px -40px rgba(0,0,0,0.7);
}

/* The portrait — live video by default (Veo loop); poster PNG as fallback */
.being-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  display: block;
}
.being-portrait--video { background: #06090C; }

/* ============================================================
   FX layers
   ============================================================ */
.being-fx { position: absolute; inset: 0; pointer-events: none; }

/* Halo — coloured glow pulse behind the portrait */
.being-fx--halo {
  z-index: 1;
  background:
    radial-gradient(50% 50% at 50% 55%, hsl(var(--being-hue) 75% 55% / 0.28), transparent 70%),
    radial-gradient(80% 60% at 50% 90%, hsl(var(--being-hue) 65% 40% / 0.18), transparent 80%);
  animation: being-halo 4.6s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes being-halo {
  0%,100% { opacity: 0.55; transform: scale(1); }
  50%     { opacity: 0.95; transform: scale(1.05); }
}

/* Scan — thin bright sweep travelling top → bottom */
.being-fx--scan {
  z-index: 4;
  background: linear-gradient(180deg,
    transparent 0%,
    hsl(var(--being-hue) 90% 70% / 0.08) 45%,
    hsl(var(--being-hue) 95% 80% / 0.22) 50%,
    hsl(var(--being-hue) 90% 70% / 0.08) 55%,
    transparent 100%);
  background-size: 100% 220%;
  background-repeat: no-repeat;
  background-position: 0 -120%;
  mix-blend-mode: screen;
  animation: being-scan 6.2s ease-in-out infinite;
  opacity: 0.85;
}
@keyframes being-scan {
  0%   { background-position: 0 -120%; }
  60%  { background-position: 0 120%; }
  100% { background-position: 0 120%; }
}

/* Noise — cinematic grain */
.being-fx--noise {
  z-index: 5;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 140px 140px;
  animation: being-noise 1.6s steps(2) infinite;
}
@keyframes being-noise {
  0% { background-position: 0 0; }
  100% { background-position: -70px 40px; }
}

/* Rim light — bright inner edge on hover / speaking */
.being-fx--rim {
  z-index: 6;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px hsl(var(--being-hue) 90% 65% / 0.22),
    inset 0 0 40px hsl(var(--being-hue) 90% 55% / 0.12);
  opacity: 0.85;
  transition: box-shadow 0.35s ease, opacity 0.35s ease;
}

/* Particles — 6 slow-rising dots */
.being-fx--particles { z-index: 3; }
.being-fx--particles span {
  position: absolute;
  bottom: -8px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: hsl(var(--being-hue) 90% 70% / 0.85);
  box-shadow: 0 0 6px hsl(var(--being-hue) 90% 65% / 0.6);
  opacity: 0;
  animation: being-particle 7s linear infinite;
}
.being-fx--particles span:nth-child(1) { left:  8%; animation-delay: 0s; }
.being-fx--particles span:nth-child(2) { left: 22%; animation-delay: 1.1s; }
.being-fx--particles span:nth-child(3) { left: 41%; animation-delay: 2.4s; }
.being-fx--particles span:nth-child(4) { left: 58%; animation-delay: 0.6s; }
.being-fx--particles span:nth-child(5) { left: 76%; animation-delay: 3.2s; }
.being-fx--particles span:nth-child(6) { left: 90%; animation-delay: 1.8s; }
@keyframes being-particle {
  0%   { transform: translateY(0)     scale(0.6); opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: translateY(-110%) scale(1.1); opacity: 0; }
}

/* ============================================================
   Tag + status pill (only on the large hero frame)
   ============================================================ */
.being-tag {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 7;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  padding: 5px 10px 4px;
  border-radius: 999px;
}
.being-status {
  position: absolute;
  right: 12px; top: 12px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  padding: 5px 10px 4px;
  border-radius: 999px;
}
.being-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: hsl(var(--being-hue) 85% 60%);
  box-shadow: 0 0 6px hsl(var(--being-hue) 90% 60% / 0.8);
  animation: being-pulse-dot 1.6s ease-in-out infinite;
}
@keyframes being-pulse-dot {
  0%,100% { opacity: 0.7; transform: scale(1); }
  50%     { opacity: 1;   transform: scale(1.3); }
}

/* ============================================================
   State machine
   ============================================================ */

/* THINKING — rim ring tightens */
.being-frame[data-state="thinking"] .being-fx--rim {
  box-shadow:
    inset 0 0 0 1px hsl(var(--being-hue) 90% 65% / 0.55),
    inset 0 0 60px hsl(var(--being-hue) 90% 55% / 0.28);
}

/* SPEAKING — rim pulses brighter on cadence */
.being-frame[data-state="speaking"] .being-fx--rim {
  box-shadow:
    inset 0 0 0 1.5px hsl(var(--being-hue) 95% 70% / 0.85),
    inset 0 0 80px hsl(var(--being-hue) 90% 55% / 0.4);
  animation: being-rim-pulse 0.7s ease-in-out infinite;
}
@keyframes being-rim-pulse {
  0%,100% { opacity: 0.75; }
  50%     { opacity: 1; }
}

/* Hover — subtle lift */
.being-frame:hover .being-fx--rim {
  box-shadow:
    inset 0 0 0 1px hsl(var(--being-hue) 90% 65% / 0.4),
    inset 0 0 60px hsl(var(--being-hue) 90% 55% / 0.2);
}

/* ============================================================
   Small variant (chat header + about-grid + other-analysts strip)
   ============================================================ */
.being-frame--sm {
  border-radius: 14px;
  aspect-ratio: 1 / 1;
  width: 100%;
}
.being-frame--sm .being-tag,
.being-frame--sm .being-status,
.being-frame--sm .being-fx--noise { display: none; }
.being-frame--sm .being-fx--particles span { width: 2px; height: 2px; }

/* Fit small frame inside chat header + strip */
.chat-header-avatar .being-frame--sm,
.other-analysts-grid .being-frame--sm { border-radius: 12px; }

.leaders-grid .leader-portrait { aspect-ratio: 1 / 1; width: 100%; padding: 0; background: transparent; border: 0; }
.leaders-grid .being-frame--sm { border-radius: 18px; }

/* ============================================================
   Chat streaming polish
   ============================================================ */
.chat-msg--assistant.is-streaming::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  animation: being-pulse-dot 0.9s ease-in-out infinite;
  transform: translateY(-1px);
}
.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  animation: chat-typing 1s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing {
  0%,100% { transform: translateY(0);   opacity: 0.4; }
  50%     { transform: translateY(-3px); opacity: 1; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .being-portrait,
  .being-fx--halo,
  .being-fx--scan,
  .being-fx--noise,
  .being-fx--particles span,
  .being-status::before,
  .being-frame[data-state="thinking"] .being-portrait,
  .being-frame[data-state="speaking"] .being-portrait,
  .chat-typing span,
  .chat-msg--assistant.is-streaming::after {
    animation: none !important;
  }
}
