/* 
 * Prism Analytics Gallery Component - Enhanced Version
 * Premium horizontal image gallery with advanced scroll behaviors
 * Brand Colors: Navy (#0B1220, #0F172A), Prism Gradient, Glass effects
 */

/* ===== THEMING BLOCK ===== */
:root {
  /* Prism Analytics Brand Colors */
  --gallery-bg-primary: #0B1220;
  --gallery-bg-secondary: #0F172A;
  --gallery-card-bg: rgba(15, 23, 42, 0.8);
  --gallery-glass-bg: rgba(255, 255, 255, 0.05);
  --gallery-border: rgba(255, 255, 255, 0.1);
  --gallery-text-primary: #E7EEF7;
  --gallery-text-secondary: #94A3B8;
  --gallery-text-muted: #64748B;
  --gallery-accent-gradient: linear-gradient(135deg, #6366f1 0%, #d946ef 50%, #06b6d4 100%);
  --gallery-hover-glow: linear-gradient(135deg, #14B8A6, #7A5CFF);
  --gallery-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  --gallery-shadow-hover: 0 30px 60px rgba(0, 0, 0, 0.4);
}

/* ===== GALLERY SECTION ===== */
.gallery-section {
  padding: 5rem 0;
  background: var(--gallery-bg-secondary);
  border-top: 1px solid var(--gallery-border);
  border-bottom: 1px solid var(--gallery-border);
  position: relative;
  overflow: hidden;
}

.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.gallery-header {
  text-align: center;
  margin-bottom: 4rem;
}

.gallery-title {
  font-size: 3rem;
  font-weight: 700;
  font-family: 'Sora', 'Work Sans', sans-serif;
  background: var(--gallery-accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.gallery-subtitle {
  font-size: 1.25rem;
  color: var(--gallery-text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ===== GALLERY RAIL CONTAINER ===== */
.gallery-rail-container {
  position: relative;
  margin-bottom: 2rem;
}

/* Gradient hairline at top */
.gallery-rail-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gallery-accent-gradient);
  z-index: 2;
  border-radius: 1px;
}

/* ===== GALLERY RAIL ===== */
.gallery-rail {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 1.5rem 0 2rem 0;
  cursor: grab;
  position: relative;
}

.gallery-rail:active {
  cursor: grabbing;
}

/* Hide scrollbar */
.gallery-rail::-webkit-scrollbar {
  display: none;
}

.gallery-rail {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Smooth scrolling for seamless loop */
.gallery-rail {
  scroll-behavior: auto; /* Override smooth for seamless jumping */
}

/* ===== GALLERY CARDS ===== */
.gallery-card {
  flex: 0 0 auto;
  width: 320px;
  height: 420px;
  background: var(--gallery-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid transparent;
  background-image: 
    linear-gradient(var(--gallery-card-bg), var(--gallery-card-bg)),
    var(--gallery-accent-gradient);
  background-origin: border-box;
  background-clip: content-box, border-box;
  border-radius: 16px;
  overflow: hidden;
  scroll-snap-align: start;
  position: relative;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-image 0.25s ease;
  box-shadow: var(--gallery-shadow);
}

.gallery-card:hover {
  transform: translateY(-22px);
  box-shadow: var(--gallery-shadow-hover);
  background-image: 
    linear-gradient(var(--gallery-card-bg), var(--gallery-card-bg)),
    var(--gallery-hover-glow);
}

.gallery-card:focus {
  outline: none;
  transform: translateY(-22px);
  box-shadow: var(--gallery-shadow-hover);
  border: 2px solid #6366f1;
}

/* ===== GALLERY IMAGES ===== */
.gallery-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center;
  transition: transform 0.25s ease;
  display: block;
}

.gallery-card:hover .gallery-image {
  transform: scale(1.03);
}

/* ===== GALLERY CAPTIONS (UPDATED PADDING) ===== */
.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: rgba(15, 23, 42, 0.95);
  padding: 22px;
  color: var(--gallery-text-primary);
  transform: translateY(0);
  transition: transform 0.25s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.gallery-card:hover .gallery-caption {
  transform: translateY(-8px); /* Subtle nudge up on hover */
}

.gallery-caption-title {
  font-size: 1.25rem;
  font-weight: 600;
  font-family: 'Sora', 'Work Sans', sans-serif;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  text-align: center;
}

.gallery-caption-subtitle {
  font-size: 1rem;
  color: var(--gallery-text-primary);
  margin-bottom: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

.gallery-caption-desc {
  font-size: 0.9rem;
  color: var(--gallery-text-primary);
  line-height: 1.4;
  opacity: 0.9;
  text-align: center;
}

/* ===== NAVIGATION ARROWS ===== */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--gallery-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gallery-text-primary);
  font-size: 1.25rem;
  font-weight: bold;
  transition: all 0.3s ease;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
}

.gallery-rail-container:hover .gallery-nav {
  opacity: 1;
  pointer-events: auto;
}

/* Always show on touch devices */
@media (hover: none) {
  .gallery-nav {
    opacity: 1;
    pointer-events: auto;
  }
}

.gallery-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.gallery-nav:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.gallery-nav-left {
  left: 1rem;
}

.gallery-nav-right {
  right: 1rem;
}

/* ===== LIGHTBOX MODAL (Simplified) ===== */
.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.gallery-lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.gallery-lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.gallery-lightbox-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox-info {
  margin-top: 2rem;
  text-align: center;
  max-width: 600px;
  color: var(--gallery-text-primary);
}

.gallery-lightbox-title {
  font-size: 2rem;
  font-weight: 600;
  font-family: 'Sora', 'Work Sans', sans-serif;
  margin-bottom: 0.5rem;
}

.gallery-lightbox-subtitle {
  font-size: 1.2rem;
  color: var(--gallery-text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.gallery-lightbox-desc {
  font-size: 1rem;
  color: var(--gallery-text-muted);
  line-height: 1.6;
}

.gallery-lightbox-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gallery-text-primary);
  font-size: 1.5rem;
  transition: all 0.3s ease;
  z-index: 10;
}

.gallery-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet */
@media (max-width: 1024px) {
  .gallery-card {
    width: 300px;
    height: 400px;
  }
  
  .gallery-image {
    height: 220px;
  }
  
  .gallery-rail {
    gap: 1rem;
  }
  
  .gallery-title {
    font-size: 2.5rem;
  }
  
  .gallery-nav {
    width: 44px;
    height: 44px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .gallery-container {
    padding: 0 1rem;
  }
  
  .gallery-card {
    width: 280px;
    height: 380px;
  }
  
  .gallery-image {
    height: 200px;
  }
  
  .gallery-rail {
    padding: 1rem 0 1.5rem 0;
    gap: 1rem;
  }
  
  .gallery-title {
    font-size: 2rem;
  }
  
  .gallery-subtitle {
    font-size: 1.1rem;
  }
  
  .gallery-caption {
    height: 160px;
    padding: 18px;
  }
  
  .gallery-caption-title {
    font-size: 1.1rem;
  }
  
  .gallery-caption-subtitle {
    font-size: 0.95rem;
  }
  
  .gallery-caption-desc {
    font-size: 0.85rem;
  }
  
  .gallery-nav {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  
  .gallery-nav-left {
    left: 0.5rem;
  }
  
  .gallery-nav-right {
    right: 0.5rem;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .gallery-card {
    width: 260px;
    height: 360px;
  }
  
  .gallery-image {
    height: 180px;
  }
  
  .gallery-title {
    font-size: 1.75rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-image,
  .gallery-caption,
  .gallery-nav,
  .gallery-lightbox {
    transition: none;
  }
  
  .gallery-rail {
    scroll-behavior: auto;
  }
}

/* Focus styles for keyboard navigation */
.gallery-card:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.gallery-nav:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* ===== LOADING STATE ===== */
.gallery-image[data-loading="true"] {
  background: linear-gradient(90deg, 
    var(--gallery-glass-bg) 25%, 
    rgba(255, 255, 255, 0.1) 50%, 
    var(--gallery-glass-bg) 75%
  );
  background-size: 200% 100%;
  animation: galleryShimmer 2s infinite;
}

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