/* Prevent document scroll when .no-doc-scroll is applied */
html.no-doc-scroll {
  overflow: hidden !important;
}

/* Global Styles */
html, body {
  overflow-x: hidden;
  overscroll-behavior: none; /* prevent any scroll chaining/bounce */
  height: 100%;
}

/* Hard lock scrolling on all devices (including iOS) */
body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  overflow: hidden;
}

/* No scrolling anywhere; JS also enforces overflow hidden */

body {
  font-family: "Poppins", Arial, sans-serif;
  background-color: #1e1e1e;
  color: #fff;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  background-color: #111;
  padding: 20px;
  font-size: 1.8rem;
  font-weight: bold;
  text-align: center;
  box-shadow: 0px 4px 10px rgba(255, 255, 255, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 80px;
  z-index: 1000;
}

header h1 {
  text-transform: none;
  font-family: 'MedievalSharp', 'Poppins', Arial, sans-serif;
}

/* Footer font to match logo */
footer, footer p {
  font-family: 'MedievalSharp', 'Poppins', Arial, sans-serif;
}

/* Footer */
footer {
  background-color: #111;
  color: white;
  padding: 15px;
  text-align: center;
  font-size: 0.9rem;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  height: 60px;
  z-index: 1000;
}

/* Content Wrapper */
#contentWrapper {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  /* Fallback for older browsers */
  height: calc(100vh - 140px);
  /* More stable on mobile address bar show/hide */
  height: calc(100svh - 140px);
}

/* Gallery */
#galleryContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Loader */
.hidden {
  display: none;
}

#loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Navigation */
.gallery-nav {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Image Container */
.image-container {
  position: relative;
  width: 90%;
  max-width: none;
  /* Fallback */
  height: 50vh;
  /* Reduce jumpiness on mobile */
  height: 50svh;
  min-height: 200px;
  overflow: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #222;
}

@media (max-width: 768px) {
  .image-container {
    max-width: 600px;
    /* Fallback */
    height: 40vh;
    /* Stable height unit on mobile */
    height: 40svh;
  }
  /* Nudge the gallery stack upward so controls/viewport/indicators sit mid-way */
  #galleryContainer {
    transform: translateY(-6svh);
  }
  /* Slightly tighten vertical spacing on small screens */
  #galleryContainer { gap: 0.75rem; }
}

/* Image */
.image-container img {
  /* Fix image size to container to avoid jump when intrinsic size arrives */
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  transition: opacity 250ms ease-in-out;
}

.image-container img.fade-out { opacity: 0; }
.image-container img.fade-in { opacity: 1; }

/* Image Indicators */
.image-indicators {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  min-height: 24px;
}

.image-indicators .indicators-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 220ms ease;
  will-change: transform;
}

.image-indicators .indicator {
  width: 10px;
  height: 10px;
  margin: 5px 4px;
  background-color: #888;
  border-radius: 50%;
  opacity: 0.7;
  transform: scale(1);
  transition: background-color 0.2s ease-in-out, transform 0.2s, opacity 0.2s;
  cursor: pointer;
}

.image-indicators .indicator.near {
  background-color: #aaa;
  opacity: 0.9;
}

.image-indicators .indicator.far {
  background-color: #777;
  opacity: 0.6;
  transform: scale(0.85);
}

.image-indicators .indicator.active {
  background-color: #fff;
  transform: scale(1.15);
  opacity: 1;
}

.image-indicators .indicator.faint {
  background-color: #666;
  opacity: 0.4;
  transform: scale(0.7);
}

.image-indicators .indicator-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15), 0 0 12px rgba(255,255,255,0.15);
  transform: translate(-50%, -50%);
  transition: left 220ms ease, top 220ms ease;
  pointer-events: none;
}

/* Small Box Button */
.small-box-btn {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  background-color: transparent;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  border-radius: 4px;
}

.small-box-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .small-box-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}

/* Modal */
.modal-dialog {
  max-width: 100vw;
  /* Fallback to classic viewport units */
  max-height: 100vh;
  /* Stable viewport height to reduce jumping */
  max-height: 100svh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  /* Fallback */
  height: 100vh;
  /* Stable viewport height to reduce jumping */
  height: 100svh;
  padding: 0;
  overflow: hidden;
}

.modal-body img {
  max-width: 100vw;
  /* Fallback */
  max-height: 100vh;
  /* Stable viewport height to reduce jumping */
  max-height: 100svh;
  object-fit: contain;
  touch-action: none; /* allow pinch/drag handling */
  user-select: none;
}

@media (max-width: 768px) {
  .modal-dialog {
    margin: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    /* Fallback */
    height: 100vh !important;
    /* Stable viewport height */
    height: 100svh !important;
  }

  .modal-content {
    width: 100% !important;
    /* Fallback */
    height: 100vh !important;
    max-height: 100vh !important;
    /* Stable viewport height */
    height: 100svh !important;
    max-height: 100svh !important;
    overflow: hidden !important;
    border: none !important;
    border-radius: 0 !important;
  }

  .modal-body {
    width: 100vw !important;
    /* Fallback */
    height: 100vh !important;
    /* Stable viewport height */
    height: 100svh !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .modal {
    overflow-y: hidden !important;
  }
}

/* Further reduce iOS bounce/backdrop jitter */
.modal,
.modal-backdrop {
  overscroll-behavior: contain;
}

/* Desktop/laptop: constrain non-modal layout width */
@media (min-width: 992px) {
  .image-container {
    width: 80%;
    max-width: 1000px;
  }
  .gallery-nav,
  .image-indicators {
    width: 80%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Modal Navigation */
.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 32px;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.3s ease;
  z-index: 10;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.modal-nav-btn:active {
  transform: translateY(-50%) scale(1);
}

.modal-nav-btn.left {
  left: 10px;
}

.modal-nav-btn.right {
  right: 10px;
}

.modal-nav-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Modal Close Button */
.close-modal {
  font-size: 2rem;
  color: white;
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  line-height: 1;
}

.close-modal:hover {
  color: #ccc;
}

/* Disable modal nav buttons when zoomed */
.modal-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
