/*
 * .numbered-rows — blue section with numbered photo rows, a closing line
 * and an optional wordmark (template-parts/flexible/numbered-rows.php).
 * Figma: Plastics D 337:16213 (rows 337:16224) / M 337:15651.
 *
 * Phones and tablets: cards with the photo on top and the number over its
 * bottom-left corner. Desktop: 210 px rows — photo 400 | text | number.
 * All rows are white; no highlighted row (Vlad, 2026-10-17).
 */

.numbered-rows {
  position: relative;
  padding-top: var(--nv-section-y);
  padding-bottom: var(--nv-section-y);
  background-color: var(--nv-blue);
  overflow: hidden;
}

/* .numbered-rows--bottom-image — the wordmark sits on the bottom edge */
.numbered-rows--bottom-image {
  padding-bottom: 0;

  /* .numbered-rows--bottom-image::before — wave on the bottom edge, under everything
     (Figma «wavy-black-white-background 2»: D 1574:17289 / M 1574:16728, render of the visible part) */
  &::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    aspect-ratio: 375 / 348;
    background: url("../../img/numbered-rows-wave-m.webp") center bottom / 100% auto no-repeat;
    pointer-events: none;

    /* @media (width >= 64.0625em) .numbered-rows--bottom-image::before */
    @media (width >= 64.0625em) {
      aspect-ratio: 1520 / 576;
      background-image: url("../../img/numbered-rows-wave-d.webp");
    }
  }
}

/* .numbered-rows__backdrop — photo at the top; the Figma export (1574:17290) already
   carries the mirror, the colour filters and the fade into the blue */
.numbered-rows__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(38.4375rem, 29.1292rem + 39.7156vw, 64.625rem);
  pointer-events: none;

  /* .numbered-rows__backdrop::after — phones: the blurred blue circle over the top left
     (Figma Ellipse 122: 532 px, 60 %, blur 180) */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 16.625rem, rgba(33, 91, 135, 0.6) 0, rgba(33, 91, 135, 0) 28rem);

    /* @media (width >= 64.0625em) .numbered-rows__backdrop::after */
    @media (width >= 64.0625em) {
      content: none;
    }
  }
}

/* .numbered-rows__backdrop-image — 72.5 % on phones (1088 px photo at −517, 1574:16727),
   half transparent from 1025 px */
.numbered-rows__backdrop-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--numbered-rows-bg-x, 72.5%) center;

  /* @media (width >= 64.0625em) .numbered-rows__backdrop-image — the photo starts 90 px
     from the left edge at 1520 (Figma 1574:17290), the gap shows the section blue */
  @media (width >= 64.0625em) {
    object-position: 5.921vw center;
    opacity: 0.5;
  }
}

/* .numbered-rows__backdrop--mobile — phones show the photo cropped for the phone frame
   (field background_image_mobile), centred; the desktop photo keeps its 72.5 % shift up to 1024 px */
.numbered-rows__backdrop--mobile {
  --numbered-rows-bg-x: 50%;

  /* @media (width >= 48em) .numbered-rows__backdrop--mobile */
  @media (width >= 48em) {
    --numbered-rows-bg-x: 72.5%;
  }
}

/* .numbered-rows__container — above the backdrop */
.numbered-rows__container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(3.125rem, 2.5696rem + 2.3697vw, 4.6875rem);
}

/* .numbered-rows__head */
.numbered-rows__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(1.875rem, 1.4306rem + 1.8957vw, 3.125rem);
}

