/* CLS (Cumulative Layout Shift) Improvements */
/* This file contains styles to prevent layout shifts during page loading */

/* Gallery Image Containers with Aspect Ratio Reservation */
.gallery-image-container {
  position: relative;
  overflow: hidden;
  background-color: #f5f5f5;
}

/* Standard gallery image aspect ratio (4:3) */
.gallery-image-container::before {
  content: '';
  display: block;
  padding-top: 75%; /* 4:3 aspect ratio */
}

.gallery-image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

/* Image loading states - updated for non-lazy loading */
.gallery-image-container img {
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.gallery-image-container img.loaded {
  opacity: 1;
}

.gallery-image-container img.loading {
  opacity: 0.5;
}

/* Box image improvements for reliable loading */
.box img {
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.box img.loaded {
  opacity: 1;
}

/* Error state for failed images */
.box img[style*="display: none"] {
  display: none !important;
}

.box[style*="opacity: 0.3"] {
  opacity: 0.3 !important;
  pointer-events: none !important;
  background-color: #f8f8f8;
}

/* Box styling without loading indicators */
.box {
  position: relative;
}

/* Box element improvements for gallery pages */
.box {
  position: relative;
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  padding: 10px;
  margin-bottom: 20px;
  min-height: 200px; /* Reserve minimum space */
}

.box p {
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box a {
  display: block;
  width: 100%;
  height: 100%;
}

.box img {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

/* Slider image improvements */
.sl-slide-inner img {
  max-width: 100%;
  height: auto;
  width: auto;
}

/* Font loading improvements */
/* Ensure all custom fonts use font-display: swap */
h1, h2, h3, h4, h5, h6, .created {
  font-display: swap;
}

/* Fallback fonts to prevent layout shift */
body h1, body h2, body h3, body h4, body .created {
  font-family: "Fjalla One", "Arial Black", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-display: swap;
}

/* Main content font fallbacks */
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Prevent font loading layout shifts with consistent line heights */
.main-info h4 {
  line-height: 1.4;
  min-height: 1.4em;
}

.main-info p {
  line-height: 1.6;
  min-height: 1.6em;
}

/* Prevent layout shift for icons and ensure proper alignment */
.icon-medium {
  font-size: 32px !important;
  width: 72px !important;
  height: 72px !important;
  line-height: 72px !important;
  display: inline-block;
  vertical-align: top;
  text-align: center;
  background: #2dcc70;
  border-radius: 100%;
  color: #fff;
  padding: 0;
}

/* Events section improvements */
.media {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.media .pull-left {
  margin-right: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
}

.media-body {
  flex: 1;
  min-width: 0; /* Prevents flex overflow */
}

.media-body img {
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.media-body a:hover img {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Carousel image loading states */
.carousel-slide img {
  transition: opacity 0.3s ease;
}

.carousel-slide img[style*="opacity: 0.8"] {
  background-color: #f5f5f5;
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  animation: loading-shimmer 1s infinite linear;
}

@keyframes loading-shimmer {
  0% {
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  }
  100% {
    background-position: 20px 20px, 20px 30px, 30px 10px, 10px 20px;
  }
}

/* Responsive media layout */
@media (max-width: 768px) {
  .media {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  
  .media .pull-left {
    margin-bottom: 10px;
  }
  
  .media-body img {
    max-width: 100%;
  }
  
  .icon-medium {
    font-size: 28px !important;
    width: 60px !important;
    height: 60px !important;
    line-height: 60px !important;
  }
}

/* Event modal specific styling */
#eventImageModal .modal-image {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

#eventImageModal .modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #666;
}

/* Event image loading enhancement */
.media-body img[style*="opacity: 0.8"] {
  background-color: #f5f5f5;
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  animation: loading-shimmer 1s infinite linear;
}

/* Address section improvements */
.address li {
  min-height: 24px;
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
}

.address li i {
  width: 20px;
  flex-shrink: 0;
  margin-right: 8px;
  margin-top: 2px;
}

/* Social icons consistent sizing */
.social li {
  width: 36px;
  height: 36px;
}

.social li a {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive improvements */
@media (max-width: 768px) {
  .gallery-image-container::before {
    padding-top: 60%; /* Adjust aspect ratio for mobile */
  }
  
  .box {
    min-height: 150px;
  }
}

@media (max-width: 480px) {
  .gallery-image-container::before {
    padding-top: 50%;
  }
  
  .box {
    min-height: 120px;
  }
}

/* Print styles to prevent CLS issues */
@media print {
  .gallery-image-container::before,
  .gallery-image-container::after {
    display: none;
  }
  
  .gallery-image-container img {
    position: static;
    opacity: 1;
  }
}

/* Modal Styles for Image Gallery */
#imageModal {
  max-width: 90vw;
  width: auto;
  margin: 0 auto;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 90vh;
  overflow: hidden;
}

#imageModal .modal-body {
  padding: 0;
  text-align: center;
  background-color: #000;
  min-height: 400px;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.modal-image-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 400px;
  max-height: 90vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.modal-image {
  max-width: 100%;
  height: auto;
  width: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
  display: block;
  margin: 0 auto;
}

.modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 16px;
  z-index: 10;
}

.modal-nav-buttons {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  pointer-events: none;
  z-index: 20;
}

.modal-nav-btn {
  position: absolute;
  top: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 25px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-nav-btn:hover {
  background-color: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

#imageModal .modal-footer {
  background-color: #f5f5f5;
  border-top: 1px solid #ddd;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-image-info {
  color: #666;
  font-size: 14px;
}

#imageModal .modal-header {
  background-color: #f5f5f5;
  border-bottom: 1px solid #ddd;
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
  #imageModal {
    max-width: 95vw;
    max-height: 85vh;
  }
  
  #imageModal .modal-body {
    max-height: 65vh;
  }
  
  .modal-image-container {
    max-height: 65vh;
  }
  
  .modal-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    font-size: 14px;
  }
  
  .modal-prev {
    left: 10px;
  }
  
  .modal-next {
    right: 10px;
  }
}

@media (max-width: 480px) {
  #imageModal {
    max-width: 100vw;
    max-height: 90vh;
    margin: 0;
  }
  
  #imageModal .modal-body {
    max-height: 60vh;
  }
  
  .modal-image-container {
    max-height: 60vh;
  }
  
  .modal-nav-btn {
    width: 35px;
    height: 35px;
    border-radius: 17px;
    font-size: 12px;
  }
  
  .modal-prev {
    left: 5px;
  }
  
  .modal-next {
    right: 5px;
  }
  
  #imageModal .modal-footer {
    padding: 8px 10px;
  }
  
  .modal-image-info {
    font-size: 12px;
  }
}

