/*
 * .challenges--labeled — inner page style of the homepage challenges layout
 * (template-parts/flexible/challenges.php, field `style`).
 * Figma: D 337:17164; M 337:16729 (head), 337:16736 (cards).
 *
 * Centered head with a subtitle; cards in rows of 3 + 4 on desktop with the
 * card title as a small label next to the icon and the text as the statement.
 * Phones and tablets keep the homepage numbers (01–07) above the cards.
 * Approved frames: D 1574:18085, M 1574:17679 (cards 335 × 201, pad 25).
 * Only overrides index.css under the modifier; the homepage never loads it.
 */

/* .challenges__head--center */
.challenges__head--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.challenges--labeled {
  /* .challenges--labeled .challenges__bg-image — the photo sits at the top of the section and
     fades into the section blue below (Figma D 337:17160, M 337:16726): anchor it to the top */
  & .challenges__bg-image {
    object-position: 50% 0;
  }

  /* .challenges--labeled .challenges__title — 30 → 75 px to the subtitle (from the baseline) */
  & .challenges__title:has(+ .challenges__subtitle) {
    margin-bottom: calc(clamp(1.875rem, 0.8744rem + 4.2654vw, 4.6875rem) - 0.14em);
  }

  /* .challenges--labeled .challenges__title without a subtitle — 50 → 75 px to the cards
     (Figma Solutions M 510:71051, D 510:64817: no subtitle) */
  & .challenges__title:not(:has(+ .challenges__subtitle)) {
    margin-bottom: calc(3.125rem - 0.14em);

    /* @media (width >= 64.0625em) .challenges--labeled .challenges__title without a subtitle */
    @media (width >= 64.0625em) {
      margin-bottom: calc(4.6875rem - 0.14em);
    }
  }

  /* .challenges--labeled .challenges__subtitle — 20 px / 120 % on phones, 23 px at the
     font's normal leading on desktop (Figma "auto"); 75 px to the cards (74 on phones:
     the card numbers sit 24 px above the cards) */
  & .challenges__subtitle {
    max-width: 43rem;
    margin-top: -0.24em;
    margin-bottom: calc(4.6875rem - 0.24em);
    color: #fff;
    font-size: var(--nv-fs-lead);
    line-height: 1.2;
    letter-spacing: -0.03em;

    /* @media (width >= 48em) .challenges--labeled .challenges__subtitle */
    @media (width >= 48em) {
      margin-top: -0.25em;
      margin-bottom: calc(4.6875rem - 0.25em);
      line-height: normal;
    }
  }

  /* .challenges--labeled .challenges__number — centred in a 105 px box (Figma) */
  & .challenges__number {
    width: 6.5625rem;
    text-align: center;
  }
}

/* .challenges--no-numbers .challenges__list — no room for the phone numbers: 10 px between
   the cards (Figma M 510:71051); from 1025 px the labeled grid gap applies */
.challenges--no-numbers .challenges__list {
  gap: 0.625rem;
}

/* .challenges--labeled .challenges__card — icon + label row, statement below */
.challenges--labeled .challenges__item .challenges__card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  align-items: center;
  column-gap: 0.625rem;
  min-height: 12.5625rem;
  padding: 1.5rem;

  /* @media (width >= 48em) .challenges--labeled .challenges__item .challenges__card */
  @media (width >= 48em) {
    column-gap: 0.75rem;
  }
}

.challenges--labeled .challenges__item .challenges__icon {
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0;
  object-fit: contain;
}

.challenges--labeled .challenges__item .challenges__card-title {
  margin-bottom: 0;
  color: var(--nv-green);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* .challenges--labeled .challenges__item .challenges__card-text — 50 → 63 px under the icon
   row, measured to the cap top: 24 px / 100 % on phones, 23 px / 120 % from 768 px */
.challenges--labeled .challenges__item .challenges__card-text {
  grid-column: 1 / -1;
  margin-top: calc(clamp(3.125rem, 2.8362rem + 1.2322vw, 3.9375rem) - 0.14em);
  margin-bottom: -0.14em;
  color: #fff;
  font-weight: 500;
  font-size: clamp(1.4375rem, 1.5222rem - 0.0948vw, 1.5rem);
  line-height: 1;
  letter-spacing: -0.02em;

  /* @media (width >= 48em) .challenges--labeled .challenges__item .challenges__card-text */
  @media (width >= 48em) {
    margin-top: calc(clamp(3.125rem, 2.8362rem + 1.2322vw, 3.9375rem) - 0.24em);
    margin-bottom: -0.24em;
    line-height: 1.2;
  }

  /* @media (width >= 64.0625em) .challenges--labeled .challenges__item .challenges__card-text —
     Figma wraps the statements in 278 px */
  @media (width >= 64.0625em) {
    max-width: 17.375rem;
  }
}

/* @media (width >= 64.0625em) .challenges--labeled .challenges__card-text on Support and Business
   Apps — Figma hand-sizes the statement boxes: 368 px in the first row (307–368), 435 px in the
   wide second-row cards (Figma phase 2 510:65117–65141) */
@media (width >= 64.0625em) {
  :is(.page-id-126, .page-id-127) .challenges--labeled .challenges__item .challenges__card-text {
    max-width: 23rem;
  }

  :is(.page-id-126, .page-id-127) .challenges--labeled .challenges__item:nth-child(n + 4) .challenges__card-text {
    max-width: 27.1875rem;
  }

  /* Support — its boxes are 307 / 336 / 368 / 346 / 435 px */
  .page-id-126 .challenges--labeled .challenges__item:nth-child(1) .challenges__card-text {
    max-width: 19.1875rem;
  }

  .page-id-126 .challenges--labeled .challenges__item:nth-child(2) .challenges__card-text {
    max-width: 21rem;
  }

  .page-id-126 .challenges--labeled .challenges__item:nth-child(4) .challenges__card-text {
    max-width: 21.625rem;
  }
}

/* .challenges--labeled .challenges__card on Support and Business Apps — fill 20 % white
   (Figma phase 2 510:65115; the sprint-2 pages keep the 10 % of index.css) */
:is(.page-id-126, .page-id-127) .challenges--labeled .challenges__item .challenges__card {
  background: rgb(255 255 255 / 0.2);
}

/* @media (width >= 64.0625em) .challenges--labeled — rows of 3 + 4, no numbers */
@media (width >= 64.0625em) {
  .challenges--labeled .challenges__list {
    flex-wrap: wrap;
    gap: 1.25rem;
  }

  .challenges--labeled .challenges__item {
    flex: 1 1 calc(25% - 0.9375rem);
  }

  .challenges--labeled .challenges__item:nth-child(-n + 3) {
    flex-basis: calc(33.333% - 0.8333rem);
  }

  .challenges--labeled .challenges__item .challenges__number {
    display: none;
  }


  .challenges--labeled .challenges__item .challenges__card {
    min-height: 15rem;
  }
}
