/* =========================================================
   How it works — كيف تعمل / خطوات بدء التجربة
   Faithful rebuild of Figma node 2185:115  (canvas 1280 · height ~939)
   Scope: everything prefixed .howitworks — no :root / global styling.
   Uses global var(--border) (#6B6790) where it matches Figma exactly;
   other hues are Figma-exact hex (no matching global token):
     band bg        #F4F6FA
     eyebrow / node / wave / button   #372873
     titles         #241B4F
     faded numbers  #CEC9E8
   ========================================================= */

/* Big faded step numbers use this condensed face in Figma. */
@import url("https://fonts.googleapis.com/css2?family=Alumni+Sans+Collegiate+One&display=swap");

/* ---- Band ---------------------------------------------------------- */
.howitworks {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 52px;
  padding: 96px 60px;
  background: #f4f6fa;
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  /* the scaled scene may overhang horizontally between 900–1280px;
     clip X, keep Y visible so the big numbers can overflow upward */
  overflow-x: clip;
}
.howitworks *,
.howitworks *::before,
.howitworks *::after { box-sizing: border-box; }

/* ---- Heading ------------------------------------------------------- */
.howitworks__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.howitworks__eyebrow {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.56px;
  color: #372873;
  white-space: nowrap;
}
.howitworks__title {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  line-height: normal;
  color: #241b4f;
  white-space: nowrap;
}
/* Figma: min-w-full + w-min → subtitle wraps to the title's width */
.howitworks__sub {
  margin: 0;
  width: min-content;
  min-width: 100%;
  font-size: 18px;
  font-weight: 400;
  line-height: normal;
  color: var(--border);
}

/* ---- Flight path scene --------------------------------------------- */
.howitworks__flight {
  width: 100%;
  display: flex;
  justify-content: center;
  /* fluid downscale so the fixed 1153px scene always fits (>=1280 → 1) */
  --hw-scale: min(1, calc((100vw - 120px) / 1153));
  height: calc(420px * var(--hw-scale));
}
.howitworks__scene {
  position: relative;
  flex: 0 0 auto;
  width: 1153px;
  height: 420px;
  transform: scale(var(--hw-scale));
  transform-origin: top center;
}

/* English (LTR): the flight path is authored for RTL (step 1 → far right).
   Swap the far-left/far-right step positions so the steps read
   1 → 2 → 3 left-to-right, and horizontally flip the connecting wave so
   the node dots stay on it. Text/number glyphs are untouched (stay upright).
   Desktop only — below 900px the scene is a static vertical stack. */
@media (min-width: 901px) {
  html[dir="ltr"] .howitworks__step--1 { left: 27px; }
  html[dir="ltr"] .howitworks__step--3 { left: 875px; }
  html[dir="ltr"] .howitworks__wave { transform: scaleX(-1); }
}

/* dotted wave */
.howitworks__wave {
  position: absolute;
  top: 0;
  left: 0;
  width: 1153px;
  height: 420px;
  overflow: visible;
}
/* dots flow along the path (dasharray "2 13" → 15px cycle, offset a multiple of 15 loops seamlessly) */
.howitworks__wave path {
  animation: hwFlow 4.5s linear infinite;
}
@keyframes hwFlow {
  to { stroke-dashoffset: -150; }
}

/* the three node dots glow-pulse, staggered */
.howitworks__node { animation: hwPulse 2.6s ease-in-out infinite; }
.howitworks__step--1 .howitworks__node { animation-delay: 0s; }
.howitworks__step--2 .howitworks__node { animation-delay: 0.5s; }
.howitworks__step--3 .howitworks__node { animation-delay: 1s; }
@keyframes hwPulse {
  0%, 100% { box-shadow: 0 0 14px 0 rgba(55, 40, 115, 0.55); }
  50%      { box-shadow: 0 0 24px 4px rgba(55, 40, 115, 0.8); }
}
.howitworks__node-dot { transition: transform 0.3s ease; }
.howitworks__step:hover .howitworks__node-dot { transform: scale(1.25); }

@media (prefers-reduced-motion: reduce) {
  .howitworks__wave path,
  .howitworks__node { animation: none; }
}

/* ---- Steps --------------------------------------------------------- */
.howitworks__step {
  position: absolute;
  width: 250px;
}
.howitworks__step--1 { left: 875px; top: -21px; height: 282px; }
.howitworks__step--2 { left: 451px; top: 98px;  height: 283px; }
.howitworks__step--3 { left: 27px;  top: -24px; height: 285px; }

