/* ==========================================================================
   Feria de las Culturas Fronterizas · Cracovia, Polonia (Targi Pogranicza Kulturowego)
   Fotografía: José Domingo Flores Saldaña
   ========================================================================== */

:root {
  --bg-main: #07070b;
  --bg-card: #12111b;
  --bg-glass: rgba(9, 9, 15, 0.88);

  --rosa-mexicano: #e91e63;
  --rosa-vibrante: #ff2a85;
  --oro-chiapas: #f5b842;
  --oro-glow: rgba(245, 184, 66, 0.3);
  --azul-facebook: #1877F2;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(245, 184, 66, 0.28);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-full: 9999px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(233, 30, 99, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 50%, rgba(37, 99, 235, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(245, 184, 66, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Canvas de Pétalos Flotantes */
#festiveCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
}

/* ==========================================================================
   ENCABEZADO COMPACTO Y NAVEGACIÓN
   ========================================================================== */
.gallery-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  padding: 0.75rem 1.25rem 0.55rem;
  transition: all 0.3s ease;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
}

.header-branding {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title {
  font-family: var(--font-sans);
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-flag {
  font-size: 1.25em;
  line-height: 1;
  flex-shrink: 0;
}

#headerTag {
  background: linear-gradient(135deg, #ffffff 0%, var(--oro-chiapas) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Línea del Artista / Autor */
.author-line {
  display: inline-flex;
  align-items: center;
  margin-top: 3px;
}

.author-name {
  color: var(--oro-chiapas);
  font-weight: 700;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

/* Botón de Facebook en el Header */
.btn-fb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(24, 119, 242, 0.15);
  border: 1px solid rgba(24, 119, 242, 0.45);
  color: #58a6ff;
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-fb:hover {
  background: var(--azul-facebook);
  border-color: var(--azul-facebook);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(24, 119, 242, 0.45);
  transform: translateY(-1px);
}

.fb-icon {
  flex-shrink: 0;
}

/* Selector de Idiomas (PL / ES / EN) */
.lang-switch {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
}

.btn-lang {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-lang:hover {
  color: #ffffff;
}

.btn-lang.active {
  background: var(--rosa-mexicano);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(233, 30, 99, 0.4);
}

/* Botón de Música con Ecualizador Animado */
.btn-sound {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(245, 184, 66, 0.12);
  border: 1px solid var(--border-glow);
  color: var(--oro-chiapas);
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-sound:hover {
  background: var(--oro-chiapas);
  color: #000;
}

.equalizer-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 14px;
  width: 14px;
}

.equalizer-bars span {
  width: 2px;
  background: currentColor;
  border-radius: 1px;
  height: 4px;
  transition: height 0.2s ease;
}

/* Animación cuando la música está sonando */
.btn-sound.playing .equalizer-bars span:nth-child(1) { animation: eqBar 0.7s infinite alternate ease-in-out; }
.btn-sound.playing .equalizer-bars span:nth-child(2) { animation: eqBar 0.9s infinite alternate ease-in-out 0.2s; }
.btn-sound.playing .equalizer-bars span:nth-child(3) { animation: eqBar 0.6s infinite alternate ease-in-out 0.4s; }
.btn-sound.playing .equalizer-bars span:nth-child(4) { animation: eqBar 0.8s infinite alternate ease-in-out 0.1s; }

@keyframes eqBar {
  0% { height: 3px; }
  100% { height: 14px; }
}

/* Conmutador de Layout (Masonry / Grid) */
.layout-toggle {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
}

.btn-layout {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-layout i {
  width: 16px;
  height: 16px;
}

.btn-layout.active {
  background: #1e1d2c;
  color: var(--oro-chiapas);
}

/* Barra Rápida Minimalista */
.gallery-quick-bar {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quick-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.filter-chip.active {
  background: linear-gradient(135deg, var(--rosa-mexicano), #c2185b);
  color: #ffffff;
  border-color: var(--rosa-vibrante);
  box-shadow: 0 4px 12px rgba(233, 30, 99, 0.35);
}

.chip-count {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.35);
}

.filter-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.25);
}

.tap-hint {
  color: var(--oro-chiapas);
  font-size: 0.75rem;
  opacity: 0.9;
}

/* ==========================================================================
   CONTENEDOR DE LA GALERÍA (DE LLENO A LAS FOTOS)
   ========================================================================== */
.gallery-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  position: relative;
  z-index: 2;
}

/* 1. Modo Mosaico / Masonry (Ajuste orgánico de proporciones) */
.gallery-grid.layout-masonry {
  column-count: 4;
  column-gap: 1rem;
}

.gallery-grid.layout-masonry .photo-card {
  break-inside: avoid;
  margin-bottom: 1rem;
  display: inline-block;
  width: 100%;
}

/* 2. Modo Cuadrícula / Grid */
.gallery-grid.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.gallery-grid.layout-grid .photo-card {
  height: 350px;
}

.gallery-grid.layout-grid .photo-thumb {
  height: 100%;
}

.gallery-grid.layout-grid .photo-thumb img {
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   TARJETA FOTOGRÁFICA LIMPIA (SOLO LA FOTO)
   ========================================================================== */
.photo-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}

.photo-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(245, 184, 66, 0.2);
}

.photo-thumb {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #14131f;
}

.photo-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.photo-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease;
  will-change: transform;
}

.photo-card:hover .photo-thumb img {
  transform: scale(1.04);
}

/* Botón Favorito Flotante sobre la Foto */
.btn-fav {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}

.btn-fav:hover {
  transform: scale(1.15);
  background: var(--rosa-mexicano);
}

.btn-fav.is-fav {
  background: var(--rosa-mexicano);
  border-color: var(--rosa-vibrante);
  box-shadow: 0 0 12px var(--rosa-mexicano);
}

.btn-fav.is-fav i {
  fill: #fff;
}

.btn-fav i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   PIE DE PÁGINA (AUTOR & FACEBOOK)
   ========================================================================== */
.gallery-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(8, 8, 13, 0.95);
  padding: 3rem 1.25rem 4rem;
  position: relative;
  z-index: 2;
}

.footer-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}

.footer-author-card {
  display: inline-flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  padding: 1rem 1.75rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.footer-author-text {
  text-align: left;
}

.footer-author-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--oro-chiapas);
  margin: 0;
  line-height: 1.2;
}

.btn-fb-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--azul-facebook);
  color: #ffffff;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(24, 119, 242, 0.35);
  white-space: nowrap;
}

.btn-fb-cta:hover {
  background: #0f66db;
  box-shadow: 0 6px 20px rgba(24, 119, 242, 0.5);
  transform: translateY(-2px);
}

.footer-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   BOTÓN VOLVER ARRIBA Y TOAST
   ========================================================================== */
.btn-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  color: var(--oro-chiapas);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  z-index: 90;
  transition: all 0.25s ease;
}

.btn-to-top:hover {
  background: var(--oro-chiapas);
  color: #000;
  transform: translateY(-3px);
}

.btn-to-top.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.toast-popup {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 17, 27, 0.95);
  border: 1px solid var(--border-glow);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0,0,0,0.6);
  z-index: 300;
  transition: all 0.3s ease;
}

.toast-popup.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
}

/* ==========================================================================
   FANCYBOX 5 PERSONALIZACIÓN
   ========================================================================== */
.fancybox__container {
  --fancybox-bg: rgba(6, 6, 10, 0.96);
  --fancybox-color: #ffffff;
  --fancybox-accent-color: var(--rosa-mexicano);
  z-index: 1000 !important;
}

/* ==========================================================================
   RESPONSIVIDAD MÓVIL
   ========================================================================== */
@media (max-width: 1100px) {
  .gallery-grid.layout-masonry {
    column-count: 3;
  }
}

@media (max-width: 768px) {
  .gallery-header {
    padding: 0.65rem 0.85rem 0.5rem;
  }

  .header-title {
    font-size: 0.95rem;
  }

  .author-line {
    font-size: 0.72rem;
  }

  .btn-fb {
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
  }

  .btn-sound {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .gallery-grid.layout-masonry {
    column-count: 2;
    column-gap: 0.65rem;
  }

  .gallery-grid.layout-masonry .photo-card {
    margin-bottom: 0.65rem;
  }

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

  .gallery-grid.layout-grid .photo-card {
    height: 220px;
  }

  .tap-hint {
    display: none;
  }

  .footer-author-card {
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.25rem 1.25rem;
    width: 100%;
    max-width: 360px;
  }

  .footer-author-text {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-container {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-branding {
    width: 100%;
    align-items: center;
    text-align: center;
  }

  .author-line {
    justify-content: center;
  }

  .header-controls {
    width: 100%;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
}
