/* Interactive teori animations */

.teori-anim {
  margin: 1rem 0 1.5rem;
  padding: 1.1rem 1.15rem 1.25rem;
  border-radius: 16px;
  border: 1px solid rgba(61, 214, 198, 0.28);
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(61, 214, 198, 0.1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(96, 165, 250, 0.08), transparent 50%),
    rgba(7, 16, 24, 0.85);
  overflow: hidden;
}

.teori-anim-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.85rem;
}

.teori-anim-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.teori-anim-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  max-width: 36rem;
}

.teori-anim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.teori-anim-controls .btn.active {
  background: var(--accent);
  color: var(--ink);
  border-color: transparent;
}

.cs-stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  min-height: 160px;
  margin-bottom: 0.85rem;
}

.cs-node {
  position: relative;
  z-index: 2;
  padding: 1rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 32, 51, 0.92);
  text-align: center;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.cs-node.active {
  border-color: rgba(61, 214, 198, 0.55);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.2), 0 8px 28px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.cs-node .cs-icon {
  display: block;
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.cs-node strong {
  display: block;
  font-size: 0.95rem;
}

.cs-node span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.cs-wire {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(61, 214, 198, 0.15), rgba(96, 165, 250, 0.35), rgba(61, 214, 198, 0.15));
  overflow: visible;
}

.cs-packet {
  position: absolute;
  top: 50%;
  left: 0;
  width: max-content;
  max-width: 9.5rem;
  padding: 0.28rem 0.5rem;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.cs-packet.req {
  background: #3dd6c6;
  color: #062018;
}

.cs-packet.res {
  background: #60a5fa;
  color: #061018;
}

.cs-packet.err {
  background: #f87171;
  color: #1a0606;
}

.cs-packet.fly {
  opacity: 1;
  transition: left 1.05s cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease;
}

.cs-log {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #050b12;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.55;
  color: #b8c9d9;
  min-height: 4.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.cs-log .tok-method {
  color: #7dd3fc;
}

.cs-log .tok-ok {
  color: #86efac;
}

.cs-log .tok-err {
  color: #fca5a5;
}

.cs-log .tok-dim {
  color: #64748b;
}

/* Hosting mode compare */
.host-stage {
  display: grid;
  gap: 0.85rem;
}

.host-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.host-canvas {
  position: relative;
  min-height: 200px;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}

.host-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.65rem;
  align-items: center;
  min-height: 120px;
}

.host-box {
  padding: 0.85rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(18, 32, 51, 0.9);
  text-align: center;
  font-size: 0.88rem;
}

.host-box strong {
  display: block;
  margin-bottom: 0.25rem;
}

.host-box small {
  color: var(--muted);
  font-size: 0.75rem;
}

.host-flow {
  position: relative;
  height: 48px;
}

.host-flow-line {
  position: absolute;
  inset: 50% 0 auto;
  height: 3px;
  background: rgba(61, 214, 198, 0.25);
  transform: translateY(-50%);
}

.host-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  opacity: 0;
  box-shadow: 0 0 12px rgba(61, 214, 198, 0.7);
}

.host-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  min-height: 2.6rem;
}

.host-mode-server .host-box.server {
  border-color: rgba(61, 214, 198, 0.5);
}

.host-mode-wasm .host-box.client {
  border-color: rgba(96, 165, 250, 0.55);
}

/* SPA route pulse */
.spa-stage {
  display: grid;
  gap: 0.75rem;
}

.spa-shell {
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: rgba(18, 32, 51, 0.9);
}

.spa-chrome {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.spa-chrome button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.spa-chrome button.active {
  color: var(--ink);
  background: var(--accent);
}

.spa-body {
  position: relative;
  min-height: 88px;
  padding: 1.1rem 1rem;
}

.spa-panel {
  position: absolute;
  inset: 1.1rem 1rem;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 280ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.spa-panel.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.spa-panel h4 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.spa-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.spa-note {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 640px) {
  .cs-stage,
  .host-row {
    grid-template-columns: 1fr;
  }

  .cs-wire {
    height: 48px;
    width: 4px;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(61, 214, 198, 0.15), rgba(96, 165, 250, 0.35), rgba(61, 214, 198, 0.15));
  }

  .cs-packet.fly {
    transition: top 1.05s cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-packet.fly,
  .spa-panel,
  .host-dot,
  .cs-node {
    transition: none !important;
  }
}
