/* =========================================================================
   NEXO AZUL · Sección "Ecosistema colaborativo" (inicio)
   Nexo Azul al centro y 9 actores conectados en ambas direcciones.
   Escritorio (≥ 900 px): constelación radial con conexiones animadas en canvas.
   Tableta y móvil: núcleo arriba y actores en rejilla de 3 columnas.
   ========================================================================= */

.eco { overflow: hidden; isolation: isolate; }
.eco > .wrap { position: relative; z-index: 1; }
.eco-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(52% 44% at 50% 64%, rgba(56, 182, 244, 0.13), transparent 72%),
    radial-gradient(38% 30% at 50% 64%, rgba(22, 119, 224, 0.08), transparent 70%),
    linear-gradient(180deg, var(--mist) 0%, var(--white) 22%, var(--white) 78%, #f6f9fd 100%);
}
.eco-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(10, 95, 200, 0.16) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(48% 40% at 50% 64%, #000 0%, transparent 100%);
  mask-image: radial-gradient(48% 40% at 50% 64%, #000 0%, transparent 100%);
  opacity: 0.55;
}

.eco-head { max-width: 1120px; margin-bottom: clamp(28px, 4vw, 56px); }
.eco-head .h2 { font-size: clamp(1.8rem, 1.05rem + 2.75vw, 3.75rem); line-height: 1.06; }
.eco-lead { max-width: 62ch; margin: 24px auto 0; }

/* ---------- Escenario ---------- */
.eco-stage { position: relative; }
.eco-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; display: none; }
.eco-nodes { list-style: none; margin: 0; padding: 0; }

/* ---------- Núcleo: Nexo Azul ---------- */
.eco-hub { position: relative; z-index: 2; width: var(--hub, 220px); aspect-ratio: 1; }
.eco-hub__core {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7%;
  background: radial-gradient(circle at 50% 32%, #ffffff 0%, #ffffff 58%, #f1f7ff 100%);
  border: 1px solid rgba(22, 119, 224, 0.14);
  box-shadow:
    0 0 0 9px rgba(255, 255, 255, 0.85),
    0 0 0 10px rgba(22, 119, 224, 0.12),
    0 30px 60px -24px rgba(10, 95, 200, 0.45),
    0 12px 26px -14px rgba(6, 20, 48, 0.22);
}
.eco-hub__symbol { width: 40%; height: auto; }
.eco-hub__word { width: 66%; height: auto; }
.eco-hub__orbit {
  position: absolute; inset: -22px; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(56, 182, 244, 0) 0deg, rgba(56, 182, 244, 0) 150deg, rgba(56, 182, 244, 0.9) 250deg, #1677e0 320deg, var(--orange-500) 352deg, rgba(242, 128, 42, 0) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: eco-spin 9s linear infinite;
}
.eco-hub__ring {
  position: absolute; inset: -22px; border-radius: 50%;
  border: 1px solid rgba(22, 119, 224, 0.16);
}
.eco-hub__ring::before, .eco-hub__ring::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid rgba(56, 182, 244, 0.5);
  animation: eco-halo 4.2s var(--ease-out) infinite;
  opacity: 0;
}
.eco-hub__ring::after { animation-delay: 2.1s; }
@keyframes eco-spin { to { transform: rotate(360deg); } }
@keyframes eco-halo {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ---------- Actores ---------- */
.eco-node { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.eco-photo {
  position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 50%;
  padding: 4px;
  background: linear-gradient(145deg, #7ad0ff 0%, #1677e0 55%, #0b2250 100%);
  box-shadow: 0 18px 34px -16px rgba(6, 20, 48, 0.45), 0 4px 10px -4px rgba(10, 95, 200, 0.25);
  transition: transform 0.6s var(--ease-out), box-shadow 0.6s var(--ease-out);
}
.eco-photo::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 1px dashed rgba(22, 119, 224, 0.28);
  transition: border-color 0.4s, transform 0.8s var(--ease-out);
}
.eco-photo::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  box-shadow: inset 0 0 0 3px #fff, inset 0 -30px 40px -20px rgba(6, 20, 48, 0.35);
  pointer-events: none;
}
.eco-photo img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  background: var(--mist-2);
  transition: transform 1s var(--ease-out), filter 0.6s;
  filter: saturate(0.96);
}
.eco-label {
  display: block; margin-top: 14px;
  font-size: 0.8rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; line-height: 1.3;
  color: var(--ink);
}

