/* Integration Matrix widget.
   Light card. 5-row compatibility matrix: Orchestrators / Frameworks
   / Containers / Dev Surfaces / Observability. Each row cycles
   through an active state (teal row-dot, bright label, full-opacity
   partner pills) on a 10s loop (2s per row). Non-active rows dim to
   a quiet rest state so the active row reads as the scan line.

   Matches the vocabulary of stage-path + sovereign-enclave +
   workforce-pipeline + intent-flow: white card, tinted panel inside,
   mono labels, brand teal accents, soft shadow stack. CSS-only,
   reduced-motion parks the indicator on row 1. */

.widget-integration-matrix {
  --wim-teal: var(--brand-teal);
  --wim-blue: var(--brand-blue);
  --wim-surface: var(--color-card, #fff);
  --wim-fg: var(--color-foreground);
  --wim-muted: var(--color-muted-foreground);
  --wim-line: var(--color-border);
  --wim-panel: color-mix(in srgb, var(--wim-fg) 3%, var(--wim-surface));
  --wim-cycle: 10s; /* overridden per-instance inline */

  min-width: 0;
  width: 100%;
}

.widget-integration-matrix__card {
  display: grid;
  grid-template-rows: auto auto auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
  padding: 0.875rem 0.875rem 0.75rem;
  background: var(--wim-surface);
  border: 1px solid var(--wim-line);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 2px rgb(16 17 20 / 4%),
    0 10px 28px -14px rgb(16 17 20 / 14%),
    0 22px 48px -24px rgb(16 17 20 / 10%);
  color: var(--wim-fg);
  --color-foreground: var(--wim-fg);
  --color-muted-foreground: var(--wim-muted);
  --color-border: var(--wim-line);
}

/* --- Head row ----------------------------------------------------- */

.widget-integration-matrix__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.125rem 0.25rem;
}

.widget-integration-matrix__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wim-fg);
}

.widget-integration-matrix__tag-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--wim-teal);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--wim-teal) 35%, var(--wim-surface)),
    0 0 10px color-mix(in srgb, var(--wim-teal) 45%, transparent);
  animation: wim-tag-breathe 2.6s ease-in-out infinite;
}

.widget-integration-matrix__status {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wim-muted);
}

/* --- Stage (the 5-row matrix) ------------------------------------- */

.widget-integration-matrix__stage {
  display: grid;
  gap: 0.375rem;
  padding: 0.625rem 0.625rem 0.75rem;
  background: var(--wim-panel);
  border: 1px solid color-mix(in srgb, var(--wim-fg) 9%, transparent);
  border-radius: var(--radius-md);
}

.widget-integration-matrix__row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.625rem;
  align-items: center;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  /* Quiet rest state: row sits at 62% opacity so the active row
     pops. Active-row keyframe bumps back to 100% during its 2s
     turn. The opacity swing is what sells the "scanning" read. */
  opacity: 0.62;
  animation: wim-row-active var(--wim-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 5) * var(--wim-cycle));
  transition: background 0.4s ease;
}

/* Active-row keyframe: each row wakes for 20% of the cycle (2s
   within 10s), 2% fade-in, 16% hold, 2% fade-out. Rest of the cycle
   the row sits quiet. Matches the site's frame-fade motion language
   shape. */
@keyframes wim-row-active {
  0%                { opacity: 0.62; background: transparent; }
  2%, 18%           {
    opacity: 1;
    background: color-mix(in srgb, var(--wim-teal) 4%, transparent);
  }
  20%               { opacity: 0.62; background: transparent; }
  100%              { opacity: 0.62; background: transparent; }
}

/* --- Row head (category dot + label) ------------------------------ */

.widget-integration-matrix__row-head {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.widget-integration-matrix__row-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--wim-fg) 18%, transparent);
  flex-shrink: 0;
  animation: wim-row-dot var(--wim-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 5) * var(--wim-cycle));
}

@keyframes wim-row-dot {
  0%       { background: color-mix(in srgb, var(--wim-fg) 18%, transparent); box-shadow: none; }
  2%, 18%  {
    background: var(--wim-teal);
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--wim-teal) 18%, transparent),
      0 0 10px color-mix(in srgb, var(--wim-teal) 40%, transparent);
  }
  20%      { background: color-mix(in srgb, var(--wim-fg) 18%, transparent); box-shadow: none; }
  100%     { background: color-mix(in srgb, var(--wim-fg) 18%, transparent); box-shadow: none; }
}

