.ecosystem {
  padding-block: clamp(52px, 5.7vw, 88px);
  background: #101010;
  border-block: 1px solid #2c2a2a;
}

.ecosystem .section-head {
  margin-bottom: clamp(24px, 3.5vw, 48px);
}

.ecosystem-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(26px, 5.4vw, 82px);
}

.ecosystem-map {
  --map-gap: clamp(12px, 3.15vw, 46px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .92fr) minmax(0, 1fr);
  grid-template-areas:
    "bot hub crm"
    "mini hub qr"
    "website hub automation";
  grid-auto-rows: minmax(46px, auto);
  gap: 9px var(--map-gap);
}

.ecosystem-hub {
  grid-area: hub;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-inline: 1px solid #73383a;
  background: #170f10;
  text-align: center;
}

.ecosystem-hub strong {
  font: 750 clamp(.52rem, 1.27vw, 1.1rem)/1.2 var(--heading);
  letter-spacing: -.075em;
}

.ecosystem-hub strong span { color: var(--accent); }

.ecosystem-hub > span {
  color: var(--muted);
  font: 500 clamp(.6rem, 1.02vw, .76rem)/1.3 var(--mono);
}

.ecosystem-node {
  position: relative;
  width: 100%;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  padding: 7px 6px;
  background: #151515;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--white);
  text-align: center;
  font: 650 clamp(.68rem, 1.09vw, .9rem)/1.3 var(--mono);
  transition: background-color .2s ease, border-color .2s ease;
}

.ecosystem-node[data-node="bot"] { grid-area: bot; }
.ecosystem-node[data-node="mini-app"] { grid-area: mini; }
.ecosystem-node[data-node="website"] { grid-area: website; }
.ecosystem-node[data-node="crm"] { grid-area: crm; }
.ecosystem-node[data-node="qr"] { grid-area: qr; }
.ecosystem-node[data-node="automation"] { grid-area: automation; }

.ecosystem-node::after,
.ecosystem-node::before {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 100%;
  pointer-events: none;
}

.ecosystem-node::after {
  inline-size: calc(var(--map-gap) + 2px);
  block-size: 1px;
  background: #664045;
}

.ecosystem-node:is([data-node="crm"], [data-node="qr"], [data-node="automation"])::after,
.ecosystem-node:is([data-node="crm"], [data-node="qr"], [data-node="automation"])::before {
  inset-inline-start: auto;
  inset-inline-end: 100%;
}

.ecosystem-node[aria-pressed="true"] {
  border-color: var(--accent);
  background: #211215;
}

.ecosystem-node:is([aria-pressed="true"], .receives-data)::after { background: var(--accent); }

.is-in-view .ecosystem-node:is([aria-pressed="true"], .receives-data)::before {
  --distance: var(--map-gap);
  z-index: 1;
  inline-size: 5px;
  block-size: 5px;
  margin-block-start: -2px;
  border-radius: 50%;
  background: var(--white);
  animation: ecosystem-transfer 620ms cubic-bezier(.22, .65, .36, 1) both;
}

.ecosystem-node:is([data-node="crm"], [data-node="qr"], [data-node="automation"]):is([aria-pressed="true"], .receives-data)::before {
  --distance: calc(-1 * var(--map-gap));
}

.ecosystem-node.receives-data::before {
  animation-delay: 540ms;
  animation-direction: reverse;
}

@media (prefers-reduced-motion: no-preference) {
  .ecosystem-map.is-in-view .ecosystem-node { animation: module-arrival .38s ease-out var(--arrival, 0ms); }
  .ecosystem-node[data-node="mini-app"] { --arrival: 125ms; }
  .ecosystem-node[data-node="website"] { --arrival: 250ms; }
  .ecosystem-node[data-node="crm"] { --arrival: 390ms; }
  .ecosystem-node[data-node="qr"] { --arrival: 515ms; }
  .ecosystem-node[data-node="automation"] { --arrival: 640ms; }
  @keyframes module-arrival {
    42% { box-shadow: inset 0 0 0 1px var(--accent); }
  }
}

@keyframes ecosystem-transfer {
  0% { transform: translateX(0); opacity: 0; }
  20% { opacity: 1; }
  82% { opacity: 1; }
  100% { transform: translateX(var(--distance)); opacity: 0; }
}

@media (hover: hover) {
  button.ecosystem-node:hover { border-color: var(--accent); }
}

.ecosystem-detail {
  min-height: 100px;
  padding: 2px 0 3px 16px;
  border-inline-start: 2px solid var(--accent);
}

.ecosystem-detail h3 { font-size: clamp(.95rem, 1.45vw, 1.22rem); }

.ecosystem-detail p {
  max-width: 49ch;
  margin-block-start: 8px;
  color: var(--muted);
  font-size: .91rem;
  line-height: 1.55;
}

.ecosystem-note {
  margin-block-start: 12px;
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.45;
}

