/* ============================================================
   VCC, Ecosystem section
   Five actors around a Helix hub
   Toggle between Data Flow and Money Flow views
   ============================================================ */

.ecosystem {
  position: relative;
  padding-block: clamp(48px, 6vw, 88px);
  overflow: hidden;
}

.ecosystem::before {
  content: "";
  position: absolute;
  top: -10%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(116, 219, 139, 0.08) 0%, transparent 65%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

.ecosystem__head {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 720px;
  margin: 0 auto var(--space-5);
}

.ecosystem__head .eyebrow { margin-bottom: var(--space-4); }

.ecosystem__head h2 {
  font-size: var(--fs-primary);
  font-weight: var(--fw-light);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  margin-bottom: var(--space-4);
  max-width: 32ch;
  margin-inline: auto;
  text-wrap: balance;
}

.ecosystem__head h2 .accent { color: var(--accent); font-weight: var(--fw-bold); }
.ecosystem__head .lead { margin-inline: auto; max-width: 56ch; }

/* ---------- Toggle control ---------- */

.ecosystem__toggle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-6);
  position: relative;
  z-index: 1;
}

.ecosystem__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 5px;
  background: rgba(46, 63, 50, 0.45);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.ecosystem__toggle-btn {
  position: relative;
  padding: 10px 22px;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ecosystem__toggle-btn:hover { color: var(--text-primary); }
.ecosystem__toggle-btn.is-active { color: var(--ew-green-700); }

.ecosystem__toggle-indicator {
  position: absolute;
  top: 5px;
  left: 5px;
  height: calc(100% - 10px);
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: transform var(--dur-base) var(--ease-out),
              width var(--dur-base) var(--ease-out);
  z-index: 0;
  pointer-events: none;
  box-shadow: 0 0 16px rgba(116, 219, 139, 0.4);
}

.ecosystem__toggle-btn .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

/* ---------- Stage frame ---------- */

.ecosystem__stage {
  position: relative;
  z-index: 1;
  background: rgba(46, 63, 50, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: clamp(16px, 2vw, 28px);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.ecosystem__canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 20 / 11;
  max-width: 1100px;
  margin-inline: auto;
}

@media (max-width: 900px) {
  .ecosystem__canvas { aspect-ratio: 5 / 7; }
}

.ecosystem__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ============================================================
   HUB, rotation fix via transform-box: fill-box
   ============================================================ */

.eco-hub-ring {
  fill: none;
  stroke: var(--border-accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 5;
  transform-box: fill-box;
  transform-origin: center;
  animation: eco-hub-rotate 50s linear infinite;
}

@keyframes eco-hub-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.eco-hub-glow {
  fill: rgba(116, 219, 139, 0.12);
  transform-box: fill-box;
  transform-origin: center;
  animation: eco-hub-pulse 4s ease-in-out infinite;
}

@keyframes eco-hub-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(1.06); }
}

.eco-hub-inner {
  fill: rgba(20, 28, 23, 0.4);
  stroke: var(--border-accent);
  stroke-width: 1.2;
}

.eco-hub-helix {
  fill: none;
  stroke: var(--accent);
  stroke-width: 14;
  stroke-linecap: round;
  filter: drop-shadow(0 0 14px rgba(116, 219, 139, 0.5));
}

.eco-hub-label {
  fill: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-anchor: middle;
  font-weight: 500;
}

/* ---------- Actor cards, larger typography ---------- */

.eco-actor rect.bg {
  fill: var(--bg-elevated);
  stroke: var(--border);
  stroke-width: 1;
  transition: stroke var(--dur-base) var(--ease-out);
}

.eco-actor:hover rect.bg { stroke: var(--border-strong); }

.eco-actor text.role {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.eco-actor text.name {
  fill: var(--text-primary);
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.eco-actor text.desc {
  fill: var(--text-muted);
  font-family: var(--font-brand);
  font-size: 12.5px;
}

.eco-actor text.flow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.3px;
  transition: fill var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out);
}

.eco-actor-icon {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eco-actor-icon-bg {
  fill: rgba(116, 219, 139, 0.08);
  stroke: rgba(116, 219, 139, 0.25);
  stroke-width: 1;
}

/* Role colors */
.eco-actor[data-role="enterprise"] .eco-actor-icon { stroke: var(--verified); }
.eco-actor[data-role="enterprise"] .eco-actor-icon-bg { fill: rgba(86, 116, 241, 0.1); stroke: rgba(86, 116, 241, 0.3); }
.eco-actor[data-role="methodology"] .eco-actor-icon { stroke: var(--accent); }
.eco-actor[data-role="operator"] .eco-actor-icon { stroke: var(--accent); }
.eco-actor[data-role="auditor"] .eco-actor-icon { stroke: var(--ew-purple-200); }
.eco-actor[data-role="auditor"] .eco-actor-icon-bg { fill: rgba(170, 160, 169, 0.1); stroke: rgba(170, 160, 169, 0.3); }
.eco-actor[data-role="public"] .eco-actor-icon { stroke: #E8A840; }
.eco-actor[data-role="public"] .eco-actor-icon-bg { fill: rgba(232, 168, 64, 0.1); stroke: rgba(232, 168, 64, 0.3); }

/* ---------- Flow lines (solid, subtle, always visible as static guides) ---------- */

.eco-flow {
  fill: none;
  stroke: var(--border-accent);
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: 0.35;
  transition: opacity var(--dur-base) var(--ease-out);
}

.ecosystem__canvas.mode-data .eco-flow,
.ecosystem__canvas.mode-money .eco-flow {
  opacity: 0.45;
}

/* ---------- Moving tokens (data packets + money coins) ---------- */

.eco-token {
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.eco-token--data > rect {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px rgba(116, 219, 139, 0.85));
}

.eco-token--money > circle {
  fill: #E8A840;
  stroke: rgba(255, 220, 160, 0.7);
  stroke-width: 1;
  filter: drop-shadow(0 0 6px rgba(232, 168, 64, 0.85));
}

.ecosystem__canvas.mode-data .eco-token--data {
  opacity: 1;
}

.ecosystem__canvas.mode-money .eco-token--money {
  opacity: 1;
}

/* Hide the opposite-mode tokens cleanly (also prevents them from rendering above the hub) */
.ecosystem__canvas.mode-data .eco-token--money,
.ecosystem__canvas.mode-money .eco-token--data {
  opacity: 0;
}

.ecosystem__canvas.mode-data .eco-actor text.flow--data { fill: var(--accent); opacity: 1; }
.ecosystem__canvas.mode-data .eco-actor text.flow--money { opacity: 0; }

.ecosystem__canvas.mode-money .eco-actor text.flow--money { fill: #E8A840; opacity: 1; }
.ecosystem__canvas.mode-money .eco-actor text.flow--data { opacity: 0; }

/* ---------- Legend below ---------- */

.ecosystem__legend {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 720px) {
  .ecosystem__legend { grid-template-columns: 1fr; gap: var(--space-4); }
}

.ecosystem__legend-card {
  position: relative;
  opacity: 0.5;
  transition: opacity var(--dur-base) var(--ease-out);
}

.ecosystem__legend-card.is-active { opacity: 1; }

.ecosystem__legend-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  transition: color var(--dur-fast) var(--ease-out);
}

.ecosystem__legend-title::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.ecosystem__legend-card.is-active .ecosystem__legend-title--data { color: var(--accent); }
.ecosystem__legend-card.is-active .ecosystem__legend-title--money { color: #E8A840; }

.ecosystem__legend-body {
  color: var(--text-secondary);
  font-size: var(--fs-body-sm);
  line-height: 1.55;
  max-width: 48ch;
}

.ecosystem__legend-body strong { color: var(--text-primary); font-weight: 500; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .eco-hub-ring, .eco-hub-glow { animation: none !important; }
  .eco-token { display: none !important; }
}
