/* ============================================
   PEAK3 VISUALS - MODERN GALLERY SYSTEM
   Mobile-first, optimized, beautiful
   ============================================ */

/* CSS Variables */
:root {
  --gallery-bg: #000000;
  --gallery-text: #ffffff;
  --gallery-accent: #E93423;
  --gallery-muted: rgba(255, 255, 255, 0.7);
  --gallery-gap: 8px;
  --gallery-radius: 4px;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ PAGE STRUCTURE ============ */
.gallery-page {
  background: var(--gallery-bg);
  min-height: 100vh;
  color: var(--gallery-text);
}

/* ============ GALLERY HERO ============ */
.gallery-hero {
  padding: 100px 20px 60px;
  text-align: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, var(--gallery-bg) 100%);
}

.gallery-hero__subtitle {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gallery-accent);
  margin-bottom: 16px;
  font-weight: 500;
}

.gallery-hero__title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* ============ GALLERY GRID ============ */
.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gallery-gap);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gallery-gap);
  padding-bottom: 40px;
}

/* Tablet */
@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  :root {
    --gallery-gap: 12px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  :root {
    --gallery-gap: 16px;
  }
}

/* ============ GALLERY ITEMS ============ */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--gallery-radius);
  cursor: pointer;
  aspect-ratio: 4/3;
  background: #111;
}

/* Featured items span 2 columns on larger screens */
.gallery-item--featured {
  grid-column: span 1;
}

@media (min-width: 640px) {
  .gallery-item--featured {
    grid-column: span 2;
    grid-row: span 2;
    aspect-ratio: 1/1;
  }
}

.gallery-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth);
  will-change: transform;
}

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

/* Loading placeholder */
.gallery-item__image[data-src] {
  opacity: 0;
  transition: opacity 0.3s ease, transform var(--transition-smooth);
}

.gallery-item__image.loaded {
  opacity: 1;
}

/* Hover overlay */
.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.4) 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

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

/* Zoom icon on hover */
.gallery-item__zoom {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition-fast);
  pointer-events: none;
}

.gallery-item__zoom svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.gallery-item:hover .gallery-item__zoom {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ============ LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

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

.lightbox__image-wrapper {
  position: relative;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.lightbox.active .lightbox__image {
  transform: scale(1);
  opacity: 1;
}

/* Lightbox controls */
.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox__close:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(90deg);
}

.lightbox__close svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox__nav:hover {
  background: rgba(255,255,255,0.2);
}

.lightbox__nav svg {
  width: 24px;
  height: 24px;
  stroke: white;
}

.lightbox__nav--prev {
  left: 20px;
}

.lightbox__nav--next {
  right: 20px;
}

/* Mobile adjustments for lightbox */
@media (max-width: 640px) {
  .lightbox__nav {
    width: 44px;
    height: 44px;
    bottom: 30px;
    top: auto;
    transform: none;
  }

  .lightbox__nav--prev {
    left: 30%;
    transform: translateX(-50%);
  }

  .lightbox__nav--next {
    right: 30%;
    left: auto;
    transform: translateX(50%);
  }

  .lightbox__close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }
}

/* Counter */
.lightbox__counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

/* ============ PROJECT DETAILS ============ */
.gallery-details {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 20px;
}

.gallery-details__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 40px;
}

@media (min-width: 640px) {
  .gallery-details__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .gallery-details__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.gallery-details__item {
  padding: 20px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

.gallery-details__label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gallery-accent);
  margin-bottom: 8px;
  font-weight: 600;
}

.gallery-details__value {
  font-size: 15px;
  color: var(--gallery-muted);
  line-height: 1.5;
}

/* Description section */
.gallery-description {
  margin-top: 40px;
  padding: 32px;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}

.gallery-description__title {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gallery-accent);
  margin-bottom: 16px;
  font-weight: 600;
}

.gallery-description__text {
  font-size: 16px;
  line-height: 1.8;
  color: var(--gallery-muted);
}

.gallery-description__text strong {
  color: var(--gallery-text);
}

/* ============ CTA SECTION ============ */
.gallery-cta {
  text-align: center;
  padding: 40px 20px 80px;
}

.gallery-cta__button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 40px;
  background: transparent;
  border: 2px solid var(--gallery-accent);
  color: var(--gallery-text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.gallery-cta__button:hover {
  background: var(--gallery-accent);
  border-color: var(--gallery-accent);
}

.gallery-cta__button svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-fast);
}

.gallery-cta__button:hover svg {
  transform: translateX(4px);
}

/* ============ LOADING STATES ============ */
.gallery-item.loading {
  background: linear-gradient(90deg, #111 25%, #1a1a1a 50%, #111 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* ============ TOUCH OPTIMIZATIONS ============ */
@media (hover: none) and (pointer: coarse) {
  .gallery-item:hover .gallery-item__image {
    transform: none;
  }

  .gallery-item:hover::after {
    opacity: 0;
  }

  .gallery-item__zoom {
    display: none;
  }

  .gallery-item:active {
    transform: scale(0.98);
  }
}

/* ============ SWIPE SUPPORT ============ */
.lightbox__container {
  touch-action: pan-y pinch-zoom;
}

.lightbox.swiping .lightbox__image {
  transition: none;
}

/* ============ ACCESSIBILITY ============ */
.gallery-item:focus-visible {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 2px;
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-item__image,
  .lightbox__image,
  .lightbox,
  .gallery-item__zoom {
    transition: none;
  }

  .gallery-item.loading {
    animation: none;
    background: #111;
  }
}
