/* AiFlo Ecosystem — How it flows: inputs → brain → actions.
   Narrower cards (3×2 icon grid) leave deliberate canvas space for
   orthogonal flow lines connecting each card to the central brain. */

.ecosystem {
  padding-block: var(--section-py);
  background: linear-gradient(180deg, #ffffff 0%, #f8f7ff 100%);
  position: relative;
  overflow: hidden;
}
.ecosystem::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 760px;
  height: 760px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.08), transparent 65%);
  pointer-events: none;
  z-index: 0;
}
.ecosystem__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.ecosystem__head,
.ecosystem__diagram { position: relative; z-index: 1; }

/* ── Header ───────────────────────────────────────────────── */
.ecosystem__head {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 760px;
  margin-inline: auto;
  margin-bottom: var(--gap-head-body);
}
.ecosystem__title {
  font-family: var(--font-display);
  font-size: var(--fs-section-h2);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  text-wrap: balance;
}
.ecosystem__title-accent {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  padding: 0 12px 4px;
  border-radius: 10px;
  transform: rotate(-0.6deg);
}
.ecosystem__lede {
  font-size: var(--fs-section-lede);
  line-height: var(--lh-section-lede);
  color: var(--color-text-muted);
  max-width: 56ch;
  margin: 0;
}

/* ── Diagram grid ─────────────────────────────────────────── */
.ecosystem__diagram { max-width: 1200px; margin-inline: auto; }

/* The two outer columns are narrower than the middle (and the gap is
   wider than usual) so the canvas in between has room for flow lines. */
.ecosystem__grid {
  display: grid;
  grid-template-columns: minmax(220px, 240px) minmax(280px, 1fr) minmax(220px, 240px);
  grid-template-rows: auto auto auto;
  gap: 16px clamp(48px, 8vw, 120px);
  align-items: stretch;
  justify-content: center;
}

/* Explicit cell placement so right-column cards sit next to the hub */
.eco-card[data-eco-pos="l1"]     { grid-column: 1; grid-row: 1; }
.eco-card[data-eco-pos="l2"]     { grid-column: 1; grid-row: 2; }
.eco-card[data-eco-pos="l3"]     { grid-column: 1; grid-row: 3; }
.eco-card[data-eco-pos="r1"]     { grid-column: 3; grid-row: 1; }
.eco-card[data-eco-pos="r2"]     { grid-column: 3; grid-row: 2; }
.eco-card[data-eco-pos="r3"]     { grid-column: 3; grid-row: 3; }
.eco-hub                         { grid-column: 2; grid-row: 1 / span 2; }
.eco-card[data-eco-pos="bottom"] { grid-column: 2; grid-row: 3; }

/* ── Compact category card (3 col × 2 row icon grid) ──────── */
.eco-card {
  background: #ffffff;
  border: 1px solid rgba(100, 80, 160, 0.14);
  border-radius: 16px;
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.eco-card:hover {
  border-color: rgba(124, 58, 237, 0.32);
  transform: translateY(-2px);
}
.eco-card__lbl {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.eco-card__lbl--in  { color: #0e7490; }   /* cyan-700 — inbound */
.eco-card__lbl--out { color: #c2410c; }   /* orange-700 — action */
.eco-card__title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

/* 2 rows × 3 columns of bare icons (no per-icon container) */
.eco-card__icons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  margin-top: 10px;
  align-items: center;
  justify-items: center;
}
.eco-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
}
.eco-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Bottom card — sits in column 2 row 3, beneath the hub. 4 cols × 2 rows
   gives 8 model + infra icons in a clean square footprint. */
.eco-card__icons--bottom {
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 8px;
  margin-top: 12px;
}
.eco-card--bottom .eco-icon { width: 30px; height: 30px; }
.eco-card--bottom { padding-bottom: 16px; }

/* ── Brain hub (centre, spans 3 rows) ─────────────────────── */
.eco-hub {
  background: linear-gradient(160deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: 18px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  position: relative;
  isolation: isolate;
  /* No flex-grow on stats — pin content tight to the top so the hub
     fits in 2 grid rows without empty bottom whitespace. */
  justify-content: flex-start;
}
.eco-hub__ring {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(circle at 50% 100%, rgba(167, 124, 255, 0.14), transparent 60%);
  z-index: -1;
}
.eco-hub__logo {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(124, 58, 237, 0.18);
  display: grid;
  place-items: center;
}
.eco-hub__logo img { width: 56%; height: 56%; object-fit: contain; }
.eco-hub__tag {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  margin: 4px 0 0;
}
.eco-hub__sub {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin: 0;
  max-width: 30ch;
  line-height: 1.4;
}
.eco-hub__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 4px;
}
.eco-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.10);
  color: var(--color-primary);
  border: 1px solid rgba(124, 58, 237, 0.18);
  letter-spacing: 0.01em;
}
.eco-pill--lime {
  background: rgba(132, 204, 22, 0.12);
  color: #4d7c0f;
  border-color: rgba(132, 204, 22, 0.30);
}
.eco-pill--cyan {
  background: rgba(34, 211, 238, 0.12);
  color: #0e7490;
  border-color: rgba(34, 211, 238, 0.30);
}
.eco-hub__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  margin: 6px 0 0;
}
.eco-hub__stats > div {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(124, 58, 237, 0.14);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.eco-hub__stats dt {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}
.eco-hub__stats dd {
  font-size: 10px;
  color: var(--color-text-muted);
  margin: 3px 0 0;
  text-align: center;
}

/* ── Status / legend dots ─────────────────────────────────── */
.eco-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.eco-dot--green   { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.eco-dot--amber   { background: #fbbf24; box-shadow: 0 0 6px #fbbf24; }
.eco-dot--cyan    { background: #22d3ee; box-shadow: 0 0 6px #22d3ee; }
.eco-dot--lime    { background: #a3e635; }
.eco-dot--orange  { background: #fb923c; }
.eco-dot--purple  { background: #8b5cf6; }


/* ── Legend ───────────────────────────────────────────────── */
.ecosystem__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  margin-top: clamp(24px, 3vw, 36px);
  font-size: 12.5px;
  color: var(--color-text-muted);
}
.eco-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 960px) {
  .ecosystem__grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .eco-card[data-eco-pos="l1"] { grid-column: 1; grid-row: auto; }
  .eco-card[data-eco-pos="l2"] { grid-column: 1; grid-row: auto; }
  .eco-card[data-eco-pos="l3"] { grid-column: 1; grid-row: auto; }
  .eco-card[data-eco-pos="r1"] { grid-column: 2; grid-row: auto; }
  .eco-card[data-eco-pos="r2"] { grid-column: 2; grid-row: auto; }
  .eco-card[data-eco-pos="r3"] { grid-column: 2; grid-row: auto; }
  .eco-hub {
    grid-column: 1 / -1;
    grid-row: auto;
    order: -1; /* brain on top on mobile */
  }
  .eco-card__icons--bottom { grid-template-columns: repeat(4, 1fr); }
  .eco-card[data-eco-pos="bottom"] { grid-column: 1 / -1; grid-row: auto; }
  .ecosystem__canvas { display: none; } /* skip flow lines on mobile */
}

@media (max-width: 600px) {
  .ecosystem__grid { grid-template-columns: 1fr; }
  .eco-card[data-eco-pos="r1"],
  .eco-card[data-eco-pos="r2"],
  .eco-card[data-eco-pos="r3"] { grid-column: 1; }
}
