/**
 * Homepage flagship ecosystem section — scoped under .home-page only
 */

.home-page .imt-ecosystem-section {
  position: relative;
  padding-block: clamp(3rem, 6vw, 5.5rem);
  overflow-x: clip;
  isolation: isolate;
}

.home-page .imt-ecosystem-section::before {
  content: "";
  position: absolute;
  inset: 8% 10% 12%;
  background:
    radial-gradient(ellipse 55% 45% at 50% 42%, rgba(87, 134, 199, 0.07) 0%, transparent 72%),
    radial-gradient(ellipse 38% 32% at 12% 18%, rgba(87, 134, 199, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 38% 32% at 88% 78%, rgba(139, 111, 212, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.home-page .imt-ecosystem-section__contain {
  position: relative;
  z-index: 1;
}

/* ── Header ── */
.home-page .imt-ecosystem-header {
  text-align: center;
  margin-block-end: clamp(2rem, 4vw, 3.25rem);
}

.home-page .imt-ecosystem-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 1.15rem;
  margin-block-end: 1.15rem;
  border-radius: 999px;
  background: rgba(87, 134, 199, 0.1);
  border: 1px solid rgba(87, 134, 199, 0.16);
  color: #5786c7;
  font-family: var(--imt-font-heading, "Cairo", sans-serif);
  font-size: clamp(0.82rem, 0.78rem + 0.15vw, 0.92rem);
  font-weight: 600;
  line-height: 1.3;
}

.home-page .imt-ecosystem-heading {
  margin: 0 auto 1.1rem;
  max-width: 22em;
  font-family: var(--imt-font-heading, "Cairo", sans-serif);
  font-size: clamp(1.65rem, 1.1rem + 2.2vw, 3.35rem);
  font-weight: 800;
  line-height: 1.34;
  color: #1a2744;
}

.home-page .imt-ecosystem-heading__break {
  display: block;
}

.home-page .imt-ecosystem-subtitle {
  margin: 0 auto;
  max-width: 780px;
  font-family: var(--imt-font-body, "IBM Plex Sans Arabic", "Cairo", sans-serif);
  font-size: clamp(0.94rem, 0.88rem + 0.2vw, 1.12rem);
  line-height: 1.8;
  color: #64748b;
}

/* ── Stage (desktop/tablet grid) ── */
@media (min-width: 768px) {
  .home-page .imt-ecosystem-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 480px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: clamp(0.85rem, 1.8vw, 1.5rem);
    align-items: center;
    width: min(1240px, 100%);
    min-height: clamp(640px, 58vw, 820px);
    margin-inline: auto;
    margin-block-end: clamp(1.75rem, 3vw, 2.75rem);
  }

  .home-page .imt-ecosystem-orbits {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
  }

  .home-page .imt-ecosystem-visual {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
    align-self: center;
    z-index: 2;
    width: min(620px, 100%);
  }

  .home-page .imt-ecosystem-card {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 3;
    width: min(100%, 360px);
    min-height: clamp(128px, 12vw, 160px);
  }

  .home-page .imt-ecosystem-card.card-materials {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    align-self: end;
  }

  .home-page .imt-ecosystem-card.card-programs {
    grid-column: 3;
    grid-row: 1;
    justify-self: start;
    align-self: end;
    flex-direction: row-reverse;
  }

  .home-page .imt-ecosystem-card.card-parents {
    grid-column: 1;
    grid-row: 3;
    justify-self: end;
    align-self: start;
  }

  .home-page .imt-ecosystem-card.card-schools {
    grid-column: 3;
    grid-row: 3;
    justify-self: start;
    align-self: start;
    flex-direction: row-reverse;
  }

  .home-page .imt-ecosystem-mobile-line {
    display: none;
  }
}

/* ── Stage fallback / shared ── */
.home-page .imt-ecosystem-stage {
  position: relative;
}

.home-page .imt-ecosystem-orbits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.home-page .imt-ecosystem-orbit,
.home-page .imt-ecosystem-connector {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-orbit,
.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-connector {
  animation: imtEcoOrbitDraw 2.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-orbit--mid {
  animation-delay: 0.12s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-orbit--inner {
  animation-delay: 0.24s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-connector--materials {
  animation-delay: 0.35s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-connector--programs {
  animation-delay: 0.45s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-connector--parents {
  animation-delay: 0.55s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-connector--schools {
  animation-delay: 0.65s;
}

@keyframes imtEcoOrbitDraw {
  to {
    stroke-dashoffset: 0;
  }
}

.home-page .imt-ecosystem-node {
  opacity: 0;
  transform-origin: center;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-node {
  animation: imtEcoNodeGlow 2.8s ease-in-out infinite alternate;
  animation-delay: 1.2s;
}

@keyframes imtEcoNodeGlow {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 0.75;
  }
}

/* ── Central blob visual ── */
.home-page .imt-ecosystem-visual {
  position: relative;
  z-index: 2;
  display: block;
  width: min(620px, 100%);
  aspect-ratio: 2 / 1;
  overflow: hidden;
  background: transparent;
  border: none;
  box-shadow: none;
}

.home-page .imt-ecosystem-visual__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #fff;
}

.home-page .imt-ecosystem-visual__media {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-color: #eef4fc;
  background-image: var(--imt-eco-photo);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-clip-path: url(#imt-ecosystem-blob-clip);
  clip-path: url(#imt-ecosystem-blob-clip);
}

.home-page .imt-ecosystem-visual__img,
.home-page .imt-ecosystem-visual img.imt-ecosystem-visual__img {
  display: none;
}

.home-page .imt-ecosystem-visual__frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  mix-blend-mode: lighten;
  pointer-events: none;
}

.home-page .imt-ecosystem-visual__shape {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ── Service cards ── */
.home-page .imt-ecosystem-card {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: clamp(0.85rem, 1.4vw, 1.15rem);
  width: 100%;
  min-height: auto;
  padding: clamp(1.1rem, 1.6vw, 1.45rem) clamp(1.15rem, 1.8vw, 1.55rem);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(87, 134, 199, 0.12);
  border-radius: clamp(1.35rem, 1.8vw, 1.85rem);
  box-shadow: 0 14px 42px rgba(15, 32, 68, 0.07);
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.35s ease;
}

.home-page .imt-ecosystem-card:hover,
.home-page .imt-ecosystem-card:focus-within {
  transform: translateY(-4px);
  border-color: rgba(87, 134, 199, 0.22);
  box-shadow: 0 20px 48px rgba(15, 32, 68, 0.11);
}

.home-page .imt-ecosystem-card-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: clamp(3.25rem, 4.2vw, 3.85rem);
  height: clamp(3.25rem, 4.2vw, 3.85rem);
  border-radius: 999px;
  background: var(--imt-eco-icon-bg, rgba(87, 134, 199, 0.12));
  color: var(--imt-eco-icon-fg, #5786c7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 0 0 1px var(--imt-eco-icon-ring, rgba(87, 134, 199, 0.14)),
    0 0 18px var(--imt-eco-icon-glow, rgba(87, 134, 199, 0.12));
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.home-page .imt-ecosystem-card:hover .imt-ecosystem-card-icon {
  transform: scale(1.04);
}

.home-page .imt-ecosystem-card-icon__svg {
  width: clamp(1.45rem, 1.8vw, 1.7rem);
  height: clamp(1.45rem, 1.8vw, 1.7rem);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-page .imt-ecosystem-card-body {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.home-page .imt-ecosystem-card.card-programs .imt-ecosystem-card-body,
.home-page .imt-ecosystem-card.card-schools .imt-ecosystem-card-body {
  text-align: left;
}

.home-page .imt-ecosystem-card-title {
  margin: 0 0 0.45rem;
  font-family: var(--imt-font-heading, "Cairo", sans-serif);
  font-size: clamp(1.05rem, 0.95rem + 0.45vw, 1.35rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--imt-eco-accent, #5786c7);
}

.home-page .imt-ecosystem-card-title::before {
  content: "+ ";
  font-weight: 700;
}

.home-page .imt-ecosystem-card-desc {
  margin: 0;
  font-family: var(--imt-font-body, "IBM Plex Sans Arabic", "Cairo", sans-serif);
  font-size: clamp(0.84rem, 0.8rem + 0.15vw, 0.95rem);
  line-height: 1.72;
  color: #64748b;
}

/* Card accent tones */
.home-page .imt-ecosystem-card--blue {
  --imt-eco-accent: #5786c7;
  --imt-eco-icon-bg: rgba(87, 134, 199, 0.13);
  --imt-eco-icon-fg: #5786c7;
  --imt-eco-icon-ring: rgba(87, 134, 199, 0.18);
  --imt-eco-icon-glow: rgba(87, 134, 199, 0.14);
}

.home-page .imt-ecosystem-card--purple {
  --imt-eco-accent: #8b6fd4;
  --imt-eco-icon-bg: rgba(139, 111, 212, 0.13);
  --imt-eco-icon-fg: #7c5fd0;
  --imt-eco-icon-ring: rgba(139, 111, 212, 0.18);
  --imt-eco-icon-glow: rgba(139, 111, 212, 0.14);
}

.home-page .imt-ecosystem-card--pink {
  --imt-eco-accent: #d97a96;
  --imt-eco-icon-bg: rgba(217, 122, 150, 0.13);
  --imt-eco-icon-fg: #c96886;
  --imt-eco-icon-ring: rgba(217, 122, 150, 0.18);
  --imt-eco-icon-glow: rgba(217, 122, 150, 0.14);
}

.home-page .imt-ecosystem-card--green {
  --imt-eco-accent: #6aab84;
  --imt-eco-icon-bg: rgba(106, 171, 132, 0.13);
  --imt-eco-icon-fg: #5a9a74;
  --imt-eco-icon-ring: rgba(106, 171, 132, 0.18);
  --imt-eco-icon-glow: rgba(106, 171, 132, 0.14);
}

.home-page .imt-ecosystem-mobile-line {
  display: none;
}

/* ── CTA ── */
.home-page .imt-ecosystem-actions {
  text-align: center;
}

.home-page .imt-ecosystem-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
  padding: 14px 34px;
  border-radius: 999px;
  background: #5786c7;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: var(--imt-font-heading, "Cairo", sans-serif);
  font-size: clamp(0.92rem, 0.88rem + 0.15vw, 1rem);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(87, 134, 199, 0.32);
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.35s ease,
    box-shadow 0.35s ease;
}

.home-page .imt-ecosystem-cta:hover,
.home-page .imt-ecosystem-cta:focus-visible {
  color: #fff;
  text-decoration: none;
  background: #466aa8;
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(87, 134, 199, 0.42);
  outline: 2px solid rgba(87, 134, 199, 0.35);
  outline-offset: 3px;
}

.home-page .imt-ecosystem-cta__icon {
  width: 0.95rem;
  height: 0.95rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Scroll reveal ── */
.home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-visual,
.home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-card,
.home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-actions {
  opacity: 0;
  transform: translateY(22px);
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-visual {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: 0.08s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-card {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-card.card-materials {
  transition-delay: 0.18s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-card.card-programs {
  transition-delay: 0.28s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-card.card-parents {
  transition-delay: 0.38s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-card.card-schools {
  transition-delay: 0.48s;
}

.home-page .imt-ecosystem-section.reveal-up.active .imt-ecosystem-actions {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: 0.58s;
}

/* ── Tablet tweaks ── */
@media (min-width: 768px) and (max-width: 1200px) {
  .home-page .imt-ecosystem-stage {
    min-height: clamp(580px, 62vw, 700px);
  }

  .home-page .imt-ecosystem-card {
    width: min(100%, 320px);
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .home-page .imt-ecosystem-orbit--outer {
    opacity: 0.6;
  }
}

/* ── Mobile vertical journey ── */
@media (max-width: 767px) {
  .home-page .imt-ecosystem-section {
    padding-block: 2.5rem;
  }

  .home-page .imt-ecosystem-heading {
    max-width: none;
  }

  .home-page .imt-ecosystem-stage {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    min-height: auto;
    width: 100%;
    padding-inline: 0;
  }

  .home-page .imt-ecosystem-orbits {
    display: none;
  }

  .home-page .imt-ecosystem-visual {
    width: 100%;
    aspect-ratio: 2 / 1;
    order: 1;
    margin-block-end: 0.5rem;
  }

  .home-page .imt-ecosystem-visual__media {
    inset: 0;
  }

  .home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-visual {
    transform: translateY(22px) scale(0.98);
  }

  .home-page .imt-ecosystem-mobile-line {
    display: block;
    position: absolute;
    top: calc((100vw - 2rem) * 10 / 16 + 1.5rem);
    bottom: 0;
    inset-inline-end: calc(clamp(3.25rem, 10vw, 3.85rem) / 2);
    width: 1px;
    background: linear-gradient(180deg, rgba(87, 134, 199, 0.35) 0%, rgba(87, 134, 199, 0.08) 100%);
    pointer-events: none;
    z-index: 0;
  }

  .home-page .imt-ecosystem-card {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    min-height: auto;
    flex-direction: row;
    order: 2;
  }

  .home-page .imt-ecosystem-card.card-programs,
  .home-page .imt-ecosystem-card.card-schools {
    flex-direction: row;
  }

  .home-page .imt-ecosystem-card-body {
    text-align: right;
  }

  .home-page .imt-ecosystem-card.card-programs .imt-ecosystem-card-body,
  .home-page .imt-ecosystem-card.card-schools .imt-ecosystem-card-body {
    text-align: right;
  }

  .home-page .imt-ecosystem-actions {
    order: 3;
    margin-block-start: 0.75rem;
  }

  .home-page .imt-ecosystem-cta {
    width: 100%;
    max-width: 360px;
  }
}

@media (max-width: 430px) {
  .home-page .imt-ecosystem-section__contain {
    padding-inline: 0.15rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .home-page .imt-ecosystem-section * {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .home-page .imt-ecosystem-orbit,
  .home-page .imt-ecosystem-connector {
    stroke-dashoffset: 0;
  }

  .home-page .imt-ecosystem-node {
    opacity: 0.55;
  }

  .home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-visual,
  .home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-card,
  .home-page .imt-ecosystem-section.reveal-up:not(.active) .imt-ecosystem-actions {
    opacity: 1;
    transform: none;
  }

  .home-page .imt-ecosystem-card:hover,
  .home-page .imt-ecosystem-cta:hover {
    transform: none;
  }
}
