/*
 * Custom overrides for local/offline archive rendering.
 * Fixes issues caused by missing Shopify runtime JS not initializing images
 * or removing the hidden state from MainContent.
 */

/* Force MainContent to be visible even if theme.min.js does not init. */
#MainContent {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Force cascading-content items to be visible (theme JS normally fades them in). */
.item.fade-in,
.no-js .item.fade-in {
  opacity: 1 !important;
  filter: none !important;
  -ms-filter: none !important;
  -moz-opacity: 1 !important;
  -khtml-opacity: 1 !important;
}

/* Ensure responsive image wrappers keep their aspect ratio placeholder while allowing children to overlay. */
.responsive-image__wrapper {
  position: relative;
  display: block;
  overflow: hidden;
}
.responsive-image__wrapper::before {
  content: "";
  display: block;
}

/* Make lazyload images always visible when we have a resolved src. */
.responsive-image__image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Hide the primary/secondary/tertiary background placeholder overlay once the image is present. */
.responsive-image__image[src]:not([src^="data:"]) + .responsive-image__placeholder {
  opacity: 0 !important;
}

/* Layout scaffolding for cascade sections when Isotope/cascade JS does not initialize.
   Provides a simple flex-wrap fallback so items don't stack absolutely. */
.cascading-content .items {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 0 -10px;
}
.cascading-content .item {
  padding: 10px;
  box-sizing: border-box;
}
.cascading-content .item-sizer,
.cascading-content .column-sizer {
  display: none;
}
.cascading-content .item--desktop--full {
  width: 100%;
  flex: 0 0 100%;
}
.cascading-content .item--desktop--half {
  width: 50%;
  flex: 0 0 50%;
}
@media only screen and (max-width: 989px) {
  .cascading-content .item--mobile--full {
    width: 100%;
    flex: 0 0 100%;
  }
}

/* Image-with-text overlay text should be readable over any image. */
.image-with-text__content {
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease;
}
.image-with-text__container:hover .image-with-text__content {
  background: rgba(0, 0, 0, 0.4);
}

/* Blog card image needs relative positioning for placeholder overlay. */
.blog-grid-item .responsive-image__wrapper {
  min-height: 200px;
}

/* Section spacing so sections aren't cramped without the theme layout JS. */
.section-with-padding {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}

/* When an image never gets a real src (theme JS didn't populate data-src, or the file 404s),
   hide the transparent SVG so the colored placeholder underneath is what shows. */
.responsive-image__image[src^="data:image/svg"] {
  opacity: 0;
}

/* Broken image icon suppression: if an <img> fails to load, the alt text/broken icon can
   look worse than nothing. Combined with the placeholder div behind, this keeps things clean. */
img.responsive-image__image {
  color: transparent;
}

/* Ensure absolute-positioned image wrappers have a base background so blank tiles aren't jarring. */
.responsive-image__wrapper {
  background-color: rgba(0, 0, 0, 0.04);
}

/* Product-page image gallery fallback: theme JS normally wires up product-media Flickity carousels.
   Without JS, show only the first media so the page still communicates the product. */
.product-media-container .product-media:not(:first-child) {
  display: none;
}

/* Header logo should not stretch to 100% width in the flex fallback. */
.header__logo img,
.site-logo img {
  width: auto;
  max-width: 100px;
}

/* Cart, search and account dropdowns should stay closed by default (no JS to toggle). */
.header__active {
  display: none;
}

/* Product grid fallback so collection pages don't collapse into a single column when Flickity fails. */
.grid--uniform > .grid__item {
  min-height: 100px;
}
