/* ─────────────────────────────────────────────────────────────────────────
   Component: How It Works carousel (Figma "fr How It Works Carousel",
   2745:2551). Shared by every feature detail page.

   Desktop values are the 1440 frame's, in rem. The card is a size container
   so its internals keep the 800x560 card's proportions when it is narrower
   (ratios of the 800 card in cqw).

   #ebf0d7 / #bed1a8 / #d7decf / #50722a are not @theme tokens: scoped here
   and flagged as token candidates.
   ───────────────────────────────────────────────────────────────────────── */

.hiw-carousel {
  --color-hiw-media: #ebf0d7;
  --color-hiw-border: #bed1a8;
  --color-hiw-segment: #d7decf;
  --color-hiw-arrow-off: #50722a;
  --space-hiw-edge: 1.25rem; /* mobile side padding */
  --space-hiw-card: calc(100vw - 4rem);
  --space-hiw-gap: 1.25rem;

  padding-block: 3.75rem;
  background-color: var(--color-cream);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.hiw-carousel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding-inline: var(--space-hiw-edge);
}

.hiw-carousel__title {
  margin: 0;
  font-size: 1.875rem; /* 30 */
  line-height: 2.0625rem; /* 33 */
  letter-spacing: -0.016em;
}

.hiw-carousel__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hiw-carousel__counter {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: -0.024em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hiw-carousel__buttons {
  display: flex;
  gap: 0.75rem; /* 12 */
}

.hiw-carousel__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem; /* 44 — tap target on mobile */
  height: 2.75rem;
  padding: 0;
  border: 0.0625rem solid var(--color-navy);
  border-radius: var(--radius-pill);
  background-color: var(--color-navy);
  color: var(--color-white);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.hiw-carousel__button svg {
  width: 1.375rem; /* 22 */
  height: 1.375rem;
}

/* Figma "Disabled" variant: ivory fill, 2px #bed1a8 border, arrow #50722a at 30% */
.hiw-carousel__button:disabled {
  border: 0.125rem solid var(--color-hiw-border);
  background-color: var(--color-cream);
  color: color-mix(in srgb, var(--color-hiw-arrow-off) 30%, transparent);
  cursor: default;
}

/* ── Track ──────────────────────────────────────────────────────────────── */
.hiw-carousel__track {
  display: flex;
  gap: var(--space-hiw-gap);
  margin-top: 2rem;
  /* Figma's viewport starts at the content edge (x96) and clips there, so
     the track begins at the edge: earlier cards never peek in on the left,
     the next one peeks in on the right. The end padding lets the last card
     snap to the start. */
  margin-left: var(--space-hiw-edge);
  padding-right: calc(100vw - var(--space-hiw-edge) - var(--space-hiw-card));
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.hiw-carousel__track::-webkit-scrollbar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .hiw-carousel__track {
    scroll-behavior: auto;
  }
}

.hiw-carousel__card {
  container-type: inline-size;
  display: flex;
  flex: 0 0 var(--space-hiw-card);
  flex-direction: column;
  overflow: hidden;
  border-radius: 1.5rem; /* 24 */
  scroll-snap-align: start;
}

/* Top area 800x367 with the 500x379 illustration 40 from its top, centred */
.hiw-carousel__media {
  position: relative;
  aspect-ratio: 800 / 367;
  overflow: hidden;
  border-radius: 1.5rem 1.5rem 0 0;
  background-color: var(--color-hiw-media);
}

.hiw-carousel__media img {
  position: absolute;
  top: 5cqw; /* 40 / 800 */
  left: 50%;
  width: 62.5cqw; /* 500 / 800 */
  max-width: none;
  height: auto;
  border-radius: 4.7348cqw; /* 37.88 / 800 */
  transform: translateX(-50%);
}

/* Spacing under the top area lives on the caption: it is inside the card
   (the size container), so cqw resolves against the card. On the card
   itself cqw would resolve against the viewport. */
.hiw-carousel__text {
  margin: 1.25rem 0 0;
  font-size: 1.125rem; /* 18 */
  line-height: 1.4375rem; /* 23 */
}

/* ── Progress ───────────────────────────────────────────────────────────── */
.hiw-carousel__progress {
  display: flex;
  gap: 0.5rem; /* 8 */
  margin-top: 1.8125rem; /* 29 */
  padding-inline: var(--space-hiw-edge);
}

.hiw-carousel__segment {
  flex: 1 0 0;
  height: 0.6875rem; /* 11 */
  border-radius: 0.4375rem; /* 7 */
  background-color: var(--color-hiw-segment);
  transition: background-color 0.2s ease;
}

.hiw-carousel__segment.is-current {
  background-color: var(--color-navy);
}

/* ── Tablet ─────────────────────────────────────────────────────────────── */
@media (width >= 48rem) {
  .hiw-carousel {
    --space-hiw-edge: 4rem;
    --space-hiw-card: min(50rem, calc(100vw - 10rem));
    --space-hiw-gap: 3.3125rem; /* 53 */
  }

  .hiw-carousel__text {
    margin-top: 6.25cqw; /* 50 / 800 */
    font-size: 1.625rem; /* 26 */
    line-height: 2rem; /* 32 */
  }
}

/* ── Desktop: the 1440 frame ────────────────────────────────────────────── */
@media (width >= 64rem) {
  .hiw-carousel {
    --space-hiw-edge: 6rem; /* 96 */

    padding-block: 7.375rem 6.25rem; /* 118 / 100 */
  }

  .hiw-carousel__header {
    flex-wrap: nowrap;
    padding-right: 2.875rem; /* nav ends 46 from the frame edge */
  }

  .hiw-carousel__title {
    font-size: 3.75rem; /* 60 */
    line-height: 1;
    letter-spacing: -0.024em;
  }

  .hiw-carousel__nav {
    gap: 1.5rem; /* 24 */
  }

  .hiw-carousel__counter {
    font-size: 2.5rem; /* 40 */
  }

  .hiw-carousel__button {
    width: 3.5rem; /* 56 */
    height: 3.5rem;
  }

  .hiw-carousel__track {
    margin-top: 4.625rem; /* 74 */
  }

  .hiw-carousel__card {
    height: 35rem; /* 560 */
  }

  /* Progress ends 96 short of the frame edge (1248 wide at 1440) */
  .hiw-carousel__progress {
    padding-inline: var(--space-hiw-edge);
  }
}
