/*
  Informative Action Lab
  Historical filename kept for compatibility.
  This stylesheet restores the visual panels after the vanilla reskin.
*/

.collapse-tool-page {
  --ia-bg: #fafafa;
  --ia-panel: #ffffff;
  --ia-soft: #f8fafc;
  --ia-text: #18181b;
  --ia-muted: #666b74;
  --ia-line: #d9dde5;
  --ia-strong: #1f2937;
  --ia-blue: #1d4ed8;
}

.tool-header {
  display: grid;
  gap: 1rem;
}

.tool-header__actions {
  margin-top: 0;
}

.cw-intro-panel {
  margin: 0 0 1.5rem;
  padding: clamp(1.25rem, 2vw, 2rem);
  border: 1px solid var(--ia-line);
  border-radius: var(--radius);
  background: var(--ia-panel);
  box-shadow: var(--shadow);
}

.cw-intro-panel h2 {
  max-width: 14ch;
}

.cw-intro-panel p {
  max-width: 70ch;
  color: var(--ia-muted);
}

.cw-intro-line {
  margin-top: 1rem;
  font-weight: 700;
  color: var(--ia-text) !important;
}

.tool-panel__head,
.collapse-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.collapse-controls {
  display: grid;
  gap: 1rem;
}

.phase-stepper,
.cw-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cw-readout-grid {
  margin-top: 1rem;
}

.cw-readout {
  padding: 0.85rem;
  border: 1px solid var(--ia-line);
  border-radius: var(--radius);
  background: var(--ia-soft);
}

.cw-readout strong {
  display: block;
  font-size: 1.1rem;
}