/* Dynamic modal sizing for different image orientations */
#imageModal.portrait-image {
  width: 70%;
  max-width: 800px;
}

#imageModal.portrait-image .modal-body {
  max-height: 95vh;
  min-height: 500px;
}

#imageModal.portrait-image .modal-image-container {
  max-height: 95vh;
  min-height: 500px;
}

#imageModal.landscape-image {
  width: 90%;
  max-width: 1200px;
}

#imageModal.landscape-image .modal-body {
  max-height: 90vh;
}

#imageModal.landscape-image .modal-image-container {
  max-height: 80vh;
}

/* Scroll functionality styles */
.modal-image-container::-webkit-scrollbar {
  width: 8px;
}

.modal-image-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.modal-image-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.modal-image-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.modal-scroll-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 5px;
}

.scroll-btn {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 3px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.scroll-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.scroll-btn:disabled {
  background: rgba(0, 0, 0, 0.3);
  cursor: not-allowed;
}

/* Enhanced responsive design for portrait images */
@media (max-width: 768px) {
  #imageModal.portrait-image {
    width: 95%;
  }
  
  #imageModal.portrait-image .modal-body {
    max-height: 80vh;
  }
  
  #imageModal.portrait-image .modal-image-container {
    max-height: 80vh;
  }
  
  #imageModal.landscape-image {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #imageModal.portrait-image .modal-body {
    max-height: 75vh;
  }
  
  #imageModal.portrait-image .modal-image-container {
    max-height: 75vh;
  }
  
  .scroll-btn {
    width: 25px;
    height: 25px;
    font-size: 12px;
  }
}

/* Floating Counter Badge */
.modal-counter-badge {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  backdrop-filter: blur(5px);
  pointer-events: none;
  transition: opacity 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-counter-badge:hover {
  opacity: 0.9;
}

/* Enhanced cursor styling for gallery images */
.box a {
  cursor: pointer;
}

.box a:hover img {
  opacity: 0.9;
  transform: scale(1.02);
  transition: all 0.3s ease;
}

/* Fix for uneven image spacing within containers - flush container with image edges */
.uniform-spacing-img {
  width: 300px !important;
  height: 225px !important;
  object-fit: contain;
  object-position: center center; /* Center the image content */
  display: block !important;
  margin: 0 auto; /* Only horizontal centering, no vertical margin */
}

.uniform-spacing-container .box {
  min-height: 225px !important; /* Exact image height - container flush with image */
  padding: 0 5px !important; /* Only horizontal padding, no vertical */
}

.uniform-spacing-container .box p {
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.uniform-spacing-container .box a {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}

/* Modern Carousel Styles */
#carousel-section {
  position: relative;
  overflow: hidden;
  background: #000;
}

.modern-carousel {
  position: relative;
  width: 100%;
  height: 600px;
  overflow: hidden;
}

.carousel-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
  overflow: hidden;
}

.carousel-slide.active {
  opacity: 1;
  z-index: 2;
}

.carousel-slide.next {
  transform: translateX(100%);
}

.carousel-slide.prev {
  transform: translateX(-100%);
}

/* Direct carousel slide images */
.carousel-slide img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
  transition: transform 0.8s ease-in-out;
}

/* Specific slides that should contain instead of fill */
.carousel-slide[data-slide="0"] img {
  object-fit: cover;
}

.carousel-slide[data-slide="9"] img {
  object-fit: cover;
  object-position: 0px -260px;
}

.carousel-slide[data-slide="31"] img {
  object-fit: inherit;
}


