/* Animated ring radius for the alert "ping" (radiates from the badge corner).
   Registering it lets the radial-gradient stop interpolate smoothly instead of
   snapping. Unsupported engines fall back to the ambient glow layer, which does
   not depend on this property. */
@property --alert-ping-r {
  syntax: "<length-percentage>";
  inherits: false;
  initial-value: 0%;
}

#alert-summary-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
}

.topbar-alert-btn {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-md, 5px);
  color: var(--ink-2-v1, var(--ink-2));
  cursor: pointer;
  transition: background-color 80ms ease, color 80ms ease, border-color 80ms ease;
}

.topbar-alert-btn:hover {
  background: var(--overlay-1);
  color: var(--ink-1);
}

.topbar-alert-btn[aria-expanded="true"] {
  background: var(--overlay-2);
  color: var(--ink-1);
}

.topbar-alert-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--overlay-2);
}

/* ── Active-alert radiating animation ──────────────────────────────────────
   Two accent-matched layers emanate from the badge corner (top-right) inward:
   ::before = a soft ambient glow that "breathes", ::after = a ring "ping" that
   sweeps across the button and fades. Both are inset:0 so the corner badge
   (positioned outside the button) is never clipped. Colour follows severity;
   the cadence is slow/ambient (errors a touch quicker). The badge itself does
   not animate. No animation while clear (no accent set). Icon + badge stay
   layered above via z-index so they read crisp over the glow. */
.topbar-alert-btn {
  --alert-accent: transparent;
}
.topbar-alert-btn[data-alert-state="warning"] { --alert-accent: var(--sig-warn); }
.topbar-alert-btn[data-alert-state="error"]   { --alert-accent: var(--sig-error); }

.topbar-alert-btn > svg { position: relative; z-index: 1; }
.topbar-alert-btn .alert-summary-badge { z-index: 2; }

.topbar-alert-btn::before,
.topbar-alert-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

/* ambient corner glow (behind the ping) */
.topbar-alert-btn::before {
  background: radial-gradient(circle at 100% 0%,
    color-mix(in srgb, var(--alert-accent) 55%, transparent) 0%,
    transparent 72%);
}

/* expanding ring, origin at the badge corner */
.topbar-alert-btn::after {
  background: radial-gradient(circle at 100% 0%,
    transparent calc(var(--alert-ping-r) - 16%),
    color-mix(in srgb, var(--alert-accent) 85%, transparent) var(--alert-ping-r),
    transparent calc(var(--alert-ping-r) + 16%));
}

.topbar-alert-btn[data-alert-state="warning"]::before,
.topbar-alert-btn[data-alert-state="error"]::before {
  animation: alert-glow-breathe 4.4s ease-in-out infinite;
}
.topbar-alert-btn[data-alert-state="warning"]::after,
.topbar-alert-btn[data-alert-state="error"]::after {
  animation: alert-ping-out 4.4s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

/* errors feel a touch more urgent — still slow, just tightened */
.topbar-alert-btn[data-alert-state="error"]::before,
.topbar-alert-btn[data-alert-state="error"]::after {
  animation-duration: 3.2s;
}

@keyframes alert-glow-breathe {
  0%, 100% { opacity: 0.14; }
  50%      { opacity: 0.5; }
}
@keyframes alert-ping-out {
  0%   { --alert-ping-r: 4%;   opacity: 0; }
  12%  { opacity: 0.85; }
  70%  { --alert-ping-r: 135%; opacity: 0; }
  100% { --alert-ping-r: 135%; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar-alert-btn::before,
  .topbar-alert-btn::after {
    animation: none !important;
  }
  /* keep a static hint of severity instead of motion */
  .topbar-alert-btn[data-alert-state="warning"]::before,
  .topbar-alert-btn[data-alert-state="error"]::before { opacity: 0.32; }
}

.alert-summary-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--sig-warn);
  color: var(--surface-1);
  border: 1px solid var(--float-bg);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  line-height: 14px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
}

.topbar-alert-btn[data-alert-state="error"] .alert-summary-badge {
  background: var(--sig-error);
}

.alert-summary-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  max-height: min(520px, calc(100vh - var(--topbar-h, 48px) - 18px));
  padding: 12px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line-1);
  border-radius: 6px;
  box-shadow: 0 8px 24px var(--overlay-2), var(--float-edge);
  z-index: 1410;
  font-family: var(--font-ui);
  color: var(--ink-1);
  animation: menu-pop var(--dur-enter) var(--ease-out);
}

.alert-summary-pop[hidden] {
  display: none;
}

.alert-summary-pop.is-leaving {
  animation: menu-pop-out var(--dur-exit) var(--ease-out) forwards;
  pointer-events: none;
}

.alert-summary-eyebrow {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3-v1, var(--ink-3));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.alert-summary-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-summary-overview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  background: var(--surface-3);
  border-radius: 5px;
}

.alert-summary-total {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.alert-summary-total-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1;
}

.alert-summary-total-label,
.alert-summary-meta,
.alert-summary-section-meta {
  font-size: 11px;
  color: var(--ink-3-v1, var(--ink-3));
}

.alert-summary-section {
  position: relative;
  overflow: hidden;
  padding: 8px 8px 8px 11px;
  background: var(--surface-3);
  border-radius: 5px;
}

.alert-summary-section::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--ink-3-v1, var(--ink-3));
}

.alert-summary-section.is-error {
  background: var(--sig-error-bg);
}

.alert-summary-section.is-error::before {
  background: var(--sig-error);
}

.alert-summary-section.is-warning {
  background: var(--sig-warn-bg);
}

.alert-summary-section.is-warning::before {
  background: var(--sig-warn);
}

.alert-summary-section.is-advice {
  background: var(--surface-3);
}

.alert-summary-section.is-advice::before {
  background: var(--ink-2-v1, var(--ink-2));
}

.alert-summary-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-summary-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-1);
}

.alert-summary-section-count {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-2-v1, var(--ink-2));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
}

.alert-summary-section.is-error .alert-summary-section-count {
  background: var(--sig-error);
  color: var(--surface-1);
}

.alert-summary-section.is-warning .alert-summary-section-count {
  background: var(--sig-warn);
  color: var(--surface-1);
}

.alert-summary-section.is-advice .alert-summary-section-count {
  background: var(--ink-2-v1, var(--ink-2));
  color: var(--surface-1);
}

.alert-summary-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.alert-summary-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 6px;
  background: var(--surface-1);
  border: 1px solid transparent;
  border-radius: 4px;
}

/* The whole per-component block is the click target (flies the camera to that
   part). Hover/focus lift the block so it reads as clickable — the BOM number
   inside is now just a label, not the affordance. */
.alert-summary-item.is-clickable {
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease;
}

.alert-summary-item.is-clickable:hover {
  background: var(--surface-2);
  border-color: var(--line-1);
}

.alert-summary-item.is-clickable:focus-visible {
  outline: none;
  border-color: var(--line-1);
  box-shadow: 0 0 0 2px var(--overlay-2);
}

.alert-summary-item-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.alert-summary-comps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1px;
}

/* BOM-number label (matches 3D balloon + BOM row). Plain badge — the click
   affordance is the surrounding block, not this pill. */
.alert-summary-comp {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid var(--line-1);
  border-radius: 999px;
  color: var(--ink-2-v1, var(--ink-2));
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.alert-summary-comp-name {
  min-width: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2-v1, var(--ink-2));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-summary-message {
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-2-v1, var(--ink-2));
}

.alert-summary-empty,
.alert-summary-none {
  padding: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-3-v1, var(--ink-3));
}

.alert-summary-none {
  padding: 6px 0 0;
}