/* .numbered-rows__eyebrow */
.numbered-rows__eyebrow {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.3125rem;
  padding: calc(0.625rem - 0.14em) 0.625rem;
  color: var(--nv-green);
  font-weight: 500;
  font-size: clamp(0.875rem, 0.7417rem + 0.5687vw, 1.25rem);
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;

  /* .numbered-rows__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;
  }
}

/* .numbered-rows__title — trimmed to cap / baseline; box 1310 px (Figma 510:67896 and the other
   phase 2 industry frames) */
.numbered-rows__title {
  max-width: 81.875rem;
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  color: var(--nv-white);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.3892rem + 4.7393vw, 5.625rem);
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;

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

/* .numbered-rows__subtitle — 810 px; h2 → subtitle 30 → 75 px; 120 % on phones (0.24em trims),
   160 % from 768 px (0.44em) */
.numbered-rows__subtitle {
  max-width: 50.625rem;
  margin-top: calc(clamp(0rem, -0.5554rem + 2.3697vw, 1.5625rem) - 0.24em);
  margin-bottom: -0.24em;
  color: var(--nv-white);
  font-size: clamp(1.25rem, 1.1833rem + 0.2844vw, 1.4375rem);
  line-height: 1.2;
  letter-spacing: -0.03em;

  & p + p {
    margin-top: 1.25rem;
  }

  /* @media (width >= 48em) .numbered-rows__subtitle */
  @media (width >= 48em) {
    margin-top: calc(clamp(0rem, -0.5554rem + 2.3697vw, 1.5625rem) - 0.44em);
    margin-bottom: -0.44em;
    line-height: 1.6;
  }
}

/* .numbered-rows__list — 10 px wider than the text on phones (Figma 337:15663) */
.numbered-rows__list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-inline: -0.625rem;

  /* @media (width >= 64.0625em) .numbered-rows__list */
  @media (width >= 64.0625em) {
    margin-inline: 0;
  }
}

/* .numbered-rows__item — card: photo with the number, then the text */
.numbered-rows__item {
  display: grid;
  grid-template-areas:
    "media"
    "body";
  grid-template-columns: minmax(0, 1fr);
  row-gap: 1.875rem;
  border-radius: var(--nv-radius-s);
  padding: 0.625rem 0.625rem 1.25rem;
  background-color: #fbfbfc;
  color: var(--nv-navy);

  /* @media (width >= 64.0625em) .numbered-rows__item — photo | text | number */
  @media (width >= 64.0625em) {
    grid-template-areas: "media body number";
    grid-template-columns: 25rem minmax(0, 1fr) 6.125rem;
    align-items: center;
    column-gap: 4rem;
    min-height: 13.125rem;
    padding: 0.625rem 1.875rem 0.625rem 0.625rem;
  }
}

/* .numbered-rows__item--no-image — text from the left edge */
.numbered-rows__item--no-image {
  grid-template-areas:
    "media"
    "body";

  /* @media (width >= 64.0625em) .numbered-rows__item--no-image */
  @media (width >= 64.0625em) {
    grid-template-areas: "body body number";
    padding-left: 1.875rem;
  }
}

/* .numbered-rows__media — 190 px photo */
.numbered-rows__media {
  grid-area: media;
  height: 11.875rem;
  border-radius: var(--nv-radius-s);
  overflow: hidden;
}

/* .numbered-rows__image */
.numbered-rows__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* .numbered-rows__body — 650 px on desktop */
.numbered-rows__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;

  /* @media (width >= 64.0625em) .numbered-rows__body */
  @media (width >= 64.0625em) {
    max-width: 50.8125rem;
  }
}

/* .numbered-rows__name — 24 → 32 px, trimmed to cap / baseline */
.numbered-rows__name {
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  font-weight: 500;
  font-size: clamp(1.5rem, 1.3223rem + 0.7583vw, 2rem);
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: break-word;
}

/* .numbered-rows__text — 16 → 18 px at 120 % (0.24em trims) */
.numbered-rows__text {
  margin-top: -0.24em;
  margin-bottom: -0.24em;
  color: rgba(19, 33, 50, 0.8);
  font-size: clamp(1rem, 0.9556rem + 0.1896vw, 1.125rem);
  line-height: 1.2;
  letter-spacing: -0.04em;
}

/* .numbered-rows__number — 98 × 75 over the photo; 98 × 150 on the right on desktop */
.numbered-rows__number {
  grid-area: media;
  display: flex;
  align-self: end;
  justify-self: start;
  align-items: center;
  justify-content: center;
  width: 6.125rem;
  height: 4.6875rem;
  margin: 0.625rem;
  border-radius: var(--nv-radius-s);
  background-color: rgba(168, 217, 95, 0.1);
  color: var(--nv-green);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;

  /* @media (width >= 64.0625em) .numbered-rows__number */
  @media (width >= 64.0625em) {
    grid-area: number;
    align-self: center;
    height: 9.375rem;
    margin: 0;
  }
}

/* .numbered-rows__item--no-image .numbered-rows__number — phones: own row above the text */
.numbered-rows__item--no-image .numbered-rows__number {
  margin: 0;
}

/* .numbered-rows__closing — centred, 23 → 32 px, 940 px; rows → closing line = the container
   gap (50 → 75 px); 120 % on phones (0.24em trims), 140 % from 768 px (0.34em) */
.numbered-rows__closing {
  max-width: 58.75rem;
  margin-top: -0.24em;
  margin-bottom: -0.24em;
  margin-inline: auto;
  color: var(--nv-white);
  font-weight: 500;
  font-size: clamp(1.4375rem, 1.2375rem + 0.8531vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  text-align: center;

  /* @media (width >= 48em) .numbered-rows__closing */
  @media (width >= 48em) {
    margin-top: -0.34em;
    margin-bottom: -0.34em;
    line-height: 1.4;
  }

  /* .numbered-rows__closing > p:first-child — the wrapper already trims; the .rich-text trim is reduced */
  &.rich-text > p:not(.nv-block):first-child {
    /* @media (width >= 48em) .numbered-rows__closing > p:first-child */
    @media (width >= 48em) {
      margin-top: -0.1em;
    }
  }
}

/* .numbered-rows__bottom — wordmark on the bottom edge; 40 → 6 px under the closing line's baseline */
.numbered-rows__bottom {
  margin-top: clamp(0.375rem, 3.2555rem - 3.2227vw, 2.5rem);
  line-height: 0;
}

/* .numbered-rows__bottom-image */
.numbered-rows__bottom-image {
  width: 100%;
  height: auto;
}

/* Phase 2 industry pages (Specialty Metals, Chemicals, Process, Industrial) — Figma 510:68… D / 510:73… M.
   Plastics (.postid-77) and any other page keep the rules above. */
:is(.postid-78, .postid-79, .postid-80, .postid-81) {
  /* .numbered-rows__item — phones and tablets: every card is 361 px tall (Figma M cards 1–7);
     desktop: row 01 is white, the others stay 251,251,252 (Figma D «image 27» fills) */
  & .numbered-rows__item {
    grid-template-rows: auto 1fr;
    min-height: 22.5625rem;

    /* @media (width >= 64.0625em) .numbered-rows__item */
    @media (width >= 64.0625em) {
      grid-template-rows: none;
      min-height: 13.125rem;

      &:first-child {
        background-color: var(--nv-white);
      }
    }
  }

  /* .numbered-rows__body — title → text: 25 px on phones, 28 px on desktop (design 16 / 14 px between the ink) */
  & .numbered-rows__body {
    gap: 1.5625rem;

    /* @media (width >= 64.0625em) .numbered-rows__body */
    @media (width >= 64.0625em) {
      gap: 1.75rem;
    }
  }

  /* .numbered-rows__name — design title block is narrower on phones: titles break after
     "Material & Inventory", "Heat, Lot & Batch"; widest line that must fit is 262 px */
  & .numbered-rows__name {
    max-width: 17rem;
    /* phones and tablets: a one-line title keeps the two-line slot, so every card's text starts
       at the same height (Figma M "Batch & Lot Traceability" ends with an empty line) */
    min-height: 2em;

    /* @media (width >= 64.0625em) .numbered-rows__name */
    @media (width >= 64.0625em) {
      max-width: none;
      min-height: 0;
    }
  }

  /* .numbered-rows__text — description box on desktop: 734 px, row 01 is 650 px (Figma D text boxes) */
  & .numbered-rows__text {
    /* @media (width >= 64.0625em) .numbered-rows__text */
    @media (width >= 64.0625em) {
      max-width: 45.875rem;
    }
  }

  /* .numbered-rows__item:first-child .numbered-rows__body — desktop: row 01 keeps its title 77 px under the card top
     (design) even with a 2-line text; the other rows are centred */
  & .numbered-rows__item:first-child .numbered-rows__body {
    /* @media (width >= 64.0625em) .numbered-rows__item:first-child .numbered-rows__body */
    @media (width >= 64.0625em) {
      align-self: start;
      margin-top: 4.1875rem;
    }
  }

  /* .numbered-rows__item:first-child .numbered-rows__text */
  & .numbered-rows__item:first-child .numbered-rows__text {
    /* @media (width >= 64.0625em) .numbered-rows__item:first-child .numbered-rows__text */
    @media (width >= 64.0625em) {
      max-width: 40.625rem;
    }
  }
}

/* .numbered-rows__picture — optional phone source around the photo (inc/template-tags.php naviona_image_with_mobile());
   the <img> keeps its own box */
.numbered-rows__picture {
  display: contents;
}