/* big faded number */
.howitworks__num {
  position: absolute;
  top: 0;
  font-family: "Alumni Sans Collegiate One", "Tajawal", sans-serif;
  font-weight: 400;
  font-size: 204px;
  line-height: 204px;
  letter-spacing: -4.08px;
  color: #cec9e8;
  opacity: 0.3;
  white-space: nowrap;
  pointer-events: none;
}
.howitworks__step--1 .howitworks__num { left: 87.5px; }
.howitworks__step--2 .howitworks__num { left: 90px; }
.howitworks__step--3 .howitworks__num { left: 89px; }

/* dot node */
.howitworks__node {
  position: absolute;
  left: 100px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 25px;
  background: #f4f6fa;
  box-shadow: 0 0 14px 0 rgba(55, 40, 115, 0.6);
}
.howitworks__step--1 .howitworks__node { top: 126px; }
.howitworks__step--2 .howitworks__node { top: 127px; }
.howitworks__step--3 .howitworks__node { top: 129px; }
.howitworks__node-dot {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #372873;
}

/* step text */
.howitworks__text {
  position: absolute;
  left: 0;
  width: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.howitworks__step--1 .howitworks__text { top: 189px; }
.howitworks__step--2 .howitworks__text { top: 190px; }
.howitworks__step--3 .howitworks__text { top: 192px; }
.howitworks__step-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: normal;
  color: #241b4f;
}
.howitworks__step-desc {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: normal;
  color: var(--border);
}

/* ---- CTA ----------------------------------------------------------- */
.howitworks__cta {
  box-sizing: border-box;
  width: auto;              /* auto-size to label so longer EN text fits */
  min-width: 160px;         /* keep the Figma pill width for the short AR label */
  height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 30px;
  background: #372873;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  /* physical radii from Figma: tl25 tr10 br25 bl10 */
  border-radius: 25px 10px 25px 10px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.2s ease;
}
.howitworks__cta:hover {
  filter: brightness(1.14);
  box-shadow: 0 12px 30px rgba(55, 40, 115, 0.45);
  transform: translateY(-2px);
}

/* =========================================================
   Responsive
   ========================================================= */

/* mid band: shrink the oversized number a touch so it never
   crowds neighbouring columns as the scene scales down */
@media (max-width: 1120px) {
  .howitworks { padding: 96px 40px; }
  .howitworks__flight { --hw-scale: min(1, calc((100vw - 80px) / 1153)); }
}

/* ---- Stacked fallback (< 900px) ------------------------------------ */
@media (max-width: 900px) {
  .howitworks { padding: 64px 20px; gap: 40px; }

  .howitworks__flight {
    height: auto;
    display: block;
    --hw-scale: 1;
  }
  .howitworks__wave { display: none; }

  .howitworks__scene {
    position: static;
    width: 100%;
    height: auto;
    transform: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 52px;
  }

  .howitworks__step,
  .howitworks__step--1,
  .howitworks__step--2,
  .howitworks__step--3 {
    position: static;
    left: auto;
    top: auto;
    width: 100%;
    max-width: 340px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .howitworks__num,
  .howitworks__step--1 .howitworks__num,
  .howitworks__step--2 .howitworks__num,
  .howitworks__step--3 .howitworks__num {
    position: static;
    left: auto;
    font-size: 120px;
    line-height: 1;
    letter-spacing: -2.4px;
    margin-bottom: -34px;
  }

  .howitworks__node,
  .howitworks__step--1 .howitworks__node,
  .howitworks__step--2 .howitworks__node,
  .howitworks__step--3 .howitworks__node {
    position: static;
    left: auto;
    top: auto;
    z-index: 1;
  }

  .howitworks__text,
  .howitworks__step--1 .howitworks__text,
  .howitworks__step--2 .howitworks__text,
  .howitworks__step--3 .howitworks__text {
    position: static;
    left: auto;
    top: auto;
    width: 100%;
    margin-top: 16px;
  }
}

@media (max-width: 480px) {
  .howitworks__title { font-size: clamp(28px, 8vw, 40px); white-space: normal; }
  .howitworks__cta { width: 100%; max-width: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .howitworks__cta { transition: none; }
}
