/* ==========================================================================
   Gallery Slider (Embla Carousel)
   ========================================================================== */

.gallery-slider {
  position: relative;
}

.embla__main {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-alt);
}

[data-transparent-bg="true"] .embla__main {
  background: transparent;
}

.embla__viewport {
  overflow: hidden;
}

.embla__container {
  display: flex;
  touch-action: pan-y pinch-zoom;
}

.embla__slide {
  flex: 0 0 100%;
  min-width: 0;

  & img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    aspect-ratio: 16 / 9;
  }
}

/* Arrow Navigation */
.embla__prev,
.embla__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font-size: 1.5rem;
  /* Controls icon size */
  width: 3rem;
  height: 3rem;
  box-shadow: none;

  /* Override hover transform from btn-icon if needed, but keeping simple scale */
  &:hover {
    transform: translateY(-50%) scale(1.1);
  }

  &:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%) scale(1);
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.embla__prev {
  left: 1rem;
}

.embla__next {
  right: 1rem;
}

/* Dot Indicators (Loop variant) */
.embla__dots {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.embla__dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--surface-3);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;

  &.is-selected {
    background: var(--accent);
    transform: scale(1.2);
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
  }
}

/* Thumbnails Strip */
.embla__thumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;

  & .embla__viewport {
    flex: 1;
  }

  & .embla__container {
    gap: 0.5rem;
  }

  & .embla__thumb {
    flex: 0 0 80px;
    padding: 0;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    overflow: hidden;
    border-radius: var(--radius);
    transition: border-color 0.2s ease;

    &.is-selected {
      border-color: var(--accent);
    }

    & img {
      width: 100%;
      height: 60px;
      object-fit: cover;
      opacity: 0.6;
      transition: opacity 0.2s ease;
    }

    &.is-selected img {
      opacity: 1;
    }
  }
}

/* ==========================================================================
   Gallery Slider Improvements
   ========================================================================== */

/* Structure */
.gallery-slider .embla__main {
  position: relative;
  /* Ensure arrows can be positioned absolutely relative to this */
}

/* Arrows: Outside
   Move arrows outside the image content. 
   Requires negative positioning. 
   Fallback to inside on mobile.
*/
.gallery-slider--arrows-outside .embla__prev {
  left: -3rem;
}

.gallery-slider--arrows-outside .embla__next {
  right: -3rem;
}

/* Fix for outside arrows being clipped */
.gallery-slider--arrows-outside .embla__main {
  overflow: visible;
}


@media (max-width: 768px) {
  .gallery-slider--arrows-outside .embla__prev {
    left: 1rem;
  }

  .gallery-slider--arrows-outside .embla__next {
    right: 1rem;
  }
}




/* Progress Bar
   Replaces dots.
*/
.embla__progress {
  position: relative;
  width: 100%;
  height: 4px;
  background-color: var(--surface-2);
  /* Track color */
  margin-top: var(--size-3);
  border-radius: 2px;
  overflow: hidden;
}

.embla__progress__bar {
  height: 100%;
  background-color: var(--text);
  /* Fill color */
  width: 0;
  /* Updated by JS */
  min-width: 2px;
  /* Visibility */
  transition: width 0.1s linear;
}

/* Alignment Overrides */
.embla__progress--left,
.embla__progress--center,
.embla__progress--right {
  background-color: transparent;
  /* Remove full width track background from container */
  display: flex;
  width: 100%;
  overflow: visible;
  /* Allow flex children */
}

.embla__progress--left {
  justify-content: flex-start;
}

.embla__progress--center {
  justify-content: center;
}

.embla__progress--right {
  justify-content: flex-end;
}


.embla__progress--left,
.embla__progress--center,
.embla__progress--right {
  /* Make the CONTAINER the fixed-width track */
  flex: 0 0 200px;
  max-width: 200px;
  /* Fix width */
  background-color: var(--surface-2);
  /* Track color back on */
  display: block;
  /* Not flex anymore, it's the track */
  margin-top: var(--size-3);
}

.embla__progress--left {
  margin-right: auto;
}

.embla__progress--center {
  margin-inline: auto;
}

.embla__progress--right {
  margin-left: auto;
}


/* Center Thumbnails */
[data-center-thumbs="true"] .embla__thumbs .embla__container {
  justify-content: center;
}

/* Editor Mock Preview Styles */
.gallery-slider-mock {
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
  position: relative;
  container-type: inline-size;
}

.gallery-slider-mock__main {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery-slider-mock[data-transparent-bg="true"] .gallery-slider-mock__main {
  background: transparent;
}

.gallery-slider-mock__slide {
  width: 100%;
  height: 100%;
}

.gallery-slider-mock__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-slider-mock__placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Mock Arrows */
.gallery-slider-mock__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: default;
  border: none;
  z-index: 10;
  /* Ensure on top of image */
  transition: color 0.2s ease, transform 0.2s ease;
}

.gallery-slider-mock__arrow--prev {
  left: 1rem;
}

.gallery-slider-mock__arrow--next {
  right: 1rem;
}

/* Mock arrow hover simulation (static) */
.gallery-slider-mock__arrow {
  box-shadow: none;
}

.gallery-slider-mock__arrow i {
  font-size: 1.5rem;
}

/* Mock Arrows Positioning: Outside */
.gallery-slider-mock[data-arrows-pos="outside"] .gallery-slider-mock__arrow--prev {
  left: -3rem;
}

.gallery-slider-mock[data-arrows-pos="outside"] .gallery-slider-mock__arrow--next {
  right: -3rem;
}

/* Allow overflow for outside arrows in mock */
.gallery-slider-mock[data-arrows-pos="outside"] .gallery-slider-mock__main {
  overflow: visible;
}



/* Mock Pagination */
.gallery-slider-mock__pagination {
  display: flex;
  justify-content: center;
  margin-top: var(--size-2);
}

.gallery-slider-mock[data-pagination="progress"] {
  display: flex;
  flex-direction: column;
}

/* Progress Alignment in Mock */
.gallery-slider-mock[data-progress-align="left"] .gallery-slider-mock__pagination {
  justify-content: flex-start;
}

.gallery-slider-mock[data-progress-align="right"] .gallery-slider-mock__pagination {
  justify-content: flex-end;
}

.gallery-slider-mock__progress {
  width: 200px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
}

.gallery-slider-mock[data-progress-align="left"] .gallery-slider-mock__progress {
  margin-right: auto;
}

.gallery-slider-mock[data-progress-align="right"] .gallery-slider-mock__progress {
  margin-left: auto;
}

.gallery-slider-mock__progress-bar {
  height: 100%;
  background: var(--text);
}

.gallery-slider-mock__dots {
  display: flex;
  gap: 8px;
}

.gallery-slider-mock__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-2);
}

.gallery-slider-mock__dot.is-selected {
  background: var(--accent);
}

/* Mock Thumbs */
.gallery-slider-mock__thumbs {
  display: flex;
  gap: var(--size-1);
  overflow: hidden;
  margin-top: var(--size-2);
}

.gallery-slider-mock[data-center-thumbs="true"] .gallery-slider-mock__thumbs {
  justify-content: center;
}

.gallery-slider-mock__thumb {
  width: 60px;
  height: 40px;
  opacity: 0.5;
}

.gallery-slider-mock__thumb.is-selected {
  opacity: 1;
  border: 2px solid var(--accent);
}

.gallery-slider-mock__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}