/* ==========================================================================
   TORRIJA FOTOS - ESTILOS DE GALERÍA Y VISOR (LIGHTBOX)
   ========================================================================== */

/* Bloqueo de scroll cuando el visor está activo */
body.tpv-body-locked {
  overflow: hidden !important;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   1. VISOR MODAL (LIGHTBOX REUTILIZABLE)
   -------------------------------------------------------------------------- */
.tpv-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

.tpv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tpv-container {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 16px;
}

.tpv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.tpv-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tpv-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--tl-neon-volt, #CCFF00);
  background: rgba(204, 255, 0, 0.08);
  border: 1px solid rgba(204, 255, 0, 0.25);
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.tpv-counter {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8E8E93;
}

.tpv-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpv-btn-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.tpv-btn-action:hover {
  background: rgba(204, 255, 0, 0.18);
  border-color: var(--tl-neon-volt, #CCFF00);
  color: var(--tl-neon-volt, #CCFF00);
  transform: scale(1.05);
}

.tpv-btn-action:active {
  transform: scale(0.95);
}

.tpv-btn-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.tpv-btn-close:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.tpv-btn-close:active {
  transform: scale(0.95);
}

.tpv-main {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 10px 0;
}

.tpv-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tpv-img-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  transition: cursor 0.2s ease;
}

.tpv-img-wrapper.zoomed {
  cursor: grab;
}

.tpv-img-wrapper.zoomed:active {
  cursor: grabbing;
}

.tpv-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85);
  transition: opacity 0.25s ease, filter 0.45s ease, transform 0.25s cubic-bezier(0.2, 0, 0.2, 1);
  will-change: transform, filter;
}

.tpv-image.progressive-loading {
  filter: blur(10px) brightness(0.9);
}

.tpv-image.progressive-loaded {
  filter: blur(0px) brightness(1);
}

.tpv-error-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #FF453A;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  background: rgba(20, 20, 24, 0.85);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid rgba(255, 69, 58, 0.3);
}

.tpv-spinner {
  position: absolute;
  font-size: 2rem;
  color: var(--tl-neon-volt, #CCFF00);
}

.tpv-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(20, 20, 24, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
}

.tpv-nav-btn:hover {
  background: rgba(204, 255, 0, 0.18);
  border-color: var(--tl-neon-volt, #CCFF00);
  color: var(--tl-neon-volt, #CCFF00);
}

.tpv-nav-btn:active {
  transform: translateY(-50%) scale(0.92);
}

.tpv-prev {
  left: 12px;
}

.tpv-next {
  right: 12px;
}

.tpv-footer {
  text-align: center;
  padding: 8px 4px;
}

.tpv-caption {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #C7C7CC;
}

/* --------------------------------------------------------------------------
   2. PÁGINA INDEPENDIENTE DE GALERÍA (/gallery/)
   -------------------------------------------------------------------------- */
.gallery-body-page {
  margin: 0;
  padding: 0;
  background: #0A0A0C;
  color: #FFFFFF;
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.gallery-app-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header de la galería */
.gallery-top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 12, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #1C1C20;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-btn-back {
  background: #141416;
  border: 1px solid #242428;
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.18s ease;
}

.gallery-btn-back:hover {
  border-color: var(--tl-neon-volt, #CCFF00);
  color: var(--tl-neon-volt, #CCFF00);
}

.gallery-nav-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #FFFFFF;
}

/* Banner de título */
.gallery-hero-header {
  padding: 24px 16px 16px 16px;
}

.gallery-hero-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--tl-neon-volt, #CCFF00);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.gallery-hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  text-transform: uppercase;
  margin: 0 0 6px 0;
  line-height: 1.1;
  color: #FFFFFF;
}

.gallery-hero-desc {
  font-size: 0.85rem;
  color: #8E8E93;
  margin: 0;
}

/* Selector de Jornadas */
.gallery-selector-container {
  padding: 0 16px 16px 16px;
}

.gallery-jornadas-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: #242428 transparent;
}

.gallery-chip {
  background: #141416;
  border: 1px solid #242428;
  color: #8E8E93;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
}

.gallery-chip:hover {
  color: #FFFFFF;
  border-color: #3C3C42;
}

.gallery-chip.active {
  background: var(--tl-neon-volt, #CCFF00);
  border-color: var(--tl-neon-volt, #CCFF00);
  color: #0A0A0C;
}

/* Rejilla de fotos */
.gallery-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 0 16px 40px 16px;
}

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

.gallery-photo-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #141416;
  border: 1px solid #242428;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.gallery-photo-card:hover {
  transform: translateY(-3px);
  border-color: var(--tl-neon-volt, #CCFF00);
}

.gallery-photo-card:active {
  transform: scale(0.97);
}

.gallery-photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.9);
  transition: filter 0.2s ease, transform 0.25s ease;
}

/* Efecto de carga progresiva al estilo Instagram */
.gallery-photo-thumb.progressive-loading {
  filter: blur(8px) brightness(0.85);
  transform: scale(1.05); /* Evitar bordes blancos por desenfoque */
}

.gallery-photo-thumb.progressive-loaded {
  filter: blur(0px) brightness(0.9);
  transform: scale(1);
  transition: filter 0.45s cubic-bezier(0.2, 0, 0.2, 1), transform 0.45s cubic-bezier(0.2, 0, 0.2, 1);
}

.gallery-photo-card:hover .gallery-photo-thumb.progressive-loaded {
  filter: blur(0px) brightness(1);
  transform: scale(1.04);
}

.gallery-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 50%, rgba(10, 10, 12, 0.75) 100%);
  display: flex;
  align-items: flex-end;
  padding: 8px;
  pointer-events: none;
}

