:root {
  --gallery-overlay-bg: rgba(0, 0, 0, 0.8);
  --gallery-button-bg: rgba(0, 0, 0, 0.6);
  --gallery-button-bg-hover: rgba(0, 0, 0, 0.8);
  --gallery-counter-bg: rgba(0, 0, 0, 0.7);
  --gallery-text-color: white;
  --gallery-z-backdrop: 1;
  --gallery-z-controls: 3;
  --gallery-z-image: 4;
  --gallery-z-modal: 9999;
  --gallery-transition-duration: 0.2s;
  --gallery-width: 95vw;
  --gallery-height: 95vh;
  --gallery-item-width: 96vw;
  --gallery-control-size: 50px;
  --gallery-control-spacing: 20px;
}

body.quote-image-gallery-open {
  overflow: hidden;
}

.quote-image-gallery-modal {
  position: fixed;
  inset: 0;
  z-index: var(--gallery-z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quote-image-gallery-modal.active {
  display: flex;
  opacity: 1;
}

.quote-image-gallery-backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--gallery-overlay-bg);
  z-index: var(--gallery-z-backdrop);
  pointer-events: auto;
}

.quote-image-gallery-track {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 0;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  z-index: calc(var(--gallery-z-backdrop) + 1);
  width: var(--gallery-width);
  max-width: var(--gallery-width);
  max-height: var(--gallery-height);
  padding: 0;
  box-sizing: border-box;
  pointer-events: auto;
  align-items: center;
  scroll-padding: 0;
  
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}

.quote-image-gallery-track.no-smooth-scroll {
  scroll-behavior: auto;
}

.quote-image-gallery-track::-webkit-scrollbar {
  display: none;
}

.quote-image-gallery-item {
  flex: 0 0 var(--gallery-item-width);
  width: var(--gallery-item-width);
  min-width: var(--gallery-item-width);
  max-width: var(--gallery-item-width);
  height: var(--gallery-height);
  min-height: var(--gallery-height);
  max-height: var(--gallery-height);
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  pointer-events: auto;
  position: relative;
  
  will-change: transform;
}

.quote-image-gallery-image {
  max-width: var(--gallery-width);
  max-height: var(--gallery-height);
  width: auto;
  height: auto;
  box-sizing: border-box;
  object-fit: contain;
  pointer-events: auto;
  position: relative;
  z-index: var(--gallery-z-image);
}

.quote-image-gallery-close,
.quote-image-gallery-button {
  position: absolute;
  background: var(--gallery-button-bg);
  border: none;
  border-radius: 50%;
  color: var(--gallery-text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  user-select: none;
  transition: all var(--gallery-transition-duration) ease;
  z-index: var(--gallery-z-controls);
  pointer-events: auto;
  width: var(--gallery-control-size);
  height: var(--gallery-control-size);
}

.quote-image-gallery-close:hover,
.quote-image-gallery-button:hover {
  background: var(--gallery-button-bg-hover);
}

.quote-image-gallery-close {
  top: var(--gallery-control-spacing);
  right: var(--gallery-control-spacing);
  font-size: 20px;
}

.quote-image-gallery-close:hover {
  transform: scale(1.1);
}

.quote-image-gallery-button {
  top: 50%;
  font-size: 24px;
  transform: translateY(-50%);
}

.quote-image-gallery-button:hover {
  transform: translateY(-50%) scale(1.1);
}

.quote-image-gallery-button:active {
  transform: translateY(-50%) scale(0.95);
}

.quote-image-gallery-button.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.quote-image-gallery-button-left {
  left: var(--gallery-control-spacing);
}

.quote-image-gallery-button-right {
  right: var(--gallery-control-spacing);
}

.quote-image-gallery-counter {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gallery-counter-bg);
  color: var(--gallery-text-color);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 16px;
  line-height: 16px;
  z-index: var(--gallery-z-controls);
  pointer-events: none;
}

.quote-image-gallery-counter.hidden,
.quote-image-gallery-button.hidden {
  display: none;
}

.quote-image {
  cursor: pointer;
  transition: opacity var(--gallery-transition-duration) ease, transform var(--gallery-transition-duration) ease;
}

.quote-image:hover {
  opacity: 0.9;
  transform: scale(1.01);
}

@media (max-width: 768px) {
  :root {
    --gallery-width: 90vw;
    --gallery-height: 90vh;
    --gallery-control-size: 60px;
    --gallery-control-spacing: 10px;
  }

  .quote-image-gallery-close {
    font-size: 24px;
  }

  .quote-image-gallery-button {
    font-size: 28px;
  }

  .quote-image-gallery-counter {
    bottom: 20px;
    font-size: 14px;
    padding: 8px 16px;
  }

  .quote-image-gallery-backdrop {
    pointer-events: none;
  }
}
