/* Stats Section Component */

.doghouse-stats-section {
  container-type: inline-size;
  container-name: stats;
  padding: var(--site-space-2xl) var(--site-container-padding);
  max-width: var(--site-container-max-width);
  margin: 0 auto;
  border-top: 1px solid var(--site-color-border-subtle);
  border-bottom: 1px solid var(--site-color-border-subtle);
}

.doghouse-stats-section__heading {
  text-align: center;
  margin: 0 0 var(--site-space-xl);
}

/* The field wrapper is an extra div inside __grid, so target it.
 * Flex (not grid) so 1–3 items grow to fill the row instead of leaving
 * an empty 4th slot. Basis values match what a 2-/4-col grid would give. */
.doghouse-stats-section__grid > div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--site-space-lg);
}

.doghouse-stats-section__grid > div > div {
  flex: 1 1 calc(50% - var(--site-space-lg) * 0.5);
}

@container stats (min-width: 768px) {
  .doghouse-stats-section__grid > div > div {
    flex: 1 1 calc(25% - var(--site-space-lg) * 0.75);
  }
}

/* Bordered variant
 * Accent-colored frame around the grid only — heading sits above, outside
 * the frame. Accent resolves to the node's --dh-accent (set by
 * field_accent_color on the parent node), with a primary fallback.
 */
.doghouse-stats-section--bordered {
  --dh-stats-accent: var(--dh-accent, var(--site-color-primary));
  border-top: 0;
  border-bottom: 0;
}

.doghouse-stats-section--bordered .doghouse-stats-section__grid {
  border: 1px solid var(--dh-stats-accent);
  border-radius: var(--site-radius-lg);
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--dh-stats-accent) 14%, transparent) 0%,
    color-mix(in srgb, var(--dh-stats-accent) 4%, transparent) 50%,
    transparent 100%
  );
  padding: var(--site-space-base);
}

/* Tighter stat sizing when inside a bordered frame */
.doghouse-stats-section--bordered .doghouse-stat-display__value {
  font-size: 2rem;
}

.doghouse-stats-section--bordered .doghouse-stat-display__label {
  font-family: monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Eyebrow is hidden by default — only the Glow Cards variant shows it */
.doghouse-stats-section .doghouse-stat-display__eyebrow {
  display: none;
}

/* ──────────────────────────────────────────────────────────────
 * Full-width gradient variant
 * The section is constrained by default; we break the grid out
 * to full viewport width, apply a soft vertical gradient and
 * top/bottom rules, then re-constrain the inner 4-col row.
 * Heading stays within the constrained flow, above the bar.
 * ────────────────────────────────────────────────────────────── */
.doghouse-stats-section--full-width-gradient {
  --dh-stats-accent: var(--dh-accent, var(--site-color-primary));
  max-width: none;
  padding-left: 0;
  padding-right: 0;
  border-top: 0;
  border-bottom: 0;
}

.doghouse-stats-section--full-width-gradient .doghouse-stats-section__heading {
  max-width: var(--site-container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--site-container-padding);
}

.doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid {
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  background: linear-gradient(
    180deg,
    var(--site-color-bg-surface-card) 0%,
    var(--site-color-bg-primary) 100%
  );
  border-top: 1px solid var(--site-color-border-subtle);
  border-bottom: 1px solid var(--site-color-border-subtle);
}

.doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div {
  max-width: var(--site-container-max-width);
  margin: 0 auto;
  padding: 0 var(--site-container-padding);
  gap: 0;
}

/* Border lives on the per-item wrapper div (Drupal's field formatter adds one
 * around each stat-display). Mobile-first: 2-col layout, so every 2nd cell
 * is the rightmost in its row and should drop the divider. */
.doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div:nth-child(2n),
.doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div:last-child {
  border-right: 0;
}

@container stats (min-width: 768px) {
  /* 4-col desktop: restore the border on every cell, then drop it on every
   * 4th (rightmost of each row) and the final cell (handles odd counts). */
  .doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }
  .doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div:nth-child(2n) {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }
  .doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div:nth-child(4n),
  .doghouse-stats-section--full-width-gradient .doghouse-stats-section__grid > div > div:last-child {
    border-right: 0;
  }
}