.cw-readout__label,
.cw-control label,
.collapse-panel__kicker,
.tool-panel__kicker {
  color: var(--ia-muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cw-morphology-note,
.tool-notes,
.cw-status,
.cw-provenance {
  color: var(--ia-muted);
}

/* SVG panels */

.collapse-svg {
  display: block;
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--ia-line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: none;
  overflow: visible;
}

/* Remove the accidental shadow look caused by missing app CSS. */
.collapse-svg,
.collapse-svg * {
  filter: none !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

.collapse-svg * {
  vector-effect: non-scaling-stroke;
}

/*
  Preserve renderer-driven SVG attributes.
  Defaults only apply when the element has not been given its own fill/stroke.
*/

.collapse-svg line:not([stroke]),
.collapse-svg path:not([stroke]),
.collapse-svg polyline:not([stroke]) {
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.collapse-svg path:not([fill]),
.collapse-svg polyline:not([fill]) {
  fill: none;
}

.collapse-svg rect:not([fill]) {
  fill: #f8fafc;
}

.collapse-svg rect:not([stroke]) {
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.collapse-svg circle:not([fill]),
.collapse-svg ellipse:not([fill]) {
  fill: #ffffff;
}

.collapse-svg circle:not([stroke]),
.collapse-svg ellipse:not([stroke]) {
  stroke: #1f2937;
  stroke-width: 2;
}

.collapse-svg polygon:not([fill]) {
  fill: rgba(241, 245, 249, 0.9);
}

.collapse-svg polygon:not([stroke]) {
  stroke: #334155;
  stroke-width: 2;
  stroke-linejoin: round;
}

.collapse-svg text:not([fill]) {
  fill: #111827;
}

.collapse-svg text {
  stroke: none;
  paint-order: normal;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  dominant-baseline: middle;
}

/* Common classes used by the renderer, plus safe generic fallbacks. */

.collapse-svg .cw-edge,
.collapse-svg .edge,
.collapse-svg .link,
.collapse-svg .response-line {
  stroke: #94a3b8;
  stroke-width: 1.75;
}

.collapse-svg .cw-node:not([fill]),
.collapse-svg .node:not([fill]),
.collapse-svg .station:not([fill]),
.collapse-svg .point:not([fill]) {
  fill: #ffffff;
}

.collapse-svg .cw-node:not([stroke]),
.collapse-svg .node:not([stroke]),
.collapse-svg .station:not([stroke]),
.collapse-svg .point:not([stroke]) {
  stroke: #1f2937;
}

.collapse-svg .cw-active,
.collapse-svg .active,
.collapse-svg .is-active,
.collapse-svg [data-active="true"] {
  animation: ia-pulse 1.25s ease-in-out infinite;
}

.collapse-svg .cw-trace,
.collapse-svg .trace,
.collapse-svg .response,
.collapse-svg .motion {
  stroke: #1d4ed8;
  stroke-width: 2.5;
}

.collapse-svg .cw-fill,
.collapse-svg .bubble,
.collapse-svg .membrane {
  fill: rgba(219, 234, 254, 0.55);
  stroke: #1d4ed8;
}

.collapse-svg .cw-label,
.collapse-svg .label {
  fill: #111827;
}

@keyframes ia-pulse {
  0% {
    opacity: 0.72;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.045);
  }
  100% {
    opacity: 0.72;
    transform: scale(1);
  }
}

.current-state-json,
#current-state-json {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .tool-panel__head,
  .collapse-panel__head {
    display: block;
  }

  .collapse-svg {
    min-height: 220px;
  }
}

/* AI-facing boundary panel */

.cw-ai-panel {
  width: min(var(--max), calc(100% - 2rem));
  margin: 1.5rem auto 4rem;
  padding: clamp(1.25rem, 2vw, 2rem);
  border: 1px solid var(--ia-line);
  border-radius: var(--radius);
  background: var(--ia-panel);
  box-shadow: var(--shadow);
}

.cw-ai-panel h2 {
  max-width: 16ch;
}

.cw-ai-panel p {
  max-width: 72ch;
  color: var(--ia-muted);
}

/* Activity highlighting. These rules are intentionally broad but do not flatten
   renderer-provided fill/stroke attributes. */

.collapse-svg .cw-active,
.collapse-svg .active,
.collapse-svg .is-active,
.collapse-svg .hot,
.collapse-svg .selected,
.collapse-svg .current,
.collapse-svg [data-active="true"],
.collapse-svg [data-current="true"] {
  transform-box: fill-box;
  transform-origin: center;
  animation: ia-pulse 1.15s ease-in-out infinite;
}

.collapse-svg circle.cw-active,
.collapse-svg circle.active,
.collapse-svg circle.is-active,
.collapse-svg circle.hot,
.collapse-svg circle.selected,
.collapse-svg circle.current,
.collapse-svg circle[data-active="true"],
.collapse-svg circle[data-current="true"] {
  stroke-width: 3.5;
}

/* Activity color and SVG label centering */

.collapse-svg text {
  text-anchor: middle;
  dominant-baseline: central;
  alignment-baseline: central;
  pointer-events: none;
}

.collapse-svg tspan {
  text-anchor: middle;
  dominant-baseline: central;
  alignment-baseline: central;
}

.collapse-svg .cw-active,
.collapse-svg .active,
.collapse-svg .is-active,
.collapse-svg .hot,
.collapse-svg .selected,
.collapse-svg .current,
.collapse-svg [data-active="true"],
.collapse-svg [data-current="true"] {
  transform-box: fill-box;
  transform-origin: center;
  animation: ia-pulse 1.15s ease-in-out infinite;
}

.collapse-svg circle.cw-active,
.collapse-svg circle.active,
.collapse-svg circle.is-active,
.collapse-svg circle.hot,
.collapse-svg circle.selected,
.collapse-svg circle.current,
.collapse-svg circle[data-active="true"],
.collapse-svg circle[data-current="true"],
.collapse-svg ellipse.cw-active,
.collapse-svg ellipse.active,
.collapse-svg ellipse.is-active,
.collapse-svg ellipse.hot,
.collapse-svg ellipse.selected,
.collapse-svg ellipse.current,
.collapse-svg ellipse[data-active="true"],
.collapse-svg ellipse[data-current="true"] {
  fill: #dbeafe !important;
  stroke: #1d4ed8 !important;
  stroke-width: 3.5 !important;
}

.collapse-svg .cw-positive,
.collapse-svg .positive,
.collapse-svg [data-sign="positive"] {
  fill: #dcfce7 !important;
  stroke: #15803d !important;
}

.collapse-svg .cw-negative,
.collapse-svg .negative,
.collapse-svg [data-sign="negative"] {
  fill: #fee2e2 !important;
  stroke: #b91c1c !important;
}

.collapse-svg .cw-neutral,
.collapse-svg .neutral,
.collapse-svg [data-sign="neutral"] {
  fill: #f8fafc !important;
  stroke: #64748b !important;
}

/* Preserve JS color fills while keeping nodes readable. */
.collapse-svg circle.cw-node[fill],
.collapse-svg ellipse.cw-node[fill] {
  stroke: #1f2937;
  stroke-width: 2.25;
}

.collapse-svg rect.cw-bar[fill] {
  stroke: none;
}

