/* ===================================================================
   AGENT ↔ MODEL — Styles
   =================================================================== */

/* ----- HERO ----- */
.am-hero {
  text-align: center;
  padding: 6vh 24px 1.5rem;
  max-width: 680px;
  margin: 0 auto;
  animation: fadeUp 0.7s ease both;
}
.am-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ai);
  margin-bottom: 0.5rem;
}
.am-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 0.6rem;
}
.am-amp {
  font-style: italic;
  color: var(--iface);
  font-weight: 300;
}
.am-lead {
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  color: hsl(var(--ink-3));
  line-height: 1.55;
  max-width: 520px;
  margin: 0 auto;
}
.am-lead em {
  color: var(--ai);
  font-style: italic;
}

/* ----- VISUALIZATION CONTAINER ----- */
.am-viz {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 2rem;
  animation: fadeUp 0.7s 0.12s ease both;
}
.am-stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 700;
  max-height: 72vh;
  margin: 0 auto;
}
.am-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

/* ----- SVG: BRAIN ----- */
.am-brain-aura {
  fill: url(#brain-grad);
  opacity: 0.6;
  transform-origin: 400px 350px;
  animation: brain-breathe 3s ease-in-out infinite;
}
.am-brain-body {
  fill: hsl(var(--card));
  stroke: var(--ai);
  stroke-width: 2.5;
  filter: url(#brain-glow);
  transition: stroke-width 0.6s ease, fill 0.4s ease;
}
.am-brain-divide {
  fill: none;
  stroke: var(--ai);
  stroke-width: 0.8;
  opacity: 0.3;
}
.am-brain-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  fill: var(--ai);
  text-anchor: middle;
  letter-spacing: 0.12em;
  pointer-events: none;
}
.am-brain-sublabel {
  font-family: var(--font-serif);
  font-size: 10.5px;
  font-style: italic;
  fill: hsl(var(--ink-4));
  text-anchor: middle;
  pointer-events: none;
}

/* Neurons */
.am-neuron {
  fill: var(--ai);
  opacity: 0.35;
  transition: opacity 0.15s ease, r 0.15s ease;
}
.am-neuron.firing {
  opacity: 1;
  filter: url(#particle-glow);
}
.am-synapse {
  stroke: var(--ai);
  stroke-width: 1;
  opacity: 0.12;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}
.am-synapse.firing {
  opacity: 0.8;
  stroke-width: 2;
}

@keyframes brain-breathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.06); opacity: 0.75; }
}

/* Brain active state (thinking) */
.am-brain.thinking .am-brain-body {
  stroke-width: 3.5;
}
.am-brain.thinking .am-brain-aura {
  animation: brain-think 0.8s ease-in-out infinite;
}
@keyframes brain-think {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.14); opacity: 1; }
}

/* ----- SVG: CONTEXT RING ----- */
.am-context {
  cursor: pointer;
}
.am-context-ring {
  fill: none;
  stroke: var(--flow);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  opacity: 0.5;
  transition: opacity 0.4s ease, stroke-width 0.3s ease;
}
.am-context:hover .am-context-ring {
  opacity: 0.8;
  stroke-width: 2.5;
}
.am-context-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  fill: var(--flow);
  text-anchor: middle;
  letter-spacing: 0.1em;
  pointer-events: none;
  opacity: 0.7;
}
.am-context-sublabel {
  font-family: var(--font-serif);
  font-size: 9px;
  font-style: italic;
  fill: hsl(var(--ink-4));
  text-anchor: middle;
  pointer-events: none;
  opacity: 0.7;
}

/* ----- SVG: EXOSKELETON ----- */
.am-exo-frame {
  fill: transparent;
  stroke: var(--iface);
  stroke-width: 2.8;
  stroke-linejoin: round;
  transition: stroke 0.6s ease, stroke-width 0.4s ease;
}
.am-exo-brace {
  fill: none;
  stroke: var(--iface);
  stroke-width: 1;
  opacity: 0.2;
  stroke-dasharray: 4 3;
}
.am-exo-joint {
  fill: hsl(var(--card));
  stroke: var(--iface);
  stroke-width: 2;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.am-exo-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  fill: var(--iface);
  text-anchor: middle;
  letter-spacing: 0.12em;
  pointer-events: none;
}
.am-exo-sublabel {
  font-family: var(--font-serif);
  font-size: 10.5px;
  font-style: italic;
  fill: hsl(var(--ink-4));
  text-anchor: middle;
  pointer-events: none;
}

