/*
 * .card-grid — centred head + grid of cards (template-parts/flexible/card-grid.php).
 * Figma phase 2:
 * - Implementation "Different stakeholders…" D 510:65815 / M 510:71591 (textured rounded container, centred cards);
 * - Upgrades "A practical migration approach…" D 510:65308 + 510:65331 / M 510:71306 (green numbers, left);
 * - Assessment "How prepared is your manufacturing business…" D 510:64430 / M 510:70551 (ghost numbers, closing line).
 *
 * Cards: 1 column → 2 from 768 px → 3 from 1025 px. The row is a wrapping flex line:
 * an incomplete last row is centred for centred cards and left for left-aligned ones.
 * Modifiers: --center / --left, --boxed (textured container), --marker-none / -number / -ghost,
 * --has-subtitle (smaller heading, as in the Upgrades frame).
 */

.card-grid {
  --cg-gap: 1.25rem;
  /* Ghost number: font size and how far it sticks out above its card (Figma 120 / 56 px, 189 / 80 px) */
  --cg-ghost-size: 7.5rem;
  --cg-ghost-lift: 3.5rem;
  /* head → cards: 40 → 75 px */
  --cg-flow: clamp(2.5rem, 1.7225rem + 3.3175vw, 4.6875rem);

  padding-top: var(--nv-section-y);
  padding-bottom: var(--nv-section-y);
  background-color: var(--nv-white);

  /* .card-grid--boxed — the box is its own top edge: the section above brings the 50 → 100 px
     (phone frame 510:71591, desktop 510:65815: 118 px from the last step text) */
  &.card-grid--boxed {
    padding-top: 0;
  }

  /* @media (width >= 64.0625em) .card-grid */
  @media (width >= 64.0625em) {
    --cg-ghost-size: 11.8rem;
    --cg-ghost-lift: 5rem;
  }
}

/* .card-grid--marker-number — 10 px between the phone cards, 20 px from 1025 px */
.card-grid--marker-number {
  --cg-gap: 0.625rem;

  /* @media (width >= 64.0625em) .card-grid--marker-number */
  @media (width >= 64.0625em) {
    --cg-gap: 1.25rem;
  }
}

/* .card-grid__container, .card-grid__body — head, cards, closing line in a column */
.card-grid__container,
.card-grid__body {
  display: flex;
  flex-direction: column;
  gap: var(--cg-flow);
}

