/* ---- Galleria pagina dedicata ---- */
.gallery-page .section-header {
  margin-bottom: 24px;
}

.gallery-page .gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto;
  gap: 16px;
  align-items: stretch;
}

.gallery-page .gallery-item {
  aspect-ratio: 4 / 3;
  min-height: 0;
  height: auto;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
    var(--gradient-main) border-box;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.gallery-page .gallery-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, transparent 50%, rgba(124, 58, 237, 0.12) 100%);
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 1;
  pointer-events: none;
}

.gallery-page .gallery-item::after {
  content: '⤢';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-primary);
  background: rgba(10, 14, 23, 0.75);
  border: 1px solid var(--cyan);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 24px rgba(0, 212, 255, 0.35);
}

.gallery-page .gallery-item:hover {
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.gallery-page .gallery-item:hover::before { opacity: 1; }

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

.gallery-page .gallery-item:hover img {
  transform: scale(1.08);
  filter: brightness(1.05);
}

.gallery-page .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lightbox avanzato — dettaglio foto e video (stessa grandezza, tutti i dispositivi) */
.photo-lightbox,
.video-lightbox {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(32px + var(--safe-top))
    max(20px, var(--safe-right))
    calc(24px + var(--safe-bottom))
    max(20px, var(--safe-left));
}

.photo-lightbox .photo-lightbox-inner,
.video-lightbox .video-lightbox-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  max-width: min(96vw, 960px);
  max-height: none;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background:
    linear-gradient(var(--bg-deep), var(--bg-deep)) padding-box,
    var(--gradient-main) border-box;
  box-shadow:
    0 0 30px rgba(0, 212, 255, 0.22),
    0 0 60px rgba(124, 58, 237, 0.14);
  height: min(
    calc(100dvh - 180px - var(--safe-top) - var(--safe-bottom)),
    calc((88vh - 80px) * 3 / 4)
  );
}

.photo-lightbox .lightbox-img,
.video-lightbox-player {
  display: block;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--bg-deep);
  object-fit: cover;
  object-position: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.photo-lightbox .photo-lightbox-meta,
.video-lightbox .video-lightbox-meta {
  width: 100%;
  max-width: min(96vw, 960px);
  margin-top: 16px;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
  padding: 0 4px;
}

.lightbox-nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
}

.photo-lightbox .photo-lightbox-counter,
.video-lightbox .video-lightbox-counter {
  flex: 0 0 auto;
  text-align: center;
  min-width: 4.5rem;
}

.lightbox-img.is-changing,
.video-lightbox-player.is-changing {
  opacity: 0;
  transform: scale(0.97);
}

.lightbox-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  padding: 0 8px;
  flex-wrap: wrap;
}

.lightbox-close-bottom {
  width: auto;
  max-width: none;
  align-self: center;
  padding: 12px 24px;
  min-height: 44px;
  color: var(--bg-deep);
}

.lightbox-close-bottom span {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--bg-deep);
}

.lightbox-close-bottom:hover,
.lightbox-close-bottom:focus,
.lightbox-close-bottom:active {
  color: var(--bg-deep);
}

.lightbox-close-bottom:focus {
  outline: none;
}

.lightbox-close-bottom:focus-visible,
.lightbox-nav:focus-visible {
  outline: 3px solid rgba(0, 212, 255, 0.35);
  outline-offset: 4px;
}

.lightbox-close {
  position: absolute;
  top: max(16px, calc(16px + var(--safe-top)));
  right: max(16px, var(--safe-right));
  width: 52px;
  height: 52px;
  background: rgba(10, 14, 23, 0.9);
  border: 1px solid var(--cyan);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 20;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
  -webkit-tap-highlight-color: transparent;
}

.lightbox-close span {
  display: block;
  margin-top: -2px;
}

.lightbox-close:hover,
.lightbox-close:focus {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.55);
  color: #fff;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.25);
}

.lightbox-close:active {
  transform: scale(0.94);
}

.lightbox-caption {
  margin: 0;
  font-family: var(--font-display);
  color: var(--text-primary);
  font-size: 1rem;
  letter-spacing: 1px;
}

.lightbox-caption:empty {
  display: none;
}

.lightbox-counter {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--cyan);
  letter-spacing: 2px;
  white-space: nowrap;
}

.lightbox-nav {
  position: static;
  transform: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  background: rgba(10, 14, 23, 0.85);
  color: var(--text-primary);
  font-size: 1.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 4px;
}

.lightbox-nav:hover,
.lightbox-nav:focus {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--cyan);
  box-shadow: var(--shadow-glow);
  color: var(--cyan);
}

.lightbox-nav:active {
  transform: scale(0.94);
}

.lightbox-nav:focus {
  outline: none;
}

@media (max-width: 1024px) {
  .gallery-page .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: auto;
    gap: 14px;
  }
}

@media (max-width: 768px) {
  .gallery-page .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: auto;
    gap: 14px;
  }

  .gallery-page .gallery-item {
    aspect-ratio: 4 / 3;
  }

  .gallery-page .gallery-item:hover {
    transform: none;
  }

  .gallery-page .gallery-item::after { display: none; }

  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
  }

  .lightbox-nav-row {
    gap: 20px;
  }

  .lightbox-meta {
    gap: 12px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .gallery-page .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 16px;
  }

  .gallery-page .gallery-item {
    aspect-ratio: 16 / 10;
  }

  .lightbox-nav {
    width: 48px;
    height: 48px;
    font-size: 1.75rem;
  }

  .lightbox-nav-row {
    gap: 18px;
  }

  .lightbox-close {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
}

/* Gallery video grid */
.gallery-videos .video-featured {
  max-width: 900px;
  margin: 0 auto;
  cursor: default;
}

.gallery-videos .video-featured video {
  display: block;
  width: 100%;
  pointer-events: none;
}

.gallery-videos .video-featured .video-play-overlay {
  display: none !important;
}

.gallery-videos .video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 28px;
}

.gallery-videos .video-grid .video-wrapper {
  max-width: none;
  margin: 0;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .photo-lightbox,
  .video-lightbox {
    padding:
      calc(24px + var(--safe-top))
      max(12px, var(--safe-right))
      calc(12px + var(--safe-bottom))
      max(12px, var(--safe-left));
  }

  .photo-lightbox .photo-lightbox-meta,
  .video-lightbox .video-lightbox-meta {
    margin-top: 14px;
  }

  .gallery-videos .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}
.gallery-videos .video-grid .video-wrapper video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-deep);
}

.gallery-videos .video-grid .play-btn {
  width: 56px;
  height: 56px;
}

.gallery-videos .video-grid .play-btn svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .gallery-videos .video-featured {
    max-width: 100%;
  }

  .gallery-videos .video-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
  }

  .gallery-videos .video-grid .play-btn {
    width: 64px;
    height: 64px;
  }

  .gallery-videos .video-grid .play-btn svg {
    width: 28px;
    height: 28px;
  }
}