.doghouse-stats-section--full-width-gradient .doghouse-stat-display {
  padding: var(--site-space-xl) var(--site-space-lg);
}

.doghouse-stats-section--full-width-gradient .doghouse-stat-display__value {
  font-size: 2.5rem;
  font-weight: var(--site-fw-extrabold);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--dh-stats-accent);
  margin-bottom: var(--site-space-sm);
  text-shadow: none;
}

.doghouse-stats-section--full-width-gradient .doghouse-stat-display__label {
  font-family: var(--site-font-sans);
  font-size: 0.8rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--site-color-text-body);
  line-height: 1.4;
}

/* ──────────────────────────────────────────────────────────────
 * Glow Cards variant
 * Each stat becomes a standalone card with a blurred accent glow
 * in the top-right corner. 3 columns on desktop.
 * ────────────────────────────────────────────────────────────── */
.doghouse-stats-section--glow-cards {
  --dh-stats-accent: var(--dh-accent, var(--site-color-primary));
  border-top: 0;
  border-bottom: 0;
}

.doghouse-stats-section--glow-cards .doghouse-stats-section__grid > div {
  display: grid;
  gap: var(--site-space-md);
  grid-template-columns: 1fr;
}

@container stats (min-width: 768px) {
  .doghouse-stats-section--glow-cards .doghouse-stats-section__grid > div {
    grid-template-columns: repeat(3, 1fr);
  }
}

.doghouse-stats-section--glow-cards .doghouse-stat-display {
  position: relative;
  overflow: hidden;
  padding: var(--site-space-lg);
  background: var(--site-color-bg-surface-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

.doghouse-stats-section--glow-cards .doghouse-stat-display::before {
  content: '';
  position: absolute;
  top: -2rem;
  right: -2rem;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  background: var(--dh-stats-accent);
  opacity: 0.1;
  filter: blur(40px);
  pointer-events: none;
}

.doghouse-stats-section--glow-cards .doghouse-stat-display__eyebrow {
  display: block;
  font-size: 0.58rem;
  font-weight: var(--site-fw-bold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dh-stats-accent);
  margin-bottom: var(--site-space-sm);
}

.doghouse-stats-section--glow-cards .doghouse-stat-display__value {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--site-color-text-white);
  margin-bottom: var(--site-space-xs);
  text-shadow: none;
}

.doghouse-stats-section--glow-cards .doghouse-stat-display__label {
  font-family: var(--site-font-sans);
  font-size: 0.78rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--site-color-text-body);
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────
 * Vertical variant
 * Each stat becomes a dark card stacked vertically. A thin accent
 * gradient rule sits at the top of each card, fading to transparent.
 * Value uses the accent color; label is small, uppercase, spaced.
 * ────────────────────────────────────────────────────────────── */
.doghouse-stats-section--vertical {
  --dh-stats-accent: var(--dh-accent, var(--site-color-coral));
  border-top: 0;
  border-bottom: 0;
}

.doghouse-stats-section--vertical .doghouse-stats-section__grid > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--site-space-md);
}

@container stats (min-width: 768px) {
  .doghouse-stats-section--vertical .doghouse-stats-section__grid > div {
    grid-template-columns: 1fr;
  }
}

.doghouse-stats-section--vertical .doghouse-stat-display {
  position: relative;
  text-align: left;
  padding: var(--site-space-md);
  background: var(--site-color-bg-surface-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--site-radius-lg);
  overflow: hidden;
}

.doghouse-stats-section--vertical .doghouse-stat-display::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    to right,
    var(--dh-stats-accent) 0%,
    color-mix(in srgb, var(--dh-stats-accent) 60%, transparent) 40%,
    transparent 100%
  );
  pointer-events: none;
}

.doghouse-stats-section--vertical .doghouse-stat-display__value {
  font-size: 2.5rem;
  font-weight: var(--site-fw-extrabold);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--dh-stats-accent);
  margin-bottom: var(--site-space-sm);
  text-shadow: none;
}

.doghouse-stats-section--vertical .doghouse-stat-display__label {
  font-family: var(--site-font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--site-color-text-label);
  line-height: 1.4;
}
