/* ==========================================================================
   Forsyths — Intrinsic Product Imagery: front-office presentation polish.

   Loads after theme.css (registerStylesheet priority) so these rules win
   without editing the designer's theme.css / custom.css. Pairs with the
   de-bordered (aspect-true) image files the module produces: once the white
   padding is gone, images keep their real shape, and this stylesheet makes
   that shape look intentional instead of loose.
   ========================================================================== */

/* 1. Page backdrop — DELIBERATELY LEAVE the theme's grey bg.webp texture alone.
   It's a theme-mandated element a colleague added; do NOT retire it. theme.css
   paints the tile on #wrapper/#header, so the body rule below is a harmless no-op
   (#wrapper covers body) — it does NOT remove the texture. Earlier this section
   tried to clear bg.webp on #wrapper/#header; that wiped the texture and was
   reverted. Don't "fix" the no-op into removing it again. */
body { background: #f7f7f8 !important; }

/* --------------------------------------------------------------------------
   2. Product page cover — premium, intentional framing
   -------------------------------------------------------------------------- */
/* Cap the RENDERED long side (~350px) so tall covers don't dominate the page
   or force endless mobile scrolling. min(100%, 350px) also stops overflow on
   narrow screens. No rounded corners — book/score covers have their own edges. */
.images-container { text-align: center !important; }
.product-cover { display: inline-block !important; margin-bottom: 1rem !important; }
.product-cover img {
  width: auto !important;
  height: auto !important;
  max-width: min(100%, 350px) !important;
  /* Cap by viewport height so the cover scales to the screen and leaves room
     for the title/price/features. dvh accounts for mobile browser chrome;
     the vh line is a fallback for older engines. ~350px ceiling on desktop. */
  max-height: min(350px, 38vh) !important;
  max-height: min(350px, 38dvh) !important;
  background: transparent !important;
  box-shadow: 0 4px 16px rgba(20, 20, 30, .12) !important;
}

/* Mobile gallery: hide the thumbnail strip so the NUMBER of images never
   shifts the title/price down the page. Multi-image products instead get
   swipe + a small row of dots overlaid on the cover (added by the module JS),
   so a 1-image and an 8-image product have the same footprint.
   Desktop is left exactly as the theme had it — there the strip sits in the
   image column beside the info, so it never pushes anything down. */
.fif-dots { display: none; }
/* Dots are real <button>s (keyboard/AT reachable) — strip native button chrome so
   the specific size/colour rules below render an identical circle. */
.fif-dot {
  border: 0; padding: 0; margin: 0; font: inherit; background: transparent;
  -webkit-appearance: none; appearance: none;
}
@media (max-width: 767px) {
  /* Only hide the native thumb rail when our JS actually ran (it adds .fif-js to
     <html> and supplies the dots/swipe replacement). If the bundle ever fails to
     load or throws, the rail stays and image browsing still works — never worse
     than the un-enhanced theme. */
  .fif-js .images-container .js-qv-mask { display: none !important; }
  /* Extra bottom space holds the dots just BELOW the cover (not over it). The
     margin is the same for 1-image and many-image products, so the footprint
     stays consistent and the title doesn't shift. */
  .product-cover { position: relative !important; margin-bottom: 28px !important; }
  /* Tap-to-fullscreen cue (the magnifier is hidden at this width). Moved here from
     JS so it's declarative and survives a gallery re-render. */
  .product-cover img { cursor: zoom-in; }
  .fif-dots {
    position: absolute; left: 0; right: 0; bottom: -20px; margin: 0;
    display: flex; justify-content: center; gap: 7px;
  }
  .fif-dots .fif-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #c9c9cf;
    cursor: pointer; transition: background .2s ease;
  }
  .fif-dots .fif-dot.active { background: #2c9ffd; }
}

/* --------------------------------------------------------------------------
   3. Listing / grid cards — clean white cards, intrinsic image, hover lift
   -------------------------------------------------------------------------- */
.product-miniature .thumbnail-container,
.featured-products .thumbnail-container,
.product-accessories .thumbnail-container {
  background: #fff !important;
  box-shadow: 0 1px 3px rgba(20, 20, 30, .07) !important;
  transition: box-shadow .22s ease, transform .22s ease !important;
  overflow: hidden !important;
}
.product-miniature .thumbnail-container:hover,
.featured-products .thumbnail-container:hover,
.product-accessories .thumbnail-container:hover {
  box-shadow: 0 12px 30px rgba(20, 20, 30, .13) !important;
  transform: translateY(-3px) !important;
}

/* Media box: fixed height, image keeps its true aspect, centred, no white box */
.product-miniature .thumbnail-container .product-thumbnail,
.featured-products .thumbnail-container .product-thumbnail,
.product-accessories .thumbnail-container .product-thumbnail {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 240px !important;
  padding: 16px !important;
  background: #fff !important;
}
.product-miniature .thumbnail-container .product-thumbnail img,
.featured-products .thumbnail-container .product-thumbnail img,
.product-accessories .thumbnail-container .product-thumbnail img {
  position: static !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  object-fit: contain !important;
  transition: transform .3s ease !important;
}
.product-miniature .thumbnail-container:hover .product-thumbnail img {
  transform: scale(1.04) !important;
}

/* --------------------------------------------------------------------------
   4. Fullscreen image viewer on mobile — opened by tapping the cover.
   Reuses the theme's #product-modal markup but restyles it to fill the
   screen: big image fit to the viewport on a dark backdrop, the module's
   close button + dots, swipe to flick through. Desktop keeps the theme's
   own modal untouched.
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  #product-modal .modal-dialog { max-width: 100% !important; width: 100% !important; margin: 0 !important; }
  #product-modal .modal-content {
    height: 100vh !important; border: 0 !important; border-radius: 0 !important;
    background: #0e0e0f !important;
  }
  #product-modal .modal-body {
    height: 100% !important; padding: 0 !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
  }
  #product-modal figure { margin: 0 !important; width: 100% !important; text-align: center !important; }
  #product-modal .product-cover-modal {
    display: block !important; width: auto !important; height: auto !important;
    max-width: 100% !important; max-height: 88vh !important; margin: 0 auto !important;
  }
  /* Hide the theme's in-modal caption + thumbnail strip; dots + swipe replace them. */
  #product-modal .image-caption,
  #product-modal #thumbnails { display: none !important; }

  .fif-modal-close {
    position: fixed; top: 6px; right: 14px; z-index: 1060;
    background: none; border: 0; color: #fff; font-size: 36px; line-height: 1;
    padding: 4px 8px; cursor: pointer; text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
  }
  .fif-modal-dots {
    position: fixed; left: 0; right: 0; bottom: 16px; z-index: 1060;
    display: flex; justify-content: center; gap: 8px;
  }
  .fif-modal-dots .fif-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255, 255, 255, .45); cursor: pointer; transition: background .2s ease;
  }
  .fif-modal-dots .fif-dot.active { background: #fff; }

  .fif-modal-arrow {
    position: fixed; top: 50%; transform: translateY(-50%); z-index: 1060;
    border: 0; color: #fff;
    font-size: 52px; line-height: 1; padding: 30px 16px; cursor: pointer;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
    -webkit-tap-highlight-color: transparent;
  }
  .fif-modal-arrow:active { opacity: .6; }
  /* teeny edge gradient so the chevron always reads over any image */
  .fif-modal-prev { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0)); }
  .fif-modal-next { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0)); }
}
/* --------------------------------------------------------------------------
   5. De-border fallout fix — keep the REAL aspect ratio everywhere.
   The theme prints width/height attributes (and some fixed CSS widths) from the
   square image-TYPE box, e.g. large_default = 800x800. Once we strip the baked
   padding the files are aspect-true (e.g. 600x800), so any element that still
   carries the square dimensions gets stretched. The inline cover is already
   freed (section 2); these are the other surfaces — the zoom modal's big image
   and both thumbnail strips. Letting one axis go `auto` restores the true shape.
   -------------------------------------------------------------------------- */
