/* ==========================================================================
   Hero
   Desktop (RTL): [copy + CTA] | [image] [feature card]
   The container's left/right edges are set from the navbar's outermost
   visible elements (--nav-edge-left/right, measured by navbar.js), so it
   lines up with them exactly. Without JS it falls back to the page gutter.
   ========================================================================== */

.hero {
  --hero-gutter: var(--space-4);
  --hero-padding: var(--space-3);        /* 24px on all four sides, every breakpoint */
  --hero-gap: var(--space-6);            /* 48px — copy ↔ media */
  --copy-width: 480px;                   /* 60 × 8 — fits "حياة سكوب.. حياة أفضل" on one line */
  --hero-radius: var(--radius-xl);       /* 48px */
  --media-gap: var(--space-2);           /* 16px — image ↔ card */
  --media-height: 352px;                 /* 44 × 8 */
  --media-radius: var(--radius-xl);
  --card-width: 232px;                   /* 29 × 8 */
  --frame-offset: var(--space-2);
  /* 80px from the navbar pills: header already adds 16px below them */
  --hero-offset: var(--space-8);

  margin-block-start: var(--hero-offset);
  padding-block-end: var(--space-6);
  scroll-margin-top: var(--header-height, 0px);
}

.hero__container {
  display: grid;
  grid-template-columns: minmax(0, var(--copy-width)) minmax(0, 1fr);
  align-items: center;
  gap: var(--hero-gap);
  margin-left: var(--nav-edge-left, var(--hero-gutter));
  margin-right: var(--nav-edge-right, var(--hero-gutter));
  padding: var(--hero-padding);
  border-radius: var(--hero-radius);
  background: var(--gradient-hero);
  overflow: hidden; /* keeps every layer inside the rounded corners */
}

/* ---- Copy ---- */
.hero__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* RTL: right edge */
  text-align: start;
}

.hero__title {
  margin: 0;
  color: var(--color-primary-700);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-h3);
}

.hero__title-line {
  display: block;
  text-wrap: balance; /* long lines wrap evenly instead of running under the image */
}

.hero__title-line--accent {
  color: var(--color-primary);
}

.hero__lead {
  max-width: 30em;
  margin: var(--space-3) 0 var(--space-4);
  color: var(--color-neutral-900);
  font-size: var(--font-size-b1);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-b1);
  text-wrap: pretty;
}

/* ---- Large CTA (extends the navbar .cta component) ---- */
.cta--lg {
  --pill-height: var(--space-8);   /* 64px */
  --cta-icon-size: var(--space-6); /* 48px */
  --cta-gap: var(--space-2);

  padding-inline: var(--space-4) var(--space-1);
  font-size: var(--font-size-b1);
  line-height: var(--line-height-b1);
  box-shadow: 0 4px 16px rgb(46 146 151 / 0.18);
  transition:
    box-shadow var(--duration-slow) var(--ease-smooth),
    filter var(--duration-slow) var(--ease-smooth),
    transform var(--duration-fast) var(--ease-smooth);
}

.cta--lg:hover {
  box-shadow: 0 8px 24px rgb(46 146 151 / 0.28);
}

.cta--lg:active {
  transform: scale(0.98);
}

/* ---- Media group ---- */
.hero__media {
  display: flex;
  align-items: stretch;
  gap: var(--media-gap);
  height: var(--media-height);
}

.hero__figure {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  /* room above for the offset frame; sideways it sits in the column gap */
  margin-block-start: var(--frame-offset);
}

/* Soft aqua/ice frame peeking out behind the image (top + right in RTL) */
.hero__figure::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: var(--media-radius);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--color-primary-100) 70%, #ffffff),
    color-mix(in srgb, var(--color-tertiary-100) 45%, #ffffff)
  );
  transform: translate(var(--frame-offset), calc(var(--frame-offset) * -1));
}

[dir="ltr"] .hero__figure::before {
  transform: translate(calc(var(--frame-offset) * -1), calc(var(--frame-offset) * -1));
}

/* Images are stacked; the one matching the active card slide fades in */
.hero__image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: var(--media-radius);
  object-fit: cover;
  object-position: var(--image-focus, 50% 50%); /* per-image focal point */
  background: var(--color-primary-100); /* calm placeholder while loading */
  opacity: 0;
  transition: opacity 700ms var(--ease-smooth);
}

.hero__image.is-active {
  z-index: 2;
  opacity: 1;
}

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

/* ---- Feature card / carousel ---- */
.feature-card {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--card-width);
  margin-block-start: var(--frame-offset); /* aligns with the image, not its frame */
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-xl);
  background: var(--color-neutral-100);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

/* Slides share one grid cell → card size = tallest slide, no layout shift */
.feature-card__slides {
  display: grid;
  flex: 1;
}

