/**
 * Gallery Page Styles - Ultra Modern Minimalistic Design
 * Vidya Chaitanya Samakhya
 */

/* ============================================
   CSS Custom Properties
   ============================================ */

:root {
  /* Colors - Modern Palette */
  --gallery-bg: #ffffff;
  --gallery-section-bg: #f8f9fa;
  --gallery-text-primary: #1a1a1a;
  --gallery-text-secondary: #6b7280;
  --gallery-text-tertiary: #9ca3af;
  --gallery-border: #e5e7eb;
  
  /* Shadows - Subtle and Modern */
  --gallery-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --gallery-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --gallery-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --gallery-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Lightbox */
  --lightbox-bg: rgba(0, 0, 0, 0.92);
  --lightbox-control-bg: rgba(255, 255, 255, 0.95);
  --lightbox-control-hover: white;

  /* Transitions */
  --gallery-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --gallery-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Spacing */
  --gallery-gap: 2px;
  --gallery-section-spacing: 80px;

  /* Z-index */
  --z-lightbox: 9999;
  --z-lightbox-controls: 10000;
}

/* ============================================
   Category Section Styles
   ============================================ */

.gallery-category-section {
  margin-bottom: var(--gallery-section-spacing);
  scroll-margin-top: 100px;
}

.gallery-category-section:last-child {
  margin-bottom: 0;
}

.gallery-category-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  padding-left: 2px;
  padding-right: 2px;
  border-bottom: 1px solid var(--gallery-border);
}

.gallery-category-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--gallery-text-primary);
  letter-spacing: -0.025em;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.gallery-category-count {
  font-size: 15px;
  color: var(--gallery-text-tertiary);
  font-weight: 400;
}

/* ============================================
   Gallery Grid - Modern Layout
   ============================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gallery-gap);
  max-width: 100%;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 3px;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 4px;
  }
}

@media (min-width: 1280px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 4px;
  }
}

@media (min-width: 1536px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 4px;
  }
}

/* ============================================
   Gallery Item Styles
   ============================================ */

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--gallery-bg);
  cursor: pointer;
  opacity: 1 !important;
  transform: translateZ(0);
  will-change: transform, opacity;
  transition: all var(--gallery-transition);
  backface-visibility: hidden;
  aspect-ratio: 1;
  box-shadow: var(--gallery-shadow-sm);
}

.gallery-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background var(--gallery-transition);
  z-index: 1;
  pointer-events: none;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--gallery-shadow-xl);
  z-index: 10;
}

.gallery-item:hover::before {
  background: rgba(0, 0, 0, 0.15);
}

.gallery-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--gallery-transition-slow);
  will-change: transform;
}

.gallery-item:hover img {
  transform: scale(1.08);
}

/* Image overlay on hover */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--gallery-transition);
  pointer-events: none;
  z-index: 2;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--gallery-transition), transform var(--gallery-transition);
  pointer-events: none;
  z-index: 3;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

.gallery-item:hover .gallery-item-caption {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Loading Skeleton
   ============================================ */

.image-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #f3f4f6 25%,
    #e5e7eb 50%,
    #f3f4f6 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  z-index: 1;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   Lightbox Styles
   ============================================ */

.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--lightbox-bg);
  z-index: var(--z-lightbox);
  opacity: 0;
  transition: opacity var(--gallery-transition);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  max-width: 92%;
  max-height: 92%;
  margin: auto;
  position: relative;
}

.lightbox img {
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--lightbox-control-bg);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--gallery-transition);
  z-index: var(--z-lightbox-controls);
  box-shadow: var(--gallery-shadow-lg);
}

.lightbox-close:hover {
  background: var(--lightbox-control-hover);
  transform: scale(1.08);
  box-shadow: var(--gallery-shadow-xl);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--lightbox-control-bg);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--gallery-transition);
  z-index: var(--z-lightbox-controls);
  box-shadow: var(--gallery-shadow-lg);
}

.lightbox-nav:hover {
  background: var(--lightbox-control-hover);
  transform: translateY(-50%) scale(1.08);
  box-shadow: var(--gallery-shadow-xl);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

.lightbox-info {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  text-align: center;
  max-width: 85%;
  font-size: 15px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

/* Lightbox Description - Ensure it's visible and properly sized */
/* Override accessibility.css [aria-live] rule that hides elements */
#lightboxDescription {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0;
  padding: 0;
  display: block !important;
  overflow: visible !important;
  white-space: normal !important;
  word-wrap: break-word;
  line-height: 1.5;
  visibility: visible !important;
  opacity: 1 !important;
  clip: auto !important;
  border: none;
  outline: none;
}

/* ============================================
   Error States
   ============================================ */

.gallery-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
  color: #ef4444;
}

.gallery-error__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.gallery-error__message {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.gallery-error__detail {
  font-size: 0.875rem;
  color: var(--gallery-text-secondary);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px;
  }

  .gallery-category-section {
    margin-bottom: 48px;
  }

  .gallery-category-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
  }

  .gallery-category-title {
    font-size: 20px;
  }

  .lightbox-close,
  .lightbox-nav {
    width: 40px;
    height: 40px;
  }

  .lightbox-close {
    top: 16px;
    right: 16px;
  }

  .lightbox-prev {
    left: 16px;
  }

  .lightbox-next {
    right: 16px;
  }

  .lightbox-info {
    bottom: 16px;
    padding: 10px 20px;
    font-size: 14px;
  }

  #lightboxDescription {
    font-size: 14px;
    line-height: 1.4;
  }
}

/* ============================================
   Accessibility
   ============================================ */

.gallery-item:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 3px;
  border-radius: 4px;
}

.lightbox-close:focus,
.lightbox-nav:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-item,
  .gallery-item img,
  .lightbox,
  .lightbox-close,
  .lightbox-nav {
    transition: none;
    animation: none;
  }
}

/* ============================================
   Performance Optimizations
   ============================================ */

.gallery-item,
.lightbox,
.lightbox-content {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.gallery-item img {
  content-visibility: auto;
  contain: layout style paint;
}
