/* ─────────────────────────────────────────────────────────────────────────────
   SCL Product Page — Gallery · Highlights · Shop Cards · Mini-Cart
   Requires main.css design tokens.
   Version: 2.1.0
   ───────────────────────────────────────────────────────────────────────────── */


/* ══════════════════════════════════════════════════════════════════════════════
   1. CUSTOM EDITORIAL GALLERY
   Rendered by woocommerce/single-product/product-image.php — no Flexslider.

   Desktop layout (2-col CSS grid):
   ┌───────────────────────────────┐
   │  Image 1  — hero  (4:5)      │  spans both cols
   ├────────────────┬──────────────┤
   │  Image 2       │  Image 3    │  1:1 square pair
   ├────────────────┴──────────────┤
   │  Image 4  — banner (16:9)    │  spans both cols
   ├────────────────┬──────────────┤
   │  Image 5       │  Image 6    │  back to 1:1 pairs
   └───────────────────────────────┘
   ══════════════════════════════════════════════════════════════════════════════ */

.scl-product-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: start;
  margin: 0;
}

/* ── Product layout: let main.css handle columns ────────────────────────────
   We don't override the layout grid — main.css already defines a working
   3-column layout (gallery | summary | aside). Our job here is just to make
   sure our injected elements don't break that flow.
   ─────────────────────────────────────────────────────────────────────────── */

/* Keep the WooCommerce gallery container from floating or overflowing */
.single-product .woocommerce-product-gallery {
  width: 100% !important;
  margin: 0 !important;
  float: none !important;
}

/* Ensure aside doesn't get sticky or overflow from any old theme styles */
.single-product-aside {
  position: static !important;
  top: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Make the WooCommerce gallery container play nicely */
.single-product .woocommerce-product-gallery {
  width: 100% !important;
  margin: 0 !important;
  float: none !important;
}

/* Hero — image 1 */
.scl-gallery-item--hero {
  grid-column: 1 / -1;
  border-radius: 22px;
  overflow: hidden;
}

.scl-gallery-item--hero .scl-gallery-img {
  aspect-ratio: 4 / 5;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--surface);
}

/* Square pair — images 2, 3 and 5+ */
.scl-gallery-item--square {
  border-radius: 14px;
  overflow: hidden;
}

.scl-gallery-item--square .scl-gallery-img {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--surface);
  transition: transform 350ms ease;
}

.scl-gallery-item--square a:hover .scl-gallery-img {
  transform: scale(1.02);
}

/* Banner — image 4 */
.scl-gallery-item--banner {
  grid-column: 1 / -1;
  border-radius: 18px;
  overflow: hidden;
}

.scl-gallery-item--banner .scl-gallery-img {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--surface);
}

/* Caption */
.scl-gallery-caption {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* Links — remove any default underline/colour */
.scl-product-gallery a {
  display: block;
  line-height: 0;
  text-decoration: none;
}

/* Hide WooCommerce's flexslider thumbnail strip (enqueued but not needed) */
.single-product .flex-control-nav,
.single-product .flex-control-thumbs,
.single-product ol.flex-control-thumbs,
.single-product .flex-direction-nav {
  display: none !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   2. STOCK BADGE
   ══════════════════════════════════════════════════════════════════════════════ */

.scl-stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.scl-stock-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5a8a60; /* muted green */
  flex-shrink: 0;
}

.scl-stock-badge--out {
  color: var(--muted);
}

.scl-stock-badge--out::before {
  background: #b87a6a; /* muted terracotta */
}


/* ══════════════════════════════════════════════════════════════════════════════
   2b. COFFEE DETAILS CARD — spacing fix
   ══════════════════════════════════════════════════════════════════════════════ */

.coffee-facts-card {
  margin-top: 2rem;
}

.coffee-facts-card__head {
  margin-bottom: 1rem;
}


/* ══════════════════════════════════════════════════════════════════════════════
   3. HIGHLIGHTS ROW
   Injected via scl_render_highlights() — reads from product attribute
   "highlights" (pipe-separated) or falls back to microcopy theme mods.
   ══════════════════════════════════════════════════════════════════════════════ */

.scl-highlights {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.scl-highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
}

.scl-highlight-icon {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.12rem;
  color: var(--muted);
}


/* ══════════════════════════════════════════════════════════════════════════════
   4. GEAR DETAILS — brand / compatibility card for non-coffee products
   ══════════════════════════════════════════════════════════════════════════════ */

.scl-gear-details {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.75rem 0 1.1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.scl-gear-detail {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.scl-gear-detail__label {
  min-width: 5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.scl-gear-detail__value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}


/* ══════════════════════════════════════════════════════════════════════════════
   5. SUMMARY SPACING POLISH
   ══════════════════════════════════════════════════════════════════════════════ */

/* Price — tighten up */
.woocommerce div.product p.price,
.woocommerce div.product span.price {
  margin-bottom: 0.6rem;
}

/* Short description — muted, tight */
.woocommerce-product-details__short-description,
.product-short-copy {
  margin-bottom: 0;
}

.product-short-copy p,
.woocommerce-product-details__short-description p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Cart form — base resets */
.woocommerce div.product form.cart {
  padding-top: 0;
  border-top: 0;
  margin-bottom: 0;
}

/* ── Simple products: quantity + button in a row ── */
.product-type-simple .woocommerce div.product form.cart,
.single-product:not(.product-type-variable) .woocommerce div.product form.cart {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 0.5rem;
}

/* ── Variable products: let variations table stack, row only for qty+button ── */
.product-type-variable .woocommerce div.product form.cart {
  display: block !important;
}

.product-type-variable .woocommerce-variation-add-to-cart {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Quantity input — compact pill (applies to both) */
.woocommerce div.product form.cart .quantity {
  flex: 0 0 auto;
}

.woocommerce div.product form.cart .qty {
  width: 3.75rem;
  min-height: 2.9rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 0;
  -moz-appearance: textfield;
  transition: border-color 200ms ease;
}

.woocommerce div.product form.cart .qty::-webkit-inner-spin-button,
.woocommerce div.product form.cart .qty::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.woocommerce div.product form.cart .qty:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* Add to Cart button — fills remaining row width */
.woocommerce div.product form.cart .single_add_to_cart_button,
.product-type-variable .woocommerce-variation-add-to-cart .single_add_to_cart_button {
  flex: 1 1 auto;
  width: auto;
  padding: 0.95em 1.5em;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  border-radius: 999px;
}

/* Purchase box — no extra gap */
.product-purchase-box {
  margin-bottom: 0;
}

/* Hide WooCommerce default breadcrumb + posted_in (theme handles nav) */
.woocommerce-breadcrumb,
.posted_in {
  display: none;
}


/* ══════════════════════════════════════════════════════════════════════════════
   6. ACCORDION POLISH
   ══════════════════════════════════════════════════════════════════════════════ */

/* Hide WooCommerce default tabs — theme uses custom accordions */
.woocommerce-tabs {
  display: none;
}

.accordion-content p {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  line-height: 1.7;
}

.accordion-content p:last-child { margin-bottom: 0; }

.accordion-content ul,
.accordion-content ol {
  padding-left: 1.1rem;
  margin: 0 0 0.7rem;
}

.accordion-content li {
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 0.3rem;
  color: var(--muted);
}

.accordion-content strong {
  color: var(--text);
  font-weight: 700;
}

.product-accordions details summary {
  padding: 1rem 0;
}

.product-accordions details[open] .accordion-content {
  animation: scl-accordion-open 180ms ease both;
}

@keyframes scl-accordion-open {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ══════════════════════════════════════════════════════════════════════════════
   7. PRODUCT CARDS — Hover second image
   Styles live here (not scl-filter.css) because product loops appear on the
   homepage and other pages too — scl-product.css loads on all frontend pages.
   ══════════════════════════════════════════════════════════════════════════════ */

.product-card__media-wrap {
  position: relative;
  overflow: hidden;
}

/* Primary thumbnail: zoom on hover */
.product-card__media-wrap img {
  display: block;
  width: 100%;
  transition: transform 360ms ease;
}

.product-card__media-wrap:hover img {
  transform: scale(1.025);
}

/* Hover image: overlays primary, invisible by default */
.product-card__hover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 360ms ease, transform 360ms ease;
  pointer-events: none;
}

.product-card__media-wrap:hover .product-card__hover-img {
  opacity: 1;
  transform: scale(1.025);
}

/* Touch devices have no hover — hide entirely so it never stacks */
@media (hover: none) {
  .product-card__hover-img {
    display: none;
  }
}


/* ══════════════════════════════════════════════════════════════════════════════
   8. MINI-CART — Free shipping progress bar
   ══════════════════════════════════════════════════════════════════════════════ */

.scl-shipping-bar {
  padding: 0.85rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}

.scl-shipping-bar__track {
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 0.55rem;
}

.scl-shipping-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.scl-shipping-bar__msg {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}

.scl-shipping-bar__msg strong {
  color: var(--text);
  font-weight: 700;
}

.scl-shipping-bar__icon {
  display: inline-block;
  margin-right: 0.2em;
  color: #5a8a60;
  font-weight: 700;
}


/* ══════════════════════════════════════════════════════════════════════════════
   9. RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 820px) {
  /* ── Product page gallery: mobile ──────────────────────────────────────────
     Hero full-width at top, then a 4-col thumbnail strip below (Fellow-style).
     ─────────────────────────────────────────────────────────────────────────── */

  .scl-product-gallery {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
  }

  /* Hero: full width, square aspect ratio */
  .scl-gallery-item--hero {
    grid-column: 1 / -1;
  }

  .scl-gallery-item--hero .scl-gallery-img {
    aspect-ratio: 1 / 1;
    border-radius: 16px;
  }

  /* Secondary images: small square thumbnails in a strip */
  .scl-gallery-item--square,
  .scl-gallery-item--banner {
    grid-column: auto;
    display: block;
  }

  .scl-gallery-item--square .scl-gallery-img,
  .scl-gallery-item--banner .scl-gallery-img {
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    opacity: 0.75;
    transition: opacity 200ms ease;
  }

  .scl-gallery-item--square a:active .scl-gallery-img,
  .scl-gallery-item--banner a:active .scl-gallery-img {
    opacity: 1;
  }

  /* Quantity + button: allow wrapping on very small screens */
  .woocommerce div.product form.cart {
    flex-wrap: wrap !important;
  }

  .woocommerce div.product form.cart .single_add_to_cart_button {
    flex: 1 1 auto;
    min-width: 0;
  }
}


/* ══════════════════════════════════════════════════════════════════════════════
   GLOBAL — Pre-footer spacing
   Adds breathing room between page content and footer on all pages.
   ══════════════════════════════════════════════════════════════════════════════ */

/* Target the site footer directly — works regardless of theme's main class */
.site-footer,
#colophon,
footer.footer,
body > footer {
  margin-top: clamp(3rem, 6vw, 6rem);
}

/* Also pad the bottom of common main content wrappers */
.site-main,
#main,
#primary,
.main-content {
  padding-bottom: clamp(2rem, 4vw, 4rem);
}


/* ── Hero secondary link ────────────────────────────────────────────────────── */

.hero__secondary-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.88rem;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.45);
  transition: text-decoration-color 200ms ease;
  white-space: nowrap;
}

.hero__secondary-link:hover {
  text-decoration-color: currentColor;
}

.hero__secondary-link::after {
  content: '→';
  font-size: 0.9em;
}
