/* Custom overrides to widen the page, especially the main content area, while preserving responsiveness. */

/* Default Bootstrap container widths are 750/970/1170. Increase for larger screens. */
@media (min-width: 1200px) {
  .container {
    width: 1400px; /* was 1170px */
  }
}

/* Very large screens */
@media (min-width: 1600px) {
  .container {
    width: 1560px;
  }
}

@media (min-width: 1900px) {
  .container {
    width: 1720px;
  }
}

/* --- Sliding gallery (horizontal scroll with snap) --- */
.gallery-slider {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px 10px 2px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}
.gallery-slider > img,
.gallery-slider > a,
.gallery-slider > figure {
  flex: 0 0 auto;
  scroll-snap-align: start;
}
.gallery-slider img {
  height: 50vh;
  max-height: 500px;
  width: auto;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.gallery-caption {
  color: #555;
  font-size: 0.95em;
  margin: 4px 0 20px;
}
@media (max-width: 576px) {
  .gallery-slider img {
    height: 40vh;
    max-height: 280px;
  }
}
/* Optional: subtle scrollbar styling on WebKit */
.gallery-slider::-webkit-scrollbar { height: 10px; }
.gallery-slider::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 10px; }
.gallery-slider::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.25); border-radius: 10px; }

/* --- Responsive fixes for small screens and content overflow --- */
@media (max-width: 991px) {
  .navbar .navbar-collapse {
    max-height: 70vh;
    overflow-y: auto;
  }
  .profile-card {
    position: static;
    top: auto;
    margin-bottom: 20px;
  }
}

@media (min-width: 992px) {
  .profile-card {
    position: sticky;
    top: 80px;
  }
}

/* Ensure media scales within content */
[role="main"] img,
[role="complementary"] img,
.content img {
  max-width: 100%;
  height: auto;
}

/* Prevent code blocks from breaking layout */
[role="main"] pre,
[role="main"] code {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Make tables scrollable on small screens without breaking layout */
[role="main"] table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

[role="main"] iframe,
[role="main"] video {
  max-width: 100%;
}


/* Prevent fixed navbar from overlapping content on small/medium screens */
@media (max-width: 1199px) {
  .navbar-fixed-top { position: static; }
  body { padding-top: 0 !important; }
}


/* Tweak profile photo size on stacked layout (small screens) */
@media (max-width: 991px) {
  .profile-card img {
    display: block;
    max-width: 120px !important; /* override inline max-width: 50% */
    width: auto;
    height: auto;
    margin: 0 auto 15px; /* center under name */
  }
}

@media (max-width: 576px) {
  .profile-card img {
    max-width: 96px !important; /* even smaller on very narrow phones */
  }
}

/* Prevent TOC (right sidebar) from colliding with top navbar */
@media (min-width: 1200px) {
  .bs-sidebar.affix {
    top: 80px; /* keep below fixed navbar */
  }
}
@media (max-width: 1199px) {
  .bs-sidebar.affix {
    position: static !important; /* disable affix on smaller screens */
    top: auto;
  }
}

/* --- Gallery slider enhancement (one-at-a-time carousel) --- */
.gallery-slider.gallery-enhanced {
  position: relative;
  display: inline-block;
  overflow: hidden;
  gap: 0;
  scroll-snap-type: none;
  -webkit-overflow-scrolling: auto;
  border-radius: 6px;
}
.gallery-slider.gallery-enhanced > img {
  display: none;
  max-width: 100%;
  height: 50vh;
  max-height: 500px;
  width: auto;
}
.gallery-slider.gallery-enhanced > img.is-active {
  display: block;
}
.gallery-slider.gallery-enhanced .gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 2;
}
.gallery-slider.gallery-enhanced .gallery-arrow:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.gallery-slider.gallery-enhanced .gallery-arrow.prev { left: 6px; }
.gallery-slider.gallery-enhanced .gallery-arrow.next { right: 6px; }

/* Hide native scrollbar when enhanced */
.gallery-slider.gallery-enhanced::-webkit-scrollbar { display: none; }

@media (hover: none) and (pointer: coarse) {
  .gallery-slider.gallery-enhanced .gallery-arrow {
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
}

@media (max-width: 576px) {
  .gallery-slider.gallery-enhanced > img {
    height: 40vh;
    max-height: 280px;
  }
}