.gallery-photo-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: #FFFFFF;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Estados de carga y vacío */
.gallery-status-box {
  padding: 40px 20px;
  text-align: center;
  color: #8E8E93;
  font-size: 0.9rem;
}

.gallery-status-icon {
  font-size: 2rem;
  color: #3C3C42;
  margin-bottom: 12px;
}

.gallery-status-box.error {
  color: #FF453A;
}

.gallery-status-box.error .gallery-status-icon {
  color: #FF453A;
}

.gallery-retry-btn {
  margin-top: 14px;
  background: #141416;
  border: 1px solid #3C3C42;
  color: #FFFFFF;
  padding: 8px 18px;
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gallery-retry-btn:hover {
  border-color: var(--tl-neon-volt, #CCFF00);
  color: var(--tl-neon-volt, #CCFF00);
  transform: translateY(-1px);
}

.gallery-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.gallery-season-select {
  background: #141416;
  border: 1px solid #242428;
  color: var(--tl-neon-volt, #CCFF00);
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.gallery-season-select:focus {
  border-color: var(--tl-neon-volt, #CCFF00);
}

/* ==========================================================================
   2. SISTEMA DE LIKES, DOBLE CLIC INSTAGRAM Y VOTACIÓN DE JUGADORES
   ========================================================================== */

/* Animación de corazón flotante pop-up estilo Instagram */
.insta-heart-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 100;
  color: #FF2D55;
  font-size: 4.5rem;
  filter: drop-shadow(0 0 18px rgba(255, 45, 85, 0.7));
  animation: instaHeartPop 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes instaHeartPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.35);
  }
  45% {
    transform: translate(-50%, -50%) scale(0.95);
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

@keyframes heartBeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* Acciones en la tarjeta del grid */
.gallery-card-actions {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  z-index: 10;
  pointer-events: auto;
}

.gallery-card-like-btn {
  background: rgba(10, 10, 12, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  user-select: none;
}

.gallery-card-like-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
}

.gallery-card-like-btn.liked {
  color: #FF2D55;
  border-color: rgba(255, 45, 85, 0.55);
  background: rgba(255, 45, 85, 0.16);
}

.gallery-card-like-btn.liked i {
  animation: heartBeat 0.3s ease;
}

/* Botón de votar mejor foto de mi partido en la tarjeta */
.gallery-card-vote-btn {
  background: rgba(10, 10, 12, 0.88);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #FFD700;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  user-select: none;
}

.gallery-card-vote-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #FFD700;
}

.gallery-card-vote-btn.voted {
  background: #FFD700;
  color: #0A0A0C;
  border-color: #FFD700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.gallery-card-votes-badge {
  background: rgba(255, 215, 0, 0.18);
  color: #FFD700;
  border: 1px solid rgba(255, 215, 0, 0.35);
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Botones en el Visor Lightbox */
.tpv-btn-like {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.tpv-btn-like:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.tpv-btn-like.liked {
  color: #FF2D55;
  border-color: rgba(255, 45, 85, 0.55);
  background: rgba(255, 45, 85, 0.18);
}

.tpv-btn-like.liked i {
  animation: heartBeat 0.3s ease;
}

.tpv-btn-player-vote {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.45);
  color: #FFD700;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.tpv-btn-player-vote:hover {
  background: rgba(255, 215, 0, 0.22);
  border-color: #FFD700;
}

.tpv-btn-player-vote.voted {
  background: #FFD700;
  color: #0A0A0C;
  border-color: #FFD700;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.55);
}

@media (max-width: 600px) {
  .tpv-btn-player-vote .tpv-vote-text {
    display: none;
  }
  .tpv-btn-player-vote {
    padding: 0 12px;
    height: 38px;
  }
  .tpv-btn-like {
    padding: 0 12px;
    height: 38px;
  }
}