/*
 * .listing — head + filter bar + grid of cards + "Show more"
 * (template-parts/flexible/listing.php).
 * Figma: Webinars 337:10380, Articles 337:11432, Stories 337:13059,
 * hub 337:11847; M 337:12907.
 *
 * Cards: story-card / resource-card in .listing__cell. Grid 1 → 2 → 3
 * columns, 20 px gaps; .listing__cell--wide is half a row on desktop.
 */

.listing {
  padding-top: var(--nv-section-y);
  padding-bottom: 3.125rem;
}

/* .listing:has(+ .resources) — the resources section's own top padding is the whole 50 → 100 px gap
   under "Show more" (Figma Guides D 18:45098, M 18:51445) */
.listing:has(+ .resources) {
  padding-bottom: 0;
}

/* .listing--cloud — light grey-blue band, e.g. under a featured slider */
.listing--cloud {
  background-color: var(--nv-cloud);
}

/* .post-slider + .listing — one Figma frame: 40 → 75 px between the featured card and the filters */
.post-slider + .listing {
  padding-top: clamp(2.5rem, 1.7225rem + 3.3176vw, 4.6875rem);
}

/* .post-slider + .listing:has(.listing__head) — a library with its own eyebrow and title is a new section:
   the usual 50 → 100 px (Figma Guides 18:45098) */
.post-slider + .listing:has(.listing__head) {
  padding-top: var(--nv-section-y);
}

/* .page-id-423 .post-slider + .listing — Webinars only: 40 → 97 px (Figma 1574:11327, matched visually 2026-10-14) */
.page-id-423 .post-slider + .listing {
  padding-top: clamp(2.5rem, 1.2456rem + 5.3521vw, 6.0625rem);
}

/* .listing__container — head → filters → grid → button */
.listing__container {
  display: flex;
  flex-direction: column;
  gap: var(--nv-flow-gap);
}

/* .listing--roomy — stories and cases: 75 px (Figma 337:13059), 50 → 100 px under the button */
.listing--roomy,
/* .listing:has(+ .cta) — the CTA card sits 50 → 100 px under the listing (Figma webinars 1574:11327 / 1574:11235) */
.listing:has(+ .cta) {
  padding-bottom: var(--nv-section-y);
}

.listing--roomy .listing__container {
  gap: clamp(2.5rem, 1.7225rem + 3.3176vw, 4.6875rem);
}

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

/* .listing__eyebrow — 10 px pill padding measured from the cap height (Figma 1574:14966 frame 20) */
.listing__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(1rem, 0.9111rem + 0.3792vw, 1.25rem);
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;

  /* @media (width >= 48em) .listing__eyebrow — the phone mocks track 5 %, the desktop ones 10 % */
  @media (width >= 48em) {
    letter-spacing: 0.1em;
  }

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

/* .page-id-121 / .page-id-423 .listing__eyebrow — Articles & Insights and Webinars only: eyebrow → title
   40 px on phones, 50 on desktop as elsewhere (Figma 1574:12178 / 1574:11235, matched visually 2026-10-14) */
:is(.page-id-121, .page-id-423) .listing__eyebrow {
  margin-bottom: clamp(0rem, 0.8451rem - 0.939vw, 0.625rem);
}

/* .listing__title — Figma measures the gaps from the cap height and the baseline */
.listing__title {
  max-width: 82rem;
  margin-top: -0.14em;
  margin-bottom: -0.14em;
  color: var(--nv-navy);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.3892rem + 4.7393vw, 5.625rem);
  line-height: 1;
  letter-spacing: -0.02em;

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

/* .page-id-120 .listing__title — Case Studies only: 1100 px (Pavlo, 2026-10-13) */
.page-id-120 .listing__title {
  max-width: 68.75rem;
}

/* .listing__subtitle — 20/120 % → 23/140 % (Figma 1574:14966 / 1574:15167), trimmed to cap / baseline */
.listing__subtitle {
  max-width: 65.375rem;
  margin-top: -0.24em;
  margin-bottom: -0.24em;
  color: var(--main-color);
  font-size: clamp(1.25rem, 1.1833rem + 0.2844vw, 1.4375rem);
  line-height: 1.2;
  letter-spacing: -0.03em;

  & p + p {
    margin-top: calc(1.25rem - 0.48em);
  }

  /* .listing__subtitle strong — blue lead-in (Figma 337:14145) */
  & strong {
    color: var(--nv-blue);
    font-weight: 600;
  }

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

    & p + p {
      margin-top: calc(1.25rem - 0.68em);
    }
  }
}

