/* ==========================================================================
   WooGrub — layout.css
   Page-level layout, containers, max-widths, and structural spacing.
   ========================================================================== */

/* ── Page wrapper ────────────────────────────────────────────────────────── */
/* Use grid on body to push footer to bottom without causing extra scroll.
   grid-template-rows: auto 1fr auto = header | content (fills gap) | footer */
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* ── Closed-store banner offset ──────────────────────────────────────────── */
/* The plugin's fixed banner reserves no space. banner-offset.js measures its
   height into --wg-banner-height and adds .wg-store-closed to <body>. Padding
   the body shifts ALL in-flow body children (header, category nav,
   .wp-site-blocks, footer) down by the banner height in one move. We pad <body>
   (not <html>) so this never compounds with the admin bar's html margin-top. */
body.wg-store-closed {
  padding-block-start: var(--wg-banner-height, 0px);
}

.wg-site {
  display: contents; /* passthrough — children participate in body grid */
}

.wg-main {
  /* occupies the 1fr row, stretching to fill available space */
}

/* ── Containers ──────────────────────────────────────────────────────────── */
.wg-container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--wg-space-4);
}

@media (min-width: 640px) {
  .wg-container {
    padding-inline: var(--wg-space-6);
  }
}

@media (min-width: 1024px) {
  .wg-container {
    padding-inline: var(--wg-space-8);
  }
}

/* Narrow container — used for checkout, single-column content */
.wg-container--narrow {
  max-width: 720px;
}

/* Wide container — used for shop page */
.wg-container--wide {
  max-width: 1600px;
}

/* ── Section spacing ─────────────────────────────────────────────────────── */
.wg-section {
  padding-block: var(--wg-space-12);
}

.wg-section--sm {
  padding-block: var(--wg-space-8);
}

.wg-section--lg {
  padding-block: var(--wg-space-16);
}

/* ── Shop page layout ────────────────────────────────────────────────────── */
/*
 * The shop page is a single scrolling column.
 * The sticky category navbar sits below the main header.
 * Content begins after the navbar offset.
 */
.wg-shop-page {
  padding-block-start: 0; /* navbar handles its own top offset */
}

.wg-shop-content {
  padding-block: var(--wg-space-6);
}

/* Each category section */
.wg-category-section {
  margin-block-end: var(--wg-space-10);
  scroll-margin-top: calc(var(--wg-navbar-height, 48px) + var(--wg-space-4));
}

.wg-category-section:last-child {
  margin-block-end: 0;
}

.wg-category-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--wg-text);
  margin-block-end: var(--wg-space-4);
}

/* Product cards grid within a category section */
.wg-product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--wg-space-3);
}

@media (min-width: 560px) {
  .wg-product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wg-space-4);
  }
}

/* ── Overlay backdrop ────────────────────────────────────────────────────── */
/* Shared by modal and floating cart on mobile */
.wg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--wg-z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--wg-transition-slow);
}

.wg-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Empty / unavailable state ───────────────────────────────────────────── */
.wg-empty-state {
  text-align: center;
  padding: var(--wg-space-16) var(--wg-space-8);
  color: var(--wg-text-muted);
}

.wg-empty-state__icon {
  font-size: 3rem;
  margin-block-end: var(--wg-space-4);
  opacity: 0.4;
}

.wg-empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--wg-text);
  margin-block-end: var(--wg-space-2);
}

.wg-empty-state__message {
  font-size: 0.9375rem;
}

/* ── Skip link (accessibility) ───────────────────────────────────────────── */
.wg-skip-link {
  position: absolute;
  top: -100%;
  left: var(--wg-space-4);
  z-index: 9999;
  background: var(--wg-primary);
  color: var(--wg-text-on-primary);
  padding: var(--wg-space-2) var(--wg-space-4);
  border-radius: var(--wg-radius-sm);
  font-weight: 600;
  transition: top var(--wg-transition);
}

.wg-skip-link:focus {
  top: var(--wg-space-4);
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.wg-divider {
  border: none;
  border-top: 1px solid var(--wg-border);
  margin-block: var(--wg-space-6);
}

/* ── Footer styles live in components/footer.css ─────────────────────────── */

/* ── Generic page layout ─────────────────────────────────────────────────── */
.wg-main {
  max-width: 720px;
  margin-inline: auto;
  padding: var(--wg-space-8) var(--wg-space-4);
  width: 100%;
}

@media (min-width: 640px) {
  .wg-main {
    padding-inline: var(--wg-space-6);
  }
}

/* Shop and front page override the default max-width */
.wg-shop-page.wg-main,
.wg-front-page.wg-main {
  max-width: none;
  padding: 0;
}