.slide-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.slide-image img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
  transition: transform 0.8s ease-in-out;
}


.slide-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0.3) 50%,
    rgba(0, 0, 0, 0.1) 100%
  );
  display: flex;
  align-items: center;
  z-index: 3;
}

.slide-text {
  color: white;
  max-width: 600px;
  padding: 40px;
  animation: slideInFromLeft 1s ease-out;
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-title {
  font-family: "Fjalla One", Arial, sans-serif;
  font-size: 3.5rem;
  font-weight: normal;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  line-height: 1.2;
}

.slide-description {
  font-size: 1.4rem;
  margin-bottom: 30px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  line-height: 1.6;
  opacity: 0.95;
}

.slide-text .btn {
  background: linear-gradient(45deg, #2dcc70, #27ae60);
  border: none;
  padding: 15px 35px;
  font-size: 1.1rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(45, 204, 112, 0.4);
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
}

.slide-text .btn:hover {
  background: linear-gradient(45deg, #27ae60, #2dcc70);
  box-shadow: 0 6px 20px rgba(45, 204, 112, 0.6);
  transform: translateY(-3px);
}

/* Navigation Controls */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  z-index: 10;
  pointer-events: none;
}

.carousel-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.carousel-prev {
  left: 30px;
}

.carousel-next {
  right: 30px;
}

/* Bootstrap 4 Slide Indicators */
.carousel-indicators {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 15;
  display: flex;
  justify-content: center;
  padding-left: 0;
  margin-right: 15%;
  margin-left: 15%;
  margin-bottom: 1rem;
  list-style: none;
}

.carousel-indicators li {
  box-sizing: content-box;
  flex: 0 1 auto;
  width: 30px;
  height: 3px;
  margin-right: 3px;
  margin-left: 3px;
  text-indent: -999px;
  cursor: pointer;
  background-color: #fff;
  background-clip: padding-box;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  opacity: 0.5;
  transition: opacity 0.6s ease;
}

.carousel-indicators li:before {
  content: "";
}

.carousel-indicators li.active {
  opacity: 1;
}

.carousel-indicators li:hover {
  opacity: 0.75;
}

/* Bootstrap 4 Carousel Captions */
.carousel-caption {
  position: absolute;
  right: 15%;
  bottom: 20px;
  left: 15%;
  z-index: 10;
  padding-top: 20px;
  padding-bottom: 20px;
  color: #fff;
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.4) 100%
  );
  border-radius: 8px;
}

.carousel-caption h5 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  line-height: 1.2;
}

.carousel-caption p {
  font-size: 1.125rem;
  line-height: 1.4;
  margin-bottom: 1rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}


/* Bootstrap 4 responsive classes */
.d-none {
  display: none !important;
}

.d-md-block {
  display: none !important;
}

@media (min-width: 768px) {
  .d-md-block {
    display: block !important;
  }
}

/* Floating Counter Badge Responsive */
@media (max-width: 768px) {
  .modal-counter-badge {
    bottom: 15px;
    right: 15px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .modal-counter-badge {
    bottom: 10px;
    right: 10px;
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 14px;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .modern-carousel {
    height: 500px;
  }
  
  .slide-title {
    font-size: 2.5rem;
  }
  
  .slide-description {
    font-size: 1.2rem;
  }
  
  .slide-text {
    padding: 20px;
    max-width: 90%;
  }
  
  .carousel-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  
  .carousel-prev {
    left: 20px;
  }
  
  .carousel-next {
    right: 20px;
  }
  
  .carousel-indicators {
    margin-bottom: 0.5rem;
    margin-right: 10%;
    margin-left: 10%;
  }
  
  .carousel-caption {
    right: 10%;
    left: 10%;
    bottom: 15px;
    padding: 15px;
  }
  
  .carousel-caption h5 {
    font-size: 1.5rem;
  }
  
  .carousel-caption p {
    font-size: 1rem;
  }
  
}

@media (max-width: 480px) {
  .modern-carousel {
    height: 400px;
  }
  
  .slide-title {
    font-size: 2rem;
    margin-bottom: 15px;
  }
  
  .slide-description {
    font-size: 1rem;
    margin-bottom: 20px;
  }
  
  .slide-text {
    padding: 15px;
  }
  
  .slide-text .btn {
    padding: 12px 25px;
    font-size: 0.9rem;
  }
  
  .carousel-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .carousel-prev {
    left: 15px;
  }
  
  .carousel-next {
    right: 15px;
  }
  
  .carousel-caption {
    right: 5%;
    left: 5%;
    bottom: 10px;
    padding: 10px;
  }
  
  .carousel-caption h5 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
  }
  
  .carousel-caption p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }
  
  
  
  .carousel-indicators li {
    width: 25px;
    height: 2px;
  }
}

/* Animation for slide transitions */
@media (prefers-reduced-motion: no-preference) {
  .carousel-slide {
    transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
  }
  
  .carousel-slide img {
    transition: transform 8s ease-in-out;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .carousel-slide,
  .carousel-slide img,
  .carousel-btn,
  .carousel-indicators li,
  .autoplay-toggle {
    transition: none;
  }
  
  .slide-text {
    animation: none;
  }
}