/* ==========================================
   Image Gallery Styles - Porsche RS Database
   ========================================== */

.vehicle-gallery {
  margin-top: 2rem;
  padding: 2rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

.gallery-date-group {
  margin-bottom: 3rem;
}

.gallery-date-header {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #f5f5f5;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.gallery-item:active {
  transform: translateY(0);
}

.gallery-item img {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

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

.gallery-item-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.gallery-item-pdf::before {
  content: 'PDF';
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #999;
}

.gallery-type-section {
  margin-bottom: 1.5rem;
}

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

.gallery-type-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 0.625rem;
}

.gallery-item-video {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-item-video::before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.5);
  margin-left: 3px;
}

/* ==========================================
   Full-Screen Modal Gallery
   ========================================== */

.gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.96);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.gallery-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 80px;
}

.gallery-modal-image-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-modal-image.loaded {
  opacity: 1;
  transform: scale(1);
}

.gallery-modal-pdf-container {
  width: 90vw;
  height: 90vh;
  background: white;
  border-radius: 4px;
  overflow: hidden;
}

.gallery-modal-pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Modal Controls */
.gallery-modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 10001;
}

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

.gallery-modal-close::before,
.gallery-modal-close::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: white;
}

.gallery-modal-close::before {
  transform: rotate(45deg);
}

.gallery-modal-close::after {
  transform: rotate(-45deg);
}

.gallery-modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 10001;
}

.gallery-modal-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.gallery-modal-nav.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.gallery-modal-nav.disabled:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-50%);
}

.gallery-modal-prev {
  left: 20px;
}

.gallery-modal-next {
  right: 20px;
}

.gallery-modal-prev::before {
  content: '';
  width: 12px;
  height: 12px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg);
  margin-left: 4px;
}

.gallery-modal-next::before {
  content: '';
  width: 12px;
  height: 12px;
  border-right: 2px solid white;
  border-top: 2px solid white;
  transform: rotate(45deg);
  margin-right: 4px;
}

/* Loading State */
.gallery-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: gallery-spin 0.8s linear infinite;
}

@keyframes gallery-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }

  .gallery-modal-content {
    padding: 60px 20px;
  }

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

  .gallery-modal-prev {
    left: 10px;
  }

  .gallery-modal-next {
    right: 10px;
  }

  .gallery-modal-close {
    top: 10px;
    right: 10px;
  }
}

/* Smooth reveal animation for gallery items */
.gallery-item {
  opacity: 0;
  animation: galleryFadeIn 0.4s ease forwards;
}

.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.2s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.3s; }
.gallery-item:nth-child(n+7) { animation-delay: 0.35s; }

@keyframes galleryFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
