/* SarvTheme gallery.css — built from modules. Edit modules + run npm run build */

/* --- gallery.css --- */
/**
 * SarvTheme — Product Gallery
 *
 * Inline gallery UI (main image + thumbnail strip) styled with theme design
 * tokens (--st-*). The fullscreen viewer is powered by Fancybox v6; only its
 * theme overrides live here (see ".st-fancybox"). Layout-agnostic: any product
 * layout can wrap .st-gallery without changes.
 */

/* ---------- Tokens ---------- */
.st-gallery {
  --st-gallery-thumb-count: 5;
  --st-gallery-thumb-gap: 8px;
  --st-gallery-thumb-radius: 12px;
  --st-gallery-thumb-border: var(
    --st-product-border,
    var(--st-border, #e5e7eb)
  );
  --st-gallery-thumb-active: var(--st-color-primary, #0d6efd);
  --st-gallery-transition: 200ms ease;
  --st-gallery-shadow: 0 2px 8px rgb(15 23 42 / 0.06);

  width: 100%;
  margin: 0;
}

/* Preserve WooCommerce opacity fade-in hook (WC sets opacity:0 inline). */
.st-gallery.woocommerce-product-gallery {
  opacity: 1 !important;
}

/* ---------- Main image ---------- */
.st-gallery__main {
  width: 100%;
  background: #fff;
  box-shadow: 0 6px 90px rgba(0, 0, 0, 0.05);
  border-radius: 16px;
}

.st-gallery__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  border-radius: var(--st-product-radius, var(--st-radius-md, 12px));
  background: var(--st-product-surface, #f8f9fa);
  aspect-ratio: 1 / 1;
}

.st-gallery__main-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity var(--st-gallery-transition);
  user-select: none;
  -webkit-user-drag: none;
}

.st-gallery__main-img.is-fading {
  opacity: 0;
}

/* Zoom layer hook (implementation can attach here later). */
.st-gallery__stage[data-st-gallery-zoom] {
  cursor: zoom-in;
}

/* ---------- Thumbnail strip ----------
   Thumbs share the gallery width equally (wrapper 300px → N equal columns). */
.st-gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(var(--st-gallery-thumb-count, 5), minmax(0, 1fr));
  align-items: stretch;
  gap: var(--st-gallery-thumb-gap);
  width: 100%;
  margin-block-start: var(--st-product-space-md, 16px);
  padding-block: 2px;
}

.st-gallery__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  padding: 0;
  margin: 0;
  border: 2px solid var(--st-gallery-thumb-border);
  border-radius: var(--st-gallery-thumb-radius);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--st-gallery-shadow);
  transition:
    border-color var(--st-gallery-transition),
    transform var(--st-gallery-transition),
    box-shadow var(--st-gallery-transition);
}

.st-gallery__thumb:hover {
  border-color: color-mix(
    in srgb,
    var(--st-gallery-thumb-active) 45%,
    var(--st-gallery-thumb-border)
  );
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgb(15 23 42 / 0.1);
}

.st-gallery__thumb:focus-visible {
  outline: none;
  box-shadow: var(
    --st-focus-ring,
    0 0 0 3px
      color-mix(in srgb, var(--st-gallery-thumb-active) 25%, transparent)
  );
}

.st-gallery__thumb.is-active {
  border-color: var(--st-gallery-thumb-active);
}

.st-gallery__thumb-img,
.st-gallery__thumb-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Video thumbs: photo poster + play badge; playback only in lightbox. */
.st-gallery__thumb--video {
  cursor: pointer;
}

/* ---------- "More" thumbnail ---------- */
.st-gallery__thumb--more .st-gallery__thumb-preview {
  filter: blur(3px);
  transform: scale(1.08);
}

.st-gallery__thumb-more-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  pointer-events: none;
}

.st-gallery__thumb-more-dots {
  font-size: 1.1rem;
  line-height: 1;
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.st-gallery__thumb-more-count {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ---------- Fullscreen viewer (Fancybox theme overrides) ----------
   The fullscreen experience is powered by Fancybox v6. We only re-skin it via
   its CSS custom properties + the .st-fancybox container class (mainClass) so
   it reads as part of SarvTheme: theme radius, primary color, spacing and
   transitions. RTL is inherited from the document direction automatically. */
.st-fancybox {
  --f-spinner-color-1: rgb(255 255 255 / 0.2);
  --f-spinner-color-2: var(--st-color-primary, #0d6efd);

  /* Toolbar / nav buttons. */
  --f-button-width: 42px;
  --f-button-height: 42px;
  --f-button-border-radius: var(--st-radius-md, 8px);
  --f-button-color: #fff;
  --f-button-bg: rgb(255 255 255 / 0.12);
  --f-button-hover-color: #fff;
  --f-button-hover-bg: var(--st-color-primary, #0d6efd);
  --f-button-active-color: #fff;
  --f-button-active-bg: var(--st-color-primary, #0d6efd);
  --f-button-svg-stroke-width: 1.8;
  --f-button-transition: all var(--st-transition, 200ms ease);
}

.st-fancybox .f-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.35);
}

/* Themed thumbnail strip (classic) to mirror the inline gallery thumbs. */
.st-fancybox .f-thumbs {
  --f-thumb-width: 64px;
  --f-thumb-height: 64px;
  --f-thumbs-gap: 10px;
  --f-thumb-border-radius: var(--st-radius-md, 12px);
  --f-thumb-opacity: 0.55;
  --f-thumb-hover-opacity: 1;
  --f-thumb-selected-opacity: 1;
  --f-thumb-selected-border: 2px solid var(--st-color-primary, #0d6efd);
  --f-thumb-focus-border: 2px solid var(--st-color-primary, #0d6efd);
}

/* Caption typography aligned with the theme. */
.st-fancybox .f-caption {
  --f-caption-font: inherit;
  --f-caption-line-height: 1.6;
  font-size: 0.9rem;
}

/* WooCommerce compat container (plugin hooks). */
.st-gallery__wc-compat {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .st-gallery {
    --st-gallery-thumb-radius: 10px;
    --st-gallery-thumb-gap: 6px;
  }

  .st-gallery__stage {
    aspect-ratio: 4 / 3;
  }

  .st-fancybox .f-thumbs {
    --f-thumb-width: 56px;
    --f-thumb-height: 56px;
  }
}

@media (max-width: 479px) {
  .st-gallery {
    --st-gallery-thumb-gap: 4px;
    --st-gallery-thumb-radius: 8px;
  }
}