.feature-card__slide {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  opacity: 0;
  visibility: hidden;
  /* Sequential fade: outgoing text clears before the next slide appears,
     so the two never overlap mid-transition. */
  transition:
    opacity 300ms ease-out,
    visibility 0s linear 300ms;
}

.feature-card__slide.is-active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 400ms var(--ease-smooth) 300ms,
    visibility 0s linear 300ms;
}

.feature-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-circle);
  background: color-mix(in srgb, var(--color-primary-100) 45%, #ffffff);
  color: var(--color-primary);
}

.feature-card__title {
  margin: 0 0 var(--space-1);
  color: var(--color-primary-700);
  font-size: var(--font-size-b1);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-b1);
  white-space: nowrap;
}

.feature-card__desc {
  margin: 0;
  color: var(--color-neutral-900);
  font-size: var(--font-size-b3);
  line-height: var(--line-height-b3);
}

.feature-card__dots {
  display: flex;
  justify-content: center;
  gap: var(--space-0-5);
  margin-block-start: var(--space-3);
}

/* 24px hit area around an 8px dot */
.feature-card__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-3);
  height: var(--space-3);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.feature-card__dot::before {
  content: "";
  width: var(--space-1);
  height: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-neutral-300);
  transition:
    background-color var(--duration-slow) var(--ease-smooth),
    width var(--duration-slow) var(--ease-smooth);
}

.feature-card__dot:hover::before {
  background: var(--color-primary-200);
}

.feature-card__dot.is-active::before {
  width: var(--space-3);
  background: var(--color-primary);
}

.feature-card__dot:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 0;
}

@media (prefers-reduced-motion: reduce) {
  .feature-card__slide,
  .feature-card__slide.is-active {
    transition: none;
  }
}

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

/* Mid desktops: tighter type + spacing, same composition */
@media (max-width: 1599.98px) {
  .hero {
    --hero-gutter: var(--space-3);
    --hero-gap: var(--space-5);
    --copy-width: 448px;
    --media-height: 352px;
    --card-width: 216px;
  }

  .hero__lead {
    font-size: var(--font-size-b2);
    line-height: var(--line-height-b2);
  }
}

@media (min-width: 1280px) and (max-width: 1439.98px) {
  .hero {
    --copy-width: 400px;
    --media-height: 320px;
    --card-width: 200px;
  }

  .hero__title {
    font-size: var(--font-size-h4);
    line-height: var(--line-height-h4);
  }

  .feature-card {
    padding-inline: var(--space-2);
  }
}

/* Tablet: copy on top, image + card stay side by side underneath */
@media (max-width: 1279.98px) {
  .hero {
    --hero-gap: var(--space-5);
    --media-height: 384px;
  }

  .hero__container {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero__title {
    font-size: var(--font-size-h4);
    line-height: var(--line-height-h4);
  }
}

@media (max-width: 899.98px) {
  .hero {
    --media-height: 304px; /* 38 × 8 — keeps the image horizontal next to the card */
  }
}

/* Mobile: everything stacks; card sits under the image */
@media (max-width: 767.98px) {
  .hero {
    --hero-gutter: var(--space-2);
    --hero-gap: var(--space-4);
    --hero-radius: var(--space-4);   /* 32px */
    --media-radius: var(--space-3);  /* 24px */
    --frame-offset: var(--space-1);
    --hero-offset: 72px; /* header adds 8px on mobile → 80px total */

    padding-block-end: var(--space-4);
  }

  .hero__title {
    font-size: var(--font-size-h5);
    line-height: var(--line-height-h5);
  }

  .hero__lead {
    font-size: var(--font-size-b2);
    line-height: var(--line-height-b2);
  }

  .hero__media {
    flex-direction: column;
    gap: var(--space-3);
    height: auto;
  }

  .hero__figure {
    aspect-ratio: 4 / 3;
    margin-inline-end: var(--frame-offset);
  }

  .feature-card {
    flex-basis: auto;
    margin-block-start: 0;
    padding: var(--space-3);
    border-radius: var(--radius-panel);
  }

  /* Horizontal layout inside the card: icon beside the text */
  .feature-card__slide {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-2);
    text-align: start;
  }

  .feature-card__icon {
    flex: none;
    width: var(--space-7);
    height: var(--space-7);
  }

  .feature-card__dots {
    justify-content: flex-start;
    margin-block-start: var(--space-2);
  }

  /* Larger touch targets on phones */
  .feature-card__dot {
    width: var(--space-5);
    height: var(--space-5);
  }

  .feature-card__dots {
    gap: 0;
    margin-inline-start: calc(var(--space-2) * -1 + var(--space-0-5));
  }
}

@media (max-width: 359.98px) {
  .hero__title {
    font-size: var(--font-size-h7);
    line-height: var(--line-height-h7);
  }
}
