/* Fix GLightbox scroll restoration issues */
/* When lightbox is NOT open, ensure page is scrollable */
html:not(.glightbox-open),
body:not(.glightbox-open) {
  overflow: auto !important;
  overflow-y: auto !important;
  position: static !important;
  height: auto !important;
}

/* Ensure GLightbox overlay shows above everything */
.glightbox-container {
  z-index: 999999 !important;
}

/* Fix SVG images in lightbox - they need explicit sizing */
.glightbox-container .gslide-image img,
.glightbox-container .gslide-image svg {
  max-width: 90vw !important;
  max-height: 85vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* Ensure the slide container expands for SVGs */
.glightbox-container .gslide-inner-content {
  max-width: 90vw !important;
  max-height: 90vh !important;
}

.glightbox-container .gslide-image {
  max-width: 90vw !important;
}

/* For SVG specifically, ensure they scale up */
.glightbox-container img[src$=".svg"] {
  min-width: 60vw;
  min-height: 60vh;
}

/* Enable smooth zoom transitions */
.glightbox-container .gslide-image img {
  transition: transform 0.15s ease-out;
  transform-origin: center center;
}

/* Allow overflow when zoomed */
.glightbox-container .gslide-inner-content,
.glightbox-container .gslide-image {
  overflow: visible !important;
}

/* Zoom controls bar */
.zoom-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 9999999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.zoom-controls.visible {
  opacity: 1;
  visibility: visible;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.zoom-slider {
  width: 120px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
}

.zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.zoom-level {
  color: white;
  font-size: 13px;
  min-width: 45px;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Pan controls - D-pad style */
.pan-controls {
  position: fixed;
  bottom: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 9999999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.pan-controls.visible {
  opacity: 1;
  visibility: visible;
}

.pan-middle {
  display: flex;
  gap: 4px;
}

.pan-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  font-family: system-ui, -apple-system, sans-serif;
}

.pan-btn:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.1);
}

.pan-btn:active {
  transform: scale(0.95);
}

.pan-center {
  font-size: 20px;
}

/* Visual feedback - make images look clickable */
a.lightbox img {
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}

a.lightbox:hover img {
  opacity: 0.85;
}

/* Remove the early dark mode styles once Quarto loads its own */
html.quarto-dark #early-dark-mode {
  display: none;
}

/* Back to top button - modern glassmorphism style */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(139, 92, 246, 0.9));
  color: white;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  box-shadow:
    0 4px 15px rgba(99, 102, 241, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.back-to-top svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 8px 25px rgba(99, 102, 241, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.15);
}

.back-to-top:hover svg {
  transform: translateY(-2px);
}

.back-to-top:active {
  transform: translateY(-2px) scale(1.02);
}

/* Dark mode styling */
.quarto-dark .back-to-top {
  background: linear-gradient(135deg, rgba(71, 85, 105, 0.9), rgba(51, 65, 85, 0.9));
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.3),
    0 1px 3px rgba(0, 0, 0, 0.2);
}

.quarto-dark .back-to-top:hover {
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Hide when lightbox is open */
.glightbox-open .back-to-top {
  display: none;
}