/* Exo active state */
.am-exo.active .am-exo-frame {
  filter: url(#exo-glow);
  stroke-width: 3.5;
}
.am-exo.active .am-exo-joint {
  fill: var(--iface);
}

/* ----- SVG: NEURAL INTERFACE ----- */
.am-neural-link {
  fill: none;
  stroke: var(--ai);
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
  opacity: 0.25;
  transition: opacity 0.5s ease, stroke-width 0.3s ease;
}
.am-neural.active .am-neural-link {
  opacity: 0.7;
  stroke-width: 2;
  animation: neural-pulse 1.5s linear infinite;
}
@keyframes neural-pulse {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -18; }
}

/* ----- SVG: ARMS ----- */
.am-arm {
  stroke: var(--iface);
  stroke-width: 2;
  stroke-dasharray: 8 5;
  opacity: 0.4;
  transition: opacity 0.5s ease, stroke-width 0.3s ease;
}
.am-arm.active {
  opacity: 0.9;
  stroke-width: 3;
  animation: arm-pulse 1s linear infinite;
}
@keyframes arm-pulse {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -13; }
}

/* ----- SVG: TOOLS ----- */
.am-tool {
  cursor: pointer;
}
.am-tool-bg,
.am-tool-ring {
  transition: transform 0.3s ease, fill 0.3s ease, stroke 0.3s ease;
}
.am-tool:hover .am-tool-bg,
.am-tool:hover .am-tool-ring {
  transform: scale(1.08);
  transform-box: fill-box;
  transform-origin: center;
}
.am-tool-bg {
  fill: hsl(var(--card));
  stroke: hsl(var(--border));
  stroke-width: 1.5;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.am-tool-ring {
  fill: none;
  stroke: transparent;
  stroke-width: 3;
  transition: stroke 0.4s ease;
}
.am-tool.active .am-tool-ring {
  stroke: var(--iface);
  filter: url(#tool-glow);
}
.am-tool.active .am-tool-bg {
  fill: var(--iface);
  fill-opacity: 0.08;
}
.am-tool-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  fill: hsl(var(--ink-4));
  text-anchor: middle;
  pointer-events: none;
}
.am-tool-icon-text {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  fill: var(--flow);
  text-anchor: middle;
  pointer-events: none;
}

/* Tool-specific active colors */
.am-tool[data-tool="user"].active .am-tool-ring { stroke: var(--human); }
.am-tool[data-tool="user"].active .am-tool-bg { fill: var(--human); fill-opacity: 0.08; }
.am-tool[data-tool="web"].active .am-tool-ring { stroke: var(--iface); }
.am-tool[data-tool="code"].active .am-tool-ring { stroke: var(--flow); }
.am-tool[data-tool="code"].active .am-tool-bg { fill: var(--flow); fill-opacity: 0.08; }
.am-tool[data-tool="files"].active .am-tool-ring { stroke: var(--flow); }
.am-tool[data-tool="memory"].active .am-tool-ring { stroke: var(--gov); }
.am-tool[data-tool="memory"].active .am-tool-bg { fill: var(--gov); fill-opacity: 0.08; }
.am-tool[data-tool="mcp"].active .am-tool-ring { stroke: var(--iface); }

/* ----- SVG: PARTICLES ----- */
.am-particle {
  transition: opacity 0.2s ease;
}

/* ----- CONTROLS ----- */
.am-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0.8rem auto 0;
  max-width: 600px;
  padding: 0 8px;
  animation: fadeUp 0.7s 0.25s ease both;
}
.am-timeline {
  flex: 1;
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
}
.am-timeline-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: hsl(var(--border));
  border-radius: 2px;
  overflow: hidden;
}
.am-timeline-fill {
  height: 100%;
  width: 0%;
  background: var(--ai);
  border-radius: 2px;
  transition: width 0.05s linear;
}
.am-steps {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: space-between;
  z-index: 1;
}
.am-step {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  position: relative;
}
.am-step:hover {
  transform: scale(1.2);
}
.am-step.active {
  border-color: var(--ai);
  background: var(--ai);
  transform: scale(1.15);
}
.am-step.done {
  border-color: var(--ai);
  background: var(--ai);
  opacity: 0.5;
}
.am-step-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: hsl(var(--ink-5));
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.am-step:hover .am-step-label,
.am-step.active .am-step-label {
  opacity: 1;
}
.am-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.am-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--ink-3));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.am-btn:hover {
  border-color: var(--ai);
  color: var(--ai);
}
.am-btn-play {
  width: 42px;
  height: 42px;
}
/* Playing state: show pause icon, hide play */
.am-btn-play .am-icon-play { display: none; }
.am-btn-play .am-icon-pause { display: block; }
.am-btn-play.paused .am-icon-play { display: block; }
.am-btn-play.paused .am-icon-pause { display: none; }

/* ----- NARRATIVE ----- */
.am-narrative {
  text-align: center;
  max-width: 580px;
  margin: 1.2rem auto 0;
  min-height: 80px;
  padding: 0 16px;
  animation: fadeUp 0.7s 0.35s ease both;
}
.am-stage-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ai);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  transition: opacity 0.4s ease;
}
.am-stage-text {
  font-size: 1rem;
  color: hsl(var(--ink-3));
  line-height: 1.6;
  transition: opacity 0.4s ease;
}
.am-stage-text em {
  color: hsl(var(--foreground));
  font-style: italic;
}

/* ----- DETAIL PANEL ----- */
.am-detail {
  position: fixed;
  width: 320px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  z-index: 100;
  animation: detail-in 0.3s ease both;
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.am-detail[hidden] { display: none; }
.am-detail-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  color: hsl(var(--ink-4));
  cursor: pointer;
  line-height: 1;
}
.am-detail-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: hsl(var(--foreground));
}
.am-detail-body {
  font-size: 0.9rem;
  color: hsl(var(--ink-3));
  line-height: 1.5;
  margin-bottom: 0.6rem;
}
.am-detail-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.am-detail-list li {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: hsl(var(--ink-4));
  padding: 3px 0;
  border-top: 1px solid hsl(var(--border));
}
.am-detail-list li::before {
  content: '→ ';
  color: var(--iface);
}

/* ----- INSIGHTS ----- */
.am-insights {
  max-width: 920px;
  margin: 2rem auto 0;
  padding: 0 24px 3rem;
  animation: fadeUp 0.7s 0.5s ease both;
}
.am-insights-heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.5rem;
}
.am-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
}
.am-insight {
  padding: 1.4rem;
  text-align: center;
}
.am-insight-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.8rem;
}
.am-insight h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}
.am-insight p {
  font-size: 0.88rem;
  color: hsl(var(--ink-3));
  line-height: 1.55;
}

/* ----- FOOTER ----- */
.am-footer {
  text-align: center;
  padding: 1rem 24px 2rem;
  font-size: 0.85rem;
  color: hsl(var(--ink-5));
}
.am-footer a {
  color: var(--ai);
}

/* ----- RESPONSIVE ----- */
@media (max-width: 768px) {
  .am-hero {
    padding-top: 4vh;
  }
  .am-insight-grid {
    grid-template-columns: 1fr;
  }
  .am-detail {
    width: min(320px, calc(100vw - 24px));
  }
  .am-step-label {
    display: none;
  }
}

/* ----- SVG interactive areas ----- */
.am-brain,
.am-exo,
.am-tool {
  cursor: pointer;
}
.am-brain:hover .am-brain-body {
  stroke-width: 3.5;
}
.am-exo:hover .am-exo-frame {
  stroke-width: 3.5;
}

/* ----- Transition helpers for stage changes ----- */
.am-fade-out {
  opacity: 0 !important;
  transition: opacity 0.4s ease !important;
}
.am-fade-in {
  opacity: 1 !important;
  transition: opacity 0.6s ease !important;
}
