/**
 * WD Grid Banners — Frontend CSS
 *
 * Handles grid-column spanning for partial and full-width banners
 * across WoodMart's three responsive breakpoints.
 *
 * WoodMart uses .wd-grid-g > .wd-col { grid-column: auto/span var(--wd-col) }
 * We override with high specificity + !important where needed.
 */

/* ─── Generic banner item container ─────────────────────────────────────────── */
.wd-grid-g .wd-banner-item,
.wd-grid-f-col .wd-banner-item {
  min-height: 0;
  min-width: 0;
}

/* ─── Partial-width spans (Desktop) ─────────────────────────────────────────── */
.wd-grid-g .wd-banner-item:not(.wd-banner--full-width),
.wd-grid-f-col .wd-banner-item:not(.wd-banner--full-width) {
  grid-column: span var(--banner-span-lg, 1) !important;
}

.wd-grid-g .wd-banner--end:not(.wd-banner--full-width),
.wd-grid-f-col .wd-banner--end:not(.wd-banner--full-width) {
  grid-column: var(--banner-col-start-lg, auto) / span var(--banner-span-lg, 1) !important;
}

/* ─── Partial-width Image Banner: Zero-Intrinsic-Height Row Fill ───────────────
 * The banner must NEVER determine or enlarge the CSS Grid track row height.
 * The row height is established by the normal product cards in that row.
 * We use an absolute fill strategy on the inner wrapper so the image contributes
 * 0 intrinsic height to CSS Grid track sizing while stretching to the row height.
 */
.wd-grid-g .wd-banner--image:not(.wd-banner--full-width),
.wd-grid-f-col .wd-banner--image:not(.wd-banner--full-width) {
  height: 100%;
  position: relative;
  overflow: hidden;
  align-self: stretch;
}

.wd-banner--image:not(.wd-banner--full-width) .wd-banner-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.wd-banner--image:not(.wd-banner--full-width) .wd-banner-link {
  display: block;
  width: 100%;
  height: 100%;
}

.wd-banner--image:not(.wd-banner--full-width) .wd-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* ─── Elementor Template & HTML Block Banners ──────────────────────────────── */
.wd-banner--elementor .wd-banner-inner,
.wd-banner--html_block .wd-banner-inner {
  position: relative;
  height: 100%;
  overflow: visible;
}

/* ─── Full-Width Banner ───────────────────────────────────────────────────────
 * Spans 1 / -1 across the entire grid row with independent natural height.
 * Not cropped to product-card row height.
 */
.wd-grid-g .wd-banner--full-width,
.wd-grid-f-col .wd-banner--full-width {
  grid-column: 1 / -1 !important;
  max-width: 100% !important;
  flex-basis: 100% !important;
  width: 100% !important;
  height: auto !important;
  position: relative;
  overflow: visible;
}

.wd-banner--full-width .wd-banner-inner {
  position: relative;
  height: auto;
  overflow: visible;
  width: 100%;
}

.wd-banner--full-width .wd-banner-img {
  width: 100%;
  height: auto;
  object-fit: initial;
  display: block;
}

.wd-banner--full-width .wd-banner-link {
  display: block;
  width: 100%;
}

/* ─── Tablet breakpoint (WoodMart: max-width 1024px) ───────────────────────── */
@media (max-width: 1024px) {
  .wd-grid-g .wd-banner-item:not(.wd-banner--full-width),
  .wd-grid-f-col .wd-banner-item:not(.wd-banner--full-width) {
    grid-column: span var(--banner-span-md, 1) !important;
  }

  .wd-grid-g .wd-banner--end:not(.wd-banner--full-width),
  .wd-grid-f-col .wd-banner--end:not(.wd-banner--full-width) {
    grid-column: var(--banner-col-start-md, auto) / span var(--banner-span-md, 1) !important;
  }
}

/* ─── Mobile breakpoint (WoodMart: max-width 768.98px) ─────────────────────── */
@media (max-width: 768.98px) {
  .wd-grid-g .wd-banner-item:not(.wd-banner--full-width),
  .wd-grid-f-col .wd-banner-item:not(.wd-banner--full-width) {
    grid-column: span var(--banner-span-sm, 1) !important;
  }

  .wd-grid-g .wd-banner--end:not(.wd-banner--full-width),
  .wd-grid-f-col .wd-banner--end:not(.wd-banner--full-width) {
    grid-column: var(--banner-col-start-sm, auto) / span var(--banner-span-sm, 1) !important;
  }
}