.widget-integration-matrix__row-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wim-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: wim-row-label var(--wim-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 5) * var(--wim-cycle));
}

@keyframes wim-row-label {
  0%       { color: var(--wim-muted); }
  2%, 18%  { color: var(--wim-teal); }
  20%      { color: var(--wim-muted); }
  100%     { color: var(--wim-muted); }
}

/* --- Partner pills -------------------------------------------------- */

.widget-integration-matrix__partners {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  min-width: 0;
}

.widget-integration-matrix__partner {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5625rem;
  background: var(--wim-surface);
  border: 1px solid color-mix(in srgb, var(--wim-fg) 10%, transparent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: -0.005em;
  color: var(--wim-fg);
  white-space: nowrap;
}

/* When the parent row is active, lift each partner pill to the teal
   border + soft tinted background. Matches the pill brightening of
   the active row. */
.widget-integration-matrix__row .widget-integration-matrix__partner {
  animation: wim-partner-active var(--wim-cycle) ease-in-out infinite;
  animation-delay: calc((var(--i) / 5) * var(--wim-cycle));
}

@keyframes wim-partner-active {
  0% {
    background: var(--wim-surface);
    border-color: color-mix(in srgb, var(--wim-fg) 10%, transparent);
  }
  2%, 18% {
    background: color-mix(in srgb, var(--wim-teal) 5%, var(--wim-surface));
    border-color: color-mix(in srgb, var(--wim-teal) 25%, transparent);
  }
  20% {
    background: var(--wim-surface);
    border-color: color-mix(in srgb, var(--wim-fg) 10%, transparent);
  }
  100% {
    background: var(--wim-surface);
    border-color: color-mix(in srgb, var(--wim-fg) 10%, transparent);
  }
}

/* --- Meter strip --------------------------------------------------- */

.widget-integration-matrix__meters {
  display: grid;
  grid-template-columns: 1fr 1fr 0.75fr;
  gap: 0.5rem;
  padding: 0.5rem 0.375rem 0;
  border-top: 1px solid color-mix(in srgb, var(--wim-fg) 9%, transparent);
}

.widget-integration-matrix__meter {
  display: flex;
  flex-direction: column;
  gap: 0.1875rem;
  padding: 0.25rem 0.375rem;
  min-width: 0;
}

.widget-integration-matrix__meter-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wim-muted);
  white-space: nowrap;
}

.widget-integration-matrix__meter-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  color: var(--wim-teal);
  letter-spacing: -0.005em;
  white-space: nowrap;
}

/* --- Shared tag-dot breathe -------------------------------------- */

@keyframes wim-tag-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--wim-teal) 35%, var(--wim-surface)),
      0 0 10px color-mix(in srgb, var(--wim-teal) 45%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 5px color-mix(in srgb, var(--wim-teal) 22%, var(--wim-surface)),
      0 0 16px color-mix(in srgb, var(--wim-teal) 60%, transparent);
  }
}

/* --- Responsive --------------------------------------------------- */

@media (max-width: 640px) {
  .widget-integration-matrix__row {
    grid-template-columns: 1fr;
    gap: 0.375rem;
  }
  .widget-integration-matrix__meters {
    grid-template-columns: 1fr;
  }
  .widget-integration-matrix__partner {
    font-size: 0.625rem;
  }
}

/* --- Reduced motion ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .widget-integration-matrix__tag-dot,
  .widget-integration-matrix__row,
  .widget-integration-matrix__row-dot,
  .widget-integration-matrix__row-label,
  .widget-integration-matrix__partner {
    animation: none;
  }
  /* All rows sit at uniform full opacity. No active-row highlight. */
  .widget-integration-matrix__row { opacity: 1; background: transparent; }
  .widget-integration-matrix__row-dot {
    background: color-mix(in srgb, var(--wim-teal) 40%, transparent);
  }
  .widget-integration-matrix__row-label {
    color: color-mix(in srgb, var(--wim-teal) 40%, var(--wim-muted));
  }
}
