/* ==========================================================================
   QD Stats 03
   Flexible stat grid (any number of stats), no side dividers, row-aligned.
   All rules scoped to .sr-stats-03 so QD Stats 02 on the same page is safe.
   ========================================================================== */

.sr-stats-03 {
  --stat-icon-size: 24px;
  --stat-gap-x: 0.2rem;
  --stat-gap-y: 0.25rem;
  --stat-icon-nudge: 0.18em;
  --stat-col-gap: 2.5rem;
  --stat-row-gap: 2.5rem;   /* space between wrapped ROWS of stats */
  --stat-value-gap: 0.25rem; /* space between the number and its sub-headline */
}

/* ---------- Optional media block above the stats ---------- */
.sr-stats-03 .stats-media img,
.sr-stats-03 .stats-media video,
.sr-stats-03 .stats-media iframe,
.sr-stats-03 .stats-media dotlottie-player,
.sr-stats-03 .stats-media lottie-player {
  display: block;
  max-width: 100%;
}

.sr-stats-03 .stats-media.media-html > .media-html > :first-child,
.sr-stats-03 .stats-media iframe {
  width: 100%;
}

/* ---------- The stat grid ----------
   Column count: mobile -> tablet -> desktop. On desktop it falls back to
   --stat-count (the actual number of stats) unless an explicit count is set
   in Stats Layout, so 4 stats sit 4-up and 6 stats sit 6-up with no edits. */
.sr-stats-03 .stats-wrapper {
  display: grid;
  grid-template-columns: repeat(var(--stat-cols-sm, 1), minmax(0, 1fr));
  column-gap: var(--stat-col-gap);
  row-gap: 0;
  align-items: start;
  /* cancels the trailing margin on the last row of stats */
  margin-bottom: calc(var(--stat-row-gap) * -1);
}

@media (min-width: 768px) {
  .sr-stats-03 .stats-wrapper {
    grid-template-columns: repeat(var(--stat-cols-md, 2), minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .sr-stats-03 .stats-wrapper {
    grid-template-columns: repeat(var(--stat-cols-lg, var(--stat-count, 4)), minmax(0, 1fr));
  }
}

/* No side borders / dividers, no inner padding offsets, no stray margins.
   (QD Stats 02's gradient hairline ::after is deliberately not carried over.) */
.sr-stats-03 .stats-wrapper .stat {
  position: relative;
  margin: 0 0 var(--stat-row-gap);
  padding: 0;
  min-width: 0;
}

.sr-stats-03 .stats-wrapper .stat::after,
.sr-stats-03 .stats-wrapper .stat::before {
  content: none;
}

/* ---------- Perfect row alignment ----------
   Each stat spans two row tracks (value, description) and inherits them via
   subgrid, so every number sits on the same line and every description starts
   on the same line — regardless of how long the labels are or whether only
   some stats have an icon. Rows are per-band, so a 6-up grid wrapping to two
   rows aligns within each row. */
@supports (grid-template-rows: subgrid) {
  .sr-stats-03 .stats-wrapper {
    grid-auto-rows: auto;
    align-items: stretch;
  }

  .sr-stats-03 .stats-wrapper .stat {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
  }

  .sr-stats-03 .stat .stat__grid {
    grid-row: span 2;
    grid-template-rows: subgrid;
  }

  .sr-stats-03 .stat .stat__body {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 2;
    align-content: start;
  }

  .sr-stats-03 .stat .stat__body > .heading { grid-row: 1; margin-bottom: 0; }
  .sr-stats-03 .stat .stat__body > .description {
    grid-row: 2;
    margin-top: var(--stat-value-gap);
  }
}

/* Fallback for engines without subgrid: plain column stack. */
@supports not (grid-template-rows: subgrid) {
  .sr-stats-03 .stats-wrapper .stat {
    display: flex;
    flex-direction: column;
  }
}

/* ---------- Icon + value layout ---------- */
.sr-stats-03 .stat.has-icon .stat__grid {
  display: grid;
  grid-template-columns: var(--stat-icon-size) 1fr;
  column-gap: var(--stat-gap-x);
  row-gap: var(--stat-gap-y);
  align-items: start;
}

.sr-stats-03 .stat:not(.has-icon) .stat__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.sr-stats-03 .stat__icon {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  transform: translateY(var(--stat-icon-nudge));
}

.sr-stats-03 .stat.has-icon .stat__body { grid-column: 2; }
.sr-stats-03 .stat:not(.has-icon) .stat__body { grid-column: 1; }

.sr-stats-03 .stat__icon-imgwrap,
.sr-stats-03 .stat__icon picture,
.sr-stats-03 .stat__icon img {
  display: block;
  width: var(--stat-icon-size);
  height: var(--stat-icon-size);
  max-width: 100%;
  object-fit: contain;
}

.sr-stats-03 .stat__icon img {
  width: 100% !important;
  height: 100% !important;
}

.sr-stats-03 .stat__icon-svg svg {
  display: block;
  width: var(--stat-icon-size);
  height: var(--stat-icon-size);
}

/* ---------- Value + description typography ---------- */
.sr-stats-03 .stats-wrapper p.heading { font-weight: 600; }

.sr-stats-03 .stat .heading { line-height: 1; }
.sr-stats-03 .stat .heading .stat-counter,
.sr-stats-03 .stat .heading .stat-value-text { line-height: 1; }
.sr-stats-03 .stat .heading + .description { margin-top: var(--stat-value-gap); }

.sr-stats-03 .stat__value {
  display: inline-flex;
  align-items: baseline;
  gap: 0.08em;
  white-space: nowrap;
  background: linear-gradient(180deg, rgba(252, 252, 252, 1) 0%, rgba(252, 252, 252, 0.4) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sr-stats-03 .stat-suffix { line-height: 1; }

/* ---------- Centered variant ---------- */
.sr-stats-03 .stats-wrapper.stats-center .stat,
.sr-stats-03 .stats-wrapper.stats-center .stat .heading,
.sr-stats-03 .stats-wrapper.stats-center .stat .description {
  text-align: center;
}

.sr-stats-03 .stats-wrapper.stats-center .stat .heading.text-left,
.sr-stats-03 .stats-wrapper.stats-center .stat .description.text-left {
  text-align: center !important;
}

.sr-stats-03 .stats-wrapper.stats-center .stat.has-icon .stat__grid {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

.sr-stats-03 .stats-wrapper.stats-center .stat.has-icon .stat__icon,
.sr-stats-03 .stats-wrapper.stats-center .stat.has-icon .stat__body {
  grid-column: 1;
}

/* ---------- Footer text ---------- */
.sr-stats-03 .stats-footer-text > :last-child { margin-bottom: 0; }

@media (max-width: 767px) {
  .sr-stats-03 { padding-bottom: 0 !important; }
  .sr-stats-03:has(.stats-footer-text) { padding-bottom: inherit !important; }
}