.ecosystem-scenario {
  margin-block-start: clamp(48px, 6.6vw, 94px);
  padding-block-start: clamp(27px, 3.1vw, 45px);
  border-block-start: 1px solid var(--line);
}
.ecosystem-scenario h3 {
  font-size: clamp(1.48rem, 3vw, 3.05rem);
  line-height: 1.12;
  text-wrap: balance;
}
.ecosystem-scenario h3 span { color: var(--accent); }
.ecosystem-scenario-intro { margin-block-start: 10px; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.2rem); }
.ecosystem-steps {
  --step-gap: clamp(16px, 2.6vw, 38px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--step-gap);
  list-style: none;
  margin: clamp(24px, 3.4vw, 46px) 0 0;
  padding: 0;
}
.ecosystem-step { position: relative; min-width: 0; }
.ecosystem-step-marker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 51px;
  color: var(--white);
}
.ecosystem-step-marker span { color: var(--accent); font: 650 clamp(2.2rem, 4vw, 3.5rem)/1 var(--mono); letter-spacing: -.09em; }
.ecosystem-step-marker svg { flex: none; }
.ecosystem-step-marker::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 61px auto auto 0;
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
}
.ecosystem-step:not(:last-child)::before,
.ecosystem-step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset: 65px auto auto 4px;
  width: calc(100% + var(--step-gap));
  height: 1px;
  background: var(--line);
}
.ecosystem-step:not(:last-child)::after { background: var(--accent); transform-origin: left center; }
.ecosystem-step-copy { margin-block-start: 34px; }
.ecosystem-step h4 { margin: 0; color: var(--white); font-family: var(--heading); font-weight: 650; font-size: clamp(.95rem, 1.35vw, 1.23rem); line-height: 1.3; }
.ecosystem-step p { margin-block-start: 7px; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.ecosystem-scenario-outro {
  margin-block-start: clamp(25px, 3.2vw, 46px);
  padding-block-start: 17px;
  border-block-start: 1px solid var(--line);
  color: var(--white);
  font-size: clamp(1rem, 1.45vw, 1.18rem);
  font-weight: 650;
}

@media (max-width: 799px) {
  .ecosystem-steps { grid-template-columns: minmax(0, 1fr); --step-gap: 21px; }
  .ecosystem-step { padding-inline-start: 26px; }
  .ecosystem-step-marker { justify-content: flex-start; gap: 16px; min-height: 36px; }
  .ecosystem-step-marker::after { inset-block-start: 14px; }
  .ecosystem-step-copy { margin-block-start: 7px; }
  .ecosystem-step:not(:last-child)::before,
  .ecosystem-step:not(:last-child)::after { inset-block-start: 18px; width: 1px; height: calc(100% + var(--step-gap)); }
  .ecosystem-step:not(:last-child)::after { transform-origin: center top; }
}

@media (prefers-reduced-motion: no-preference) {
  .ecosystem-steps.is-sequenced .ecosystem-step {
    --step-delay: 0ms;
    --line-scale: scaleX(0);
  }
  .ecosystem-steps.is-sequenced .ecosystem-step-copy {
    transform: translateY(6px);
    transition: transform 260ms ease-out var(--step-delay);
  }
  .ecosystem-steps.is-sequenced .ecosystem-step.is-active .ecosystem-step-copy { transform: none; }
  .ecosystem-steps.is-sequenced .ecosystem-step-marker::after {
    background: #101010;
    transition: background-color 160ms var(--step-delay);
  }
  .ecosystem-steps.is-sequenced .ecosystem-step:not(:last-child)::after {
    transform: var(--line-scale);
    transition: transform 240ms ease-out var(--step-delay);
  }
  .ecosystem-steps.is-sequenced .ecosystem-step.is-active::after { transform: none; }
  .ecosystem-steps.is-sequenced .ecosystem-step.is-active .ecosystem-step-marker::after { background: var(--accent); }
}
@media (min-width: 800px) and (prefers-reduced-motion: no-preference) {
  .ecosystem-steps.is-sequenced .ecosystem-step:nth-child(2) { --step-delay: 135ms; }
  .ecosystem-steps.is-sequenced .ecosystem-step:nth-child(3) { --step-delay: 270ms; }
  .ecosystem-steps.is-sequenced .ecosystem-step:nth-child(4) { --step-delay: 405ms; }
  .ecosystem-steps.is-sequenced .ecosystem-step:nth-child(5) { --step-delay: 540ms; }
}
@media (max-width: 799px) and (prefers-reduced-motion: no-preference) {
  .ecosystem-steps.is-sequenced .ecosystem-step { --line-scale: scaleY(0); }
}

@media (max-width: 799px) {
  .ecosystem-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .ecosystem-map { max-width: 620px; }
  .ecosystem-hub strong { font-size: clamp(.63rem, 1.6vw, 1rem); }
  .ecosystem-detail { min-height: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .ecosystem-node { transition: none; }
  .ecosystem-node:is([aria-pressed="true"], .receives-data)::before { animation: none; content: none; }
}