/* .listing__grid */
.listing__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;

  /* @media (width >= 48em) .listing__grid */
  @media (width >= 48em) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* @media (width >= 64.0625em) .listing__grid — 6 tracks: card = 2, wide card = 3 (half a row) */
  @media (width >= 64.0625em) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* .listing__cell */
.listing__cell {
  min-width: 0;

  /* @media (width >= 64.0625em) .listing__cell */
  @media (width >= 64.0625em) {
    grid-column: span 2;
  }
}

/* .listing__cell--wide — full row on tablets, half a row (690 px) on desktop */
.listing__cell--wide {
  /* @media (width >= 48em) .listing__cell--wide */
  @media (width >= 48em) {
    grid-column: span 2;
  }

  /* @media (width >= 64.0625em) .listing__cell--wide */
  @media (width >= 64.0625em) {
    grid-column: span 3;
  }
}

/* .listing__more */
.listing__more {
  display: flex;
  justify-content: center;
}

/* .listing__more-button — .outline-button, one grid column (453 px) from 768 px
   (two classes: wins over its width: 100% in any load order; the hub mock draws 449 + a 2 px outside stroke) */
.listing__more-button.outline-button {
  /* @media (width >= 48em) .listing__more-button.outline-button */
  @media (width >= 48em) {
    width: 28.3125rem;
  }
}

/* .listing__empty — nothing found: mist card, ghost, heading, text (Figma 397:37104: 1400 × 640,
   the 239 × 215 content centred; no phone frame, 60 px above and below on phones) */
.listing__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: var(--nv-radius-s);
  padding: clamp(3.75rem, 0.405rem + 14.27vw, 13.25rem) 1.25rem clamp(3.5rem, 0.155rem + 14.27vw, 13rem);
  background-color: var(--nv-mist);
  color: var(--nv-blue);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
}

/* .listing__empty-icon — 120 px ghost in the light blue */
.listing__empty-icon {
  width: 7.5rem;
  height: 7.5rem;
  color: var(--nv-blue-light);
}

/* .listing__empty-title — 32 px medium, cap height 139 px under the icon box's top */
.listing__empty-title {
  margin-top: 1rem;
  font-size: clamp(1.5rem, 1.3239rem + 0.7512vw, 2rem);
  font-weight: 500;
}

/* .listing__empty-text — 20 px, 19 px between the cap heights; wraps after "results?" as in Figma */
.listing__empty-text {
  max-width: 12.5em;
  margin-top: 0.75rem;
  font-size: clamp(1.125rem, 1.0805rem + 0.1896vw, 1.25rem);
}

/* .listing__more[hidden], .listing__empty[hidden], .listing__error[hidden] — display rules above must not show them */
.listing__more[hidden],
.listing__empty[hidden],
.listing__error[hidden] {
  display: none;
}

/* .listing__error — network error with "Try again" */
.listing__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  color: var(--nv-blue);
  font-size: clamp(1rem, 0.9556rem + 0.1896vw, 1.125rem);
  line-height: 1.4;
  text-align: center;
}

/* .listing__retry */
.listing__retry {
  height: 3.5rem;
  border-radius: 0.625rem;
  padding: 0 1.875rem;
  background-color: var(--nv-green);
  color: var(--nv-navy);
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;

  /* .listing__retry:focus-visible */
  &:focus-visible {
    outline: 0.125rem solid var(--nv-blue);
    outline-offset: 0.25rem;
  }
}

/* .listing__status — read by screen readers ("Showing 9 of 14") */
.listing__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* .listing--loading — cards fade while the next result loads */
.listing--loading .listing__grid {
  opacity: 0.5;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* @media (prefers-reduced-motion: reduce) .listing--loading */
@media (prefers-reduced-motion: reduce) {
  .listing--loading .listing__grid {
    transition: none;
  }
}