/* .card-grid__box — rounded container; phones: full width as in the phone frame */
.card-grid__box {
  position: relative;
  margin-left: -1.25rem;
  margin-right: -1.25rem;
  border-radius: var(--nv-radius-m);
  background: linear-gradient(180deg, #f6f7f9 14%, #dce5ee 100%);
  overflow: hidden;

  /* @media (width >= 48em) .card-grid__box */
  @media (width >= 48em) {
    margin-left: 0;
    margin-right: 0;
    background: linear-gradient(180deg, var(--nv-steel) 0, #f6f7f9 39%) #f6f7f9;
  }
}

/* .card-grid__box > .card-grid__body — the content sits over the texture */
.card-grid__box > .card-grid__body {
  position: relative;
  padding: var(--nv-section-y) 1.25rem;

  /* @media (width >= 48em) .card-grid__box > .card-grid__body */
  @media (width >= 48em) {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }

  /* @media (width >= 64.0625em) .card-grid__box > .card-grid__body — head 1288 px wide, cards 1200 px */
  @media (width >= 64.0625em) {
    padding-left: 3.5rem;
    padding-right: 3.5rem;
  }
}

/* .card-grid__box .card-grid__list — cards 44 px narrower than the head on desktop */
.card-grid__box .card-grid__list {
  /* @media (width >= 64.0625em) .card-grid__box .card-grid__list */
  @media (width >= 64.0625em) {
    margin-left: 2.75rem;
    margin-right: 2.75rem;
  }
}

/* .card-grid__texture — decorative layer under the content */
.card-grid__texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* .card-grid__texture-image — texture chosen in the admin fills the container */
.card-grid__texture-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* .card-grid__texture--default — theme wave (Figma 0746dd) fading to white at its edges;
   phones: covers the whole box, from 768 px: one 1920 × 889 box over the top (Figma 510:65817) */
.card-grid__texture--default {
  /* .card-grid__texture--default::before, ::after */
  &::before,
  &::after {
    content: "";
    position: absolute;
    inset: 0;

    /* @media (width >= 48em) .card-grid__texture--default::before, ::after */
    @media (width >= 48em) {
      inset: -13.75rem auto auto 50%;
      width: 120rem;
      height: 55.5625rem;
      translate: -50% 0;
    }
  }

  /* .card-grid__texture--default::before — phones: the wave of the phone frame rendered with its Figma
     filter (exposure +0.31, temperature −0.92 → light blue; Implementation M 1:15193), 375 × 449 px at the top */
  &::before {
    background: url("../../img/card-grid-texture-m.webp") 50% 0 / 100% auto no-repeat;

    /* @media (width >= 48em) .card-grid__texture--default::before */
    @media (width >= 48em) {
      background: url("../../img/card-grid-texture.webp") 50% 0 / 100% 100% no-repeat;
      /* the design wave is a bright blue-tinted layer (Figma exposure +0.71 / +0.31, temperature −0.5 / −0.92) */
      filter: sepia(1) hue-rotate(200deg) saturate(1.3) brightness(1.1);
      opacity: 0.35;
    }
  }

  /* .card-grid__texture--default::after */
  &::after {
    /* phones: the frame's radial fill — a wide ellipse at the top (centre 194 × 105 px, radii 647 × 263 px
       of the 375 px box), so the wave stays clear and the fill closes in below it */
    background: radial-gradient(172.5% 16.4375rem at 51.8% 6.5625rem, rgba(236, 240, 245, 0) 45%, #f2f5f8 100%);

    /* @media (width >= 48em) .card-grid__texture--default::after */
    @media (width >= 48em) {
      background: radial-gradient(ellipse farthest-side at 50% 50%, rgba(242, 245, 248, 0) 45%, #f2f5f8 100%);
    }
  }
}

/* .card-grid__head */
.card-grid__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.875rem, 1.4306rem + 1.8957vw, 3.125rem);
  text-align: center;
}

/* .card-grid__eyebrow — green label with a rhomb, 10 px around the cap height as in Figma Frame 20 (its sky fill is not rendered) */
.card-grid__eyebrow {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.3125rem;
  padding: calc(0.625rem - 0.14em) 0;
  color: var(--nv-green);
  font-weight: 500;
  font-size: var(--nv-fs-eyebrow);
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;

  /* @media (width >= 64.0625em) .card-grid__eyebrow */
  @media (width >= 64.0625em) {
    letter-spacing: 0.1em;
  }

  /* .card-grid__eyebrow::before — rhomb */
  &::before {
    content: "";
    flex-shrink: 0;
    width: 0.53rem;
    height: 0.53rem;
    margin-top: calc(0.5lh - 0.265rem);
    background: url("../../img/icons/rhomb.svg") center / contain no-repeat;
  }
}

/* .card-grid__title — 40 → 90 px (with a subtitle 40 → 75 px), line box trimmed to cap / baseline */
.card-grid__title {
  max-width: 82rem;
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  color: var(--nv-navy);
  font-weight: 400;
  font-size: var(--nv-fs-h2);
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: break-word;

  /* @media (width >= 48em) .card-grid__title */
  @media (width >= 48em) {
    letter-spacing: -0.02em;
  }

  & strong {
    color: var(--nv-green);
    font-weight: inherit;
  }
}

/* .card-grid--has-subtitle .card-grid__title */
.card-grid--has-subtitle .card-grid__title {
  font-size: clamp(2.5rem, 1.7225rem + 3.3175vw, 4.6875rem);
}

/* .card-grid__subtitle — 20 → 23 px, 20 → 50 px under the heading, bold first words darker (Figma 70 % navy) */
.card-grid__subtitle {
  max-width: 65.25rem;
  margin-top: calc(clamp(-0.625rem, -0.8471rem + 0.9479vw, 0rem) - 0.24em);
  margin-bottom: -0.24em;
  color: rgba(19, 33, 50, 0.7);
  font-size: var(--nv-fs-lead);
  line-height: 1.2;
  letter-spacing: -0.03em;

  & > * + * {
    margin-top: 1.25rem;
  }

  & strong {
    color: var(--nv-navy);
    font-weight: 700;
  }
}

/* .card-grid--has-subtitle .card-grid__subtitle strong — bold words keep the 70 % grey (Figma Upgrades 510:65298) */
.card-grid--has-subtitle .card-grid__subtitle strong {
  color: inherit;
}

/* .card-grid__list — wrapping row of cards */
.card-grid__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cg-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* .card-grid--center .card-grid__list */
.card-grid--center .card-grid__list {
  justify-content: center;
}

/* .card-grid--left .card-grid__list */
.card-grid--left .card-grid__list {
  justify-content: flex-start;
}

/* .card-grid--marker-ghost .card-grid__list — room for the numbers above the cards */
.card-grid--marker-ghost .card-grid__list {
  row-gap: calc(var(--cg-ghost-lift) + 1.5rem);
  padding-top: var(--cg-ghost-lift);
}

/* @media (width >= 64.0625em) .card-grid--marker-number .card-grid__list on Upgrades — rows 15 px apart,
   the second row of cards is 10 px taller than the first (240 / 230 px): 30 px between number and title
   (Figma 510:65333 / 510:65388) */
@media (width >= 64.0625em) {
  .page-id-125 .card-grid--marker-number .card-grid__list {
    row-gap: 0.9375rem;
  }

  .page-id-125 .card-grid--marker-number .card-grid__item:nth-child(n + 4) {
    gap: 1.875rem;
  }
}

/* .card-grid__item — white card; width of 1 / 2 / 3 columns */
.card-grid__item {
  position: relative;
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  min-width: 0;
  gap: 1.875rem;
  border-radius: var(--nv-radius-s);
  padding: 2.5rem 1.25rem;
  background-color: var(--nv-white);
  text-align: center;

  /* @media (width >= 48em) .card-grid__item */
  @media (width >= 48em) {
    flex-basis: calc((100% - var(--cg-gap)) / 2);
  }

  /* @media (width >= 64.0625em) .card-grid__item */
  @media (width >= 64.0625em) {
    flex-basis: calc((100% - 2 * var(--cg-gap)) / 3);
    min-height: 13.75rem;
    padding: 3.125rem 1.875rem;
  }
}

/* .card-grid--marker-none:not(.card-grid--boxed) .card-grid__item — white card on the white page keeps a thin border */
.card-grid--marker-none:not(.card-grid--boxed) .card-grid__item {
  border: 1px solid var(--nv-ice);
}

/* .card-grid--left .card-grid__item */
.card-grid--left .card-grid__item {
  text-align: left;
}

/* .card-grid__name — card title, trimmed to cap / baseline */
.card-grid__name {
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  color: var(--nv-navy);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

/* .card-grid__text — blue body text, 20 px; trimmed to cap / baseline  */
.card-grid__text {
  margin-top: -0.34em;
  margin-bottom: -0.34em;
  color: var(--nv-blue);
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.03em;

  /* @media (width >= 64.0625em) .card-grid__text */
  @media (width >= 64.0625em) {
    margin-top: -0.24em;
    margin-bottom: -0.24em;
    line-height: 1.2;
  }

  /* any tag from the editor looks like the text: size, line height and margins do not change */
  & > * {
    margin: 0;
    font: inherit;
    letter-spacing: inherit;
  }

  & > * + * {
    margin-top: 0.75em;
  }
}

/* .card-grid--marker-number .card-grid__item — thin border, number on top (Figma 510:65333 / 510:71315) */
.card-grid--marker-number .card-grid__item {
  gap: 1.25rem;
  border: 1px solid var(--nv-ice);
  padding: 1.25rem;
  min-height: 9.25rem;

  /* @media (width >= 64.0625em) .card-grid--marker-number .card-grid__item */
  @media (width >= 64.0625em) {
    min-height: 14.375rem;
    border-radius: var(--nv-radius-m);
    padding: 1.875rem 3.75rem 1.875rem 1.875rem;
  }
}

/* .card-grid--marker-number .card-grid__name — 23 → 32 px */
.card-grid--marker-number .card-grid__name {
  font-size: 1.4375rem;

  /* @media (width >= 64.0625em) .card-grid--marker-number .card-grid__name */
  @media (width >= 64.0625em) {
    font-size: 2rem;
  }
}

/* .card-grid--marker-number .card-grid__number — green number: 32 px on phones, 50 px SemiBold in a 60 px high row from 1025 px */
.card-grid--marker-number .card-grid__number {
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  color: var(--nv-green);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;

  /* @media (width >= 64.0625em) .card-grid--marker-number .card-grid__number */
  @media (width >= 64.0625em) {
    display: flex;
    align-items: center;
    height: 3.75rem;
    margin: 0;
    font-weight: 600;
    font-size: 3.125rem;
  }
}

/* .card-grid--marker-ghost .card-grid__item — Assessment card (Figma 510:64470 / 510:70565) */
.card-grid--marker-ghost .card-grid__item {
  gap: 1.875rem;
  min-height: 16.25rem;
  border: 1px solid var(--nv-ice);
  border-radius: var(--nv-radius-m);
  padding: 3.25rem 1.25rem;
  background-color: transparent;
  isolation: isolate;

  /* @media (width >= 64.0625em) .card-grid--marker-ghost .card-grid__item */
  @media (width >= 64.0625em) {
    min-height: 17.5rem;
    padding: 3.75rem 2.875rem;
  }
}

/* .card-grid--marker-ghost .card-grid__item::before — the card glass: ice 40 % with a 15 px background blur
   (Figma 1:8064, M 1:13781), over the ghost number, so the number's lower part shows blurred through it */
.card-grid--marker-ghost .card-grid__item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-color: rgb(232 242 249 / 0.4);
  -webkit-backdrop-filter: blur(0.46875rem);
  backdrop-filter: blur(0.46875rem);
}

/* .card-grid--marker-ghost .card-grid__name — 23 → 32 px SemiBold */
.card-grid--marker-ghost .card-grid__name {
  font-weight: 600;
  font-size: 1.4375rem;

  /* @media (width >= 64.0625em) .card-grid--marker-ghost .card-grid__name */
  @media (width >= 64.0625em) {
    font-size: 2rem;
  }
}

/* .card-grid--marker-ghost .card-grid__text — navy 70 %, 20 → 23 px; centred column 267 → 353 px,
   so the lines break as in Figma (510:70565 M 5/4/5 lines, 510:64470 D 4/4/4) */
.card-grid--marker-ghost .card-grid__text {
  max-width: 16.6875rem;
  margin: -0.24em auto;
  color: rgba(19, 33, 50, 0.7);
  line-height: 1.2;

  /* @media (width >= 64.0625em) .card-grid--marker-ghost .card-grid__text */
  @media (width >= 64.0625em) {
    max-width: 22.0625rem;
    font-size: 1.4375rem;
  }
}

/* .card-grid--marker-ghost .card-grid__number — large faint number sticking out above the card, under its glass */
.card-grid--marker-ghost .card-grid__number {
  position: absolute;
  top: calc(-1 * var(--cg-ghost-lift) - 0.14em);
  left: 50%;
  translate: -50% 0;
  color: var(--nv-green);
  font-weight: 700;
  font-size: var(--cg-ghost-size);
  line-height: 1;
  letter-spacing: 0.1em;
  opacity: 0.4;
  pointer-events: none;
  z-index: -2;
}

/* .card-grid__closing — bold blue closing line under the cards, 23 → 32 px */
.card-grid__closing {
  max-width: 57.875rem;
  margin: calc(clamp(0rem, 1.6943rem - 1.8957vw, 1.25rem) - 0.14em) auto -0.14em;
  color: var(--nv-blue);
  font-weight: 700;
  font-size: clamp(1.4375rem, 1.2375rem + 0.853vw, 2rem);
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: center;
  overflow-wrap: break-word;

  & > * {
    margin: 0;
  }

  & > * + * {
    margin-top: 0.5em;
  }
}