/* Hover / foco visual */
.eco-node.is-active .eco-photo, .eco-node:hover .eco-photo {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 26px 46px -18px rgba(10, 95, 200, 0.55), 0 0 0 1px rgba(56, 182, 244, 0.35);
  background: linear-gradient(145deg, #ffb070 0%, var(--orange-500) 22%, #38b6f4 60%, #0a5fc8 100%);
}
.eco-node.is-active .eco-photo::before, .eco-node:hover .eco-photo::before { border-color: rgba(242, 128, 42, 0.6); transform: rotate(40deg) scale(1.04); }
.eco-node.is-active .eco-photo img, .eco-node:hover .eco-photo img { transform: scale(1.08); filter: saturate(1.08); }
.eco-node.is-active .eco-label, .eco-node:hover .eco-label { color: var(--blue-600); }

/* ---------- Animación de entrada (solo si ecosistema.js está activo) ---------- */
.eco-stage.is-armed .eco-hub { opacity: 0; transform: scale(0.72); transition: opacity 0.9s var(--ease-out), transform 1.2s var(--ease-out); }
.eco-stage.is-armed .eco-node > * { opacity: 0; transform: translate3d(0, 22px, 0) scale(0.86); transition: opacity 0.8s var(--ease-out), transform 1.1s var(--ease-out); transition-delay: calc(0.35s + var(--i, 0) * 0.08s); }
.eco-stage.is-armed .eco-node > .eco-label { transition-delay: calc(0.5s + var(--i, 0) * 0.08s); }
.eco-stage.is-armed.is-on .eco-hub { opacity: 1; transform: none; }
.eco-stage.is-armed.is-on .eco-node > * { opacity: 1; transform: none; }

/* =========================================================================
   Escritorio: constelación radial
   ========================================================================= */
@media (min-width: 900px) {
  .eco-stage {
    --node: clamp(118px, 10.6vw, 168px);
    --hub: clamp(206px, 18.5vw, 272px);
    --rx: 39.5%;
    --ry: 38.5%;
    --oy: 49%;
    height: clamp(720px, 62vw, 930px);
    max-width: 1320px; margin-inline: auto;
  }
  .eco-canvas { display: block; }
  .eco-hub { position: absolute; left: 50%; top: var(--oy); margin: calc(var(--hub) / -2) 0 0 calc(var(--hub) / -2); }
  .eco-stage.is-armed .eco-hub { transform: scale(0.72); }
  .eco-nodes { position: absolute; inset: 0; }
  .eco-node {
    position: absolute;
    left: calc(50% + var(--cx) * var(--rx));
    top: calc(var(--oy) + var(--cy) * var(--ry));
    width: var(--node);
    margin: calc(var(--node) / -2) 0 0 calc(var(--node) / -2);
  }
  .eco-label {
    position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
    width: max-content; max-width: 190px;
    margin-top: 16px; padding: 8px 15px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(22, 119, 224, 0.14);
    box-shadow: 0 8px 20px -12px rgba(6, 20, 48, 0.3);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    font-size: 0.74rem;
    transition: color 0.3s, border-color 0.3s, box-shadow 0.3s;
  }
  .eco-stage.is-armed .eco-node > .eco-label { transform: translate3d(-50%, 18px, 0); }
  .eco-stage.is-armed.is-on .eco-node > .eco-label { transform: translateX(-50%); }
  .eco-node.is-active .eco-label, .eco-node:hover .eco-label { border-color: rgba(242, 128, 42, 0.5); box-shadow: 0 10px 24px -12px rgba(242, 128, 42, 0.45); }
  /* Las etiquetas de dos palabras largas van en dos líneas y con forma de cápsula suave */
  .eco-label { border-radius: 18px; text-wrap: balance; }
}
@media (min-width: 900px) and (max-width: 1179px) {
  .eco-stage { --rx: 40.5%; --ry: 39%; height: clamp(680px, 76vw, 820px); }
  .eco-label { max-width: 160px; font-size: 0.7rem; padding: 7px 12px; }
}

/* =========================================================================
   Tableta y móvil: núcleo arriba + rejilla
   ========================================================================= */
@media (max-width: 899px) {
  .eco-stage { --hub: clamp(170px, 34vw, 230px); display: flex; flex-direction: column; align-items: center; }
  .eco-hub { margin: 26px auto 0; }
  /* Conector vertical con pulso de luz entre el núcleo y los actores */
  .eco-stage::before {
    content: ""; display: block; order: 1;
    width: 2px; height: clamp(46px, 9vw, 70px); margin-top: 30px;
    background: linear-gradient(180deg, rgba(22, 119, 224, 0.45), rgba(56, 182, 244, 0.15));
    border-radius: 2px;
  }
  .eco-stage::after {
    content: ""; position: absolute; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
    top: calc(26px + var(--hub) + 30px);
    background: var(--cyan-400); box-shadow: 0 0 10px 3px rgba(56, 182, 244, 0.6);
    animation: eco-drop 2.4s var(--ease-in-out) infinite;
  }
  @keyframes eco-drop {
    0% { transform: translateY(0); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(clamp(46px, 9vw, 70px)); opacity: 0; }
  }
  .eco-nodes {
    order: 2; width: 100%;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 12px;
    padding: 28px clamp(12px, 3vw, 36px) clamp(30px, 4vw, 40px);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(22, 119, 224, 0.14);
    box-shadow: var(--shadow-sm);
  }
  .eco-node { min-width: 0; }
  .eco-photo { width: min(100%, 150px); }
  .eco-photo::before { inset: -6px; }
  /* Insignia bidireccional sobre cada actor */
  .eco-node::after {
    content: ""; position: absolute; z-index: 2;
    top: calc(min(100%, 150px) * 0.06); right: calc(50% - min(100%, 150px) / 2 + 2px);
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--grad-brand) center / 100% 100%;
    box-shadow: 0 0 0 3px #fff, 0 6px 12px -4px rgba(10, 95, 200, 0.6);
    -webkit-mask: none; mask: none;
  }
  .eco-node::before {
    content: ""; position: absolute; z-index: 3;
    top: calc(min(100%, 150px) * 0.06 + 6px); right: calc(50% - min(100%, 150px) / 2 + 8px);
    width: 14px; height: 14px;
    background: #fff;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h15M15 4l4 4-4 4M20 16H5M9 12l-4 4 4 4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h15M15 4l4 4-4 4M20 16H5M9 12l-4 4 4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  /* Ola de luz que recorre los actores, uno tras otro */
  .eco-photo { animation: eco-wave 5.4s var(--ease-in-out) infinite; animation-delay: calc(var(--i, 0) * 0.6s); }
  @keyframes eco-wave {
    0%, 22%, 100% { box-shadow: 0 18px 34px -16px rgba(6, 20, 48, 0.45), 0 0 0 0 rgba(56, 182, 244, 0); }
    10% { box-shadow: 0 18px 34px -16px rgba(6, 20, 48, 0.45), 0 0 0 7px rgba(56, 182, 244, 0.22); }
  }
  .eco-label { margin-top: 12px; font-size: 0.72rem; letter-spacing: 0.08em; }
}
@media (max-width: 559px) {
  .eco-nodes { gap: 26px 6px; padding: 24px 6px 26px; }
  .eco-node::after { width: 22px; height: 22px; }
  .eco-node::before { width: 12px; height: 12px; top: calc(min(100%, 150px) * 0.06 + 5px); right: calc(50% - min(100%, 150px) / 2 + 7px); }
  .eco-label { font-size: 0.8rem; font-weight: 700; letter-spacing: -0.01em; text-transform: none; line-height: 1.25; }
}
@media (max-width: 359px) {
  .eco-label { font-size: 0.74rem; -webkit-hyphens: auto; hyphens: auto; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .eco-hub__orbit, .eco-hub__ring::before, .eco-hub__ring::after, .eco-stage::after, .eco-photo { animation: none !important; }
  .eco-stage.is-armed .eco-hub, .eco-stage.is-armed .eco-node > * { opacity: 1; transform: none; transition: none; }
  .eco-stage.is-armed .eco-node > .eco-label { transform: none; }
}
@media (prefers-reduced-motion: reduce) and (min-width: 900px) {
  .eco-stage.is-armed .eco-node > .eco-label { transform: translateX(-50%); }
}