/* Thumbnail strips: theme fixes the width, so free the height (all viewports). */
#product-modal .js-modal-thumb,
#product-modal #thumbnails .thumb,
.images-container .product-images .thumb.js-thumb {
  height: auto !important;
}

/* Desktop zoom modal: stop the 800x800 box stretching the portrait cover, and
   recentre (the theme's -30% nudge assumed an 800px-wide image). */
@media (min-width: 768px) {
  .fif-modal-close, .fif-modal-dots, .fif-modal-arrow { display: none; }

  #product-modal .modal-content .modal-body {
    margin-left: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #product-modal img.product-cover-modal {
    width: auto !important;
    height: auto !important;
    /* viewport-based, not 100% of the shrunk flex item, or the figure/image
       sizing goes circular and collapses to min-content. 58vw leaves room for
       the thumbnail column; 82vh keeps it within the screen. */
    max-width: 58vw !important;
    max-height: 82vh !important;
    background: #fff !important;
  }
  #product-modal .modal-content .modal-body .image-caption {
    width: auto !important;
    max-width: 800px !important;
  }
}

/* --------------------------------------------------------------------------
   6. Product grid — density & proportion (cards + their image area only).
   The classic theme runs 3-up on desktop with loose ~276px slots and a tall
   240px image box, so cards read sparse. Tighten to 4-up on wide desktop /
   2-up on phones, and bring the image area into proportion with the narrower
   card. The image area is sized as if a cover is present (per brief). No new
   content, no rounded corners — purely the card↔image sizing and density.
   -------------------------------------------------------------------------- */
/* Columns: override the per-card flex-item width the listing uses. Scoped to
   the category/search list so homepage featured blocks keep their own layout. */
@media (min-width: 1200px) {
  #js-product-list .products > .product { width: 25% !important; }
}
@media (min-width: 768px) and (max-width: 1199px) {
  #js-product-list .products > .product { width: 33.3333% !important; }
}
@media (max-width: 767px) {
  #js-product-list .products > .product { width: 50% !important; }
}
/* Even gutters between cards at any column count. */
#js-product-list .products > .product {
  padding: 0 8px !important;
  margin-bottom: 16px !important;
  /* Search results carry a theme min-width:250px that floors the flex item and
     collapses our 2-up to 1-up on phones; clear it so the % widths above win. */
  min-width: 0 !important;
}

/* THE key fix: the classic theme pins .thumbnail-container to a rigid 250x352px
   box. That (a) overflows into neighbours once a column is narrower than 250px
   and (b) bakes in dead space below the price. Make it fluid — fill the column,
   take height from content — so density actually works. */
#js-product-list .product-miniature .thumbnail-container {
  width: auto !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column !important;
}
#js-product-list .product-miniature .thumbnail-container .product-description {
  position: relative !important;
  width: auto !important;
  flex: 1 0 auto !important;
}

/* Image area: proportionate to the now-narrower card (was a tall 240px). */
.product-miniature .thumbnail-container .product-thumbnail {
  height: 210px !important;
  padding: 12px !important;
}
@media (max-width: 767px) {
  .product-miniature .thumbnail-container .product-thumbnail {
    height: 160px !important;
    padding: 10px !important;
  }
}

/* Tighten the text block so the card isn't mostly air. */
.product-miniature .thumbnail-container .product-description {
  padding: 10px 12px 14px !important;
}
/* Reserve two lines for the title so prices sit on the same baseline across a
   row even when one title wraps and another doesn't. */
.product-miniature .product-title {
  margin: 0 0 6px !important;
  min-height: 37px !important;
}
.product-miniature .product-title a { font-size: 14px !important; line-height: 1.3 !important; }
.product-miniature .product-price-and-shipping { font-size: 15px !important; }
