  /* ==========================================================================
   MARTVILL - BOOK COVER DISPLAY & HOVER FIX (PRODUCT DETAILS)
   ========================================================================== */

/* 1. Prevent Martvill's gallery wrapper from clipping/cropping vertical covers */
.product-gallery-viewer,
.single-product-gallery,
.easyzoom,
.product-image-container {
  height: auto !important;
  max-height: none !important;
  min-height: auto !important;
  overflow: visible !important;
  display: flex !important;
  justify-content: center !important;
  align-items: flex-start !important;
}

/* 2. Format the main product image into a clean Amazon-style Book Cover */
.product-gallery-viewer img,
.single-product-gallery img,
.product-image-container img {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 520px !important;
  
  /* Force clean book aspect ratio without distorting */
  aspect-ratio: 2 / 3 !important;
  object-fit: contain !important;
  
  /* Amazon 3D Book Cover Shadow */
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.2) !important;
  border-radius: 2px !important;
}

/* 3. Hide the annoying popup zoom lens overlay on hover */
.zoomLens, 
.zoomWindow, 
.zoomContainer {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* ==========================================================================
   AMAZON-STYLE VERTICAL BOOK LIST (CATALOG & CATEGORIES)
   ========================================================================== */

/* 1. Turn the product grid container into a single-column vertical stack */
.product-container,
.category-product-list,
.products-wrapper .row {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
}

/* Force grid columns to take 100% width */
.product-container [class*="col-"],
.products-wrapper [class*="col-"] {
  width: 100% !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
}

/* 2. Convert each book card into a horizontal row (Amazon Style) */
.product-card,
.single-product,
.product-box {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  padding: 16px !important;
  background: #ffffff !important;
  border: 1px solid #d5d9d9 !important;
  border-radius: 4px !important;
  gap: 20px !important;
  width: 100% !important;
}

/* 3. Book Cover Image (Fixed width on the left) */
.product-card .image-wrap,
.product-card .product-img,
.single-product .img-box {
  width: 120px !important;
  min-width: 120px !important;
  height: auto !important;
  aspect-ratio: 2 / 3 !important;
  margin-bottom: 0 !important;
  flex-shrink: 0 !important;
}

.product-card img,
.single-product img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.15) !important;
}

/* 4. Book Information Block (Stacked to the right of the cover) */
.product-card .product-info,
.single-product .product-content {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: flex-start !important;
  text-align: left !important;
  flex-grow: 1 !important;
}

/* Title & Author styling */
.product-card .product-title,
.single-product .product-title {
  font-size: 16px !important;
  font-weight: 700 !important;
  margin-bottom: 4px !important;
}

.product-card .vendor-name,
.product-card .category {
  font-size: 13px !important;
  color: #565959 !important;
  margin-bottom: 8px !important;
}

/* Price & Button placement */
.product-card .product-price {
  font-size: 18px !important;
  color: #b12704 !important;
  margin-bottom: 10px !important;
}

.product-card .add-to-cart-btn,
.product-card .btn-primary {
  align-self: flex-start !important;
  padding: 6px 18px !important;
}
/* 1. Force the Swiper wrapper and slide container to allow flexible height */
body .swiper-slide,
body .swiper-slide-img-wrap,
body .product-gallery-slider .swiper-slide {
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
}

/* 2. Style the book cover image with natural book proportions */
img.swiper-slide-img,
body img.swiper-slide-img {
    width: 100% !important;
    max-width: 320px !important;  /* Controls maximum cover width on desktop */
    height: auto !important;
    max-height: 480px !important; /* Prevents giant vertical stretching */
    aspect-ratio: 2 / 3 !important; /* Standard portrait book dimension */
    object-fit: contain !important; /* Displays full cover with NO cropping */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15) !important; /* Realistic 3D book shadow */
    border-radius: 4px !important;
    margin: 0 auto !important;
}
/* 1. Hide the entire top badge container (Box + Month + Date) */
body [class*="blog"] [class*="badge"],
body [class*="blog"] [class*="date"],
body .blog-section [class*="badge"],
body .blog-section [class*="date"],
body .blog-card [class*="badge"],
body .blog-card [class*="date"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 2. Target absolute-positioned overlay boxes over blog thumbnails */
body .blog-section .absolute.top-0,
body .blog-section .absolute.top-2,
body .blog-section .absolute.top-3,
body .blog-section .absolute.top-4,
body [class*="blog"] .absolute {
    display: none !important;
}

document.addEventListener("DOMContentLoaded", function () {
  // Target brand elements across product details and product cards
  const brandElements = document.querySelectorAll(
    '.product-brand-name, .product-details-info .brand, .product-meta .brand, .product-card .vendor-name'
  );

  brandElements.forEach(function (el) {
    // Prevent double wrapping if script runs multiple times
    if (el.querySelector('a') || el.dataset.clickable === "true") return;

    // Extract the author name text
    let fullText = el.innerText.trim();
    let authorName = fullText.replace(/^by\s+/i, '').replace(/^Brand:\s*/i, '').trim();

    if (authorName) {
      // Build search URL for Martvill's brand catalog page
      let brandUrl = '/search?brand=' + encodeURIComponent(authorName);

      // Replace static text with a clickable hyperlink
      el.innerHTML = 'by <a href="' + brandUrl + '" class="amazon-author-link">' + authorName + '</a>';
      el.dataset.clickable = "true";
    }
  });
});

/* ==========================================================================
   CLICKABLE AUTHOR LINK STYLING (AMAZON STYLE)
   ========================================================================== */

.amazon-author-link {
  color: #007185 !important; /* Amazon Blue */
  font-weight: 600 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: color 0.15s ease-in-out;
}

.amazon-author-link:hover {
  color: #c45500 !important; /* Amazon Orange Hover */
  text-decoration: underline !important;
}