/* ── Banner de categoría activa ────────────────────────────── */
.cat-filter-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1rem;
  background: rgba(212,175,55,.1);
  border: 1px solid rgba(212,175,55,.25);
  border-radius: var(--radius-md);
  font-size: .88rem;
  color: var(--text-main);
  margin-bottom: 1.2rem;
}
.cat-filter-banner strong { color: var(--color-secondary); }
.cat-filter-banner__clear {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .8rem;
  text-decoration: none;
  padding: .2rem .5rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.cat-filter-banner__clear:hover {
  background: var(--border-light);
  text-decoration: none;
}

/* ── Toolbar de filtros ─────────────────────────────────────── */
.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
  align-items: flex-end;
  margin-bottom: 2rem;
  padding: 1.2rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.filter-group--search { flex: 1; min-width: 200px; }
.filter-group__label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
}
.filter-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.filter-tab {
  padding: .38rem 1rem;
  border-radius: 100px;
  border: 1.5px solid var(--border-color);
  background: none;
  color: var(--text-muted);
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-tab:hover { border-color: var(--color-primary); color: var(--color-primary); }
.filter-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.filter-select {
  padding: .38rem .8rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: .88rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  min-width: 150px;
}
.filter-select:focus { border-color: var(--color-primary); }
.filter-input-search {
  width: 100%;
  padding: .4rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: .88rem;
  outline: none;
  transition: border-color var(--transition);
}
.filter-input-search:focus { border-color: var(--color-primary); }
.filter-count {
  margin-left: auto;
  font-size: .82rem;
  color: var(--text-light);
  align-self: flex-end;
  white-space: nowrap;
}

/* Mantener compatibilidad con .gallery-filters (home.php) */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.filter-search {
  margin-left: auto;
  display: flex;
  align-items: center;
}
.filter-search input {
  padding: .4rem .9rem;
  border: 1.5px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: .88rem;
  width: 200px;
  outline: none;
  transition: border-color var(--transition);
}
.filter-search input:focus { border-color: var(--color-primary); }

/* ── Cuadrícula grid ────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.gallery-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.gallery-item__img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
  object-position: center top;
  opacity: 0;
  transition: filter var(--transition), opacity .3s ease;
  filter: sepia(0.12) contrast(1.04);
}
.gallery-item__img.img-loaded {
  opacity: 1;
}
.gallery-item:hover .gallery-item__img { filter: sepia(0) contrast(1); }

/* Badge tipo (foto/video) */
.gallery-item__badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
  background: rgba(44, 30, 15, .75);
  color: var(--color-secondary);
  font-size: .7rem;
  font-weight: bold;
  padding: .2rem .5rem;
  border-radius: 100px;
  letter-spacing: .06em;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}
/* Etiqueta de año histórico (esquina inferior izquierda) */
.gallery-item__year {
  position: absolute;
  bottom: .5rem;
  left: .5rem;
  background: rgba(44, 30, 15, .82);
  color: var(--color-secondary);
  font-size: .75rem;
  font-weight: 700;
  font-family: var(--font-serif);
  padding: .18rem .55rem;
  border-radius: 100px;
  letter-spacing: .04em;
  backdrop-filter: blur(4px);
  z-index: 2;
  pointer-events: none;
}

/* Overlay en hover */
.gallery-item__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(44,30,15,.85) 0%, transparent 55%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: flex-end;
  padding: .8rem;
}
.gallery-item:hover .gallery-item__overlay { opacity: 1; }
.gallery-item__caption {
  color: #fff;
  font-size: .8rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Icono play para videos */
.gallery-item__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(44,30,15,.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-secondary);
  font-size: 1.4rem;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* ── Placeholder de carga ───────────────────────────────────── */
.gallery-skeleton {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--border-light);
  aspect-ratio: 4/3;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Estado vacío ───────────────────────────────────────────── */
.gallery-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.gallery-empty__icon { font-size: 3rem; margin-bottom: 1rem; }
.gallery-empty p { font-size: 1rem; }

/* ── Botón "Cargar más" ─────────────────────────────────────── */
.gallery-load-more {
  text-align: center;
  margin-top: 2rem;
}
#sentinel { height: 1px; }

/* ── Lightbox ───────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.lightbox.open {
  opacity: 1;
  pointer-events: all;
}
/* ── Lightbox dos columnas ──────────────────────────────────── */
.lightbox__inner {
  position: relative;
  width: min(1080px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: #12100c;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.8);
}
/* Columna media */
.lightbox__media {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 1rem;
}
.lightbox__img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: sepia(0) !important;
}
/* Columna sidebar */
.lightbox__sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}
.lightbox__info {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: var(--text-on-dark);
  flex-shrink: 0;
}
.lightbox__caption {
  font-size: .88rem;
  opacity: .9;
  line-height: 1.65;
  white-space: pre-line;
  max-height: 6.6rem;   /* ~4 líneas visibles */
  overflow: hidden;
  transition: max-height .35s ease;
}
.lightbox__caption.expanded {
  max-height: 600px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.caption-toggle {
  display: inline-block;
  background: none;
  border: none;
  color: var(--color-secondary);
  font-size: .75rem;
  cursor: pointer;
  padding: .3rem 0 0;
  opacity: .75;
  transition: opacity var(--transition);
}
.caption-toggle:hover { opacity: 1; }
.lightbox__date {
  font-size: .75rem;
  opacity: .45;
  margin-top: .5rem;
}
.lightbox__fb-link {
  display: inline-block;
  margin-top: .7rem;
  font-size: .78rem;
  color: var(--color-secondary);
  opacity: .8;
}
.lightbox__fb-link:hover { opacity: 1; }
/* Botón cerrar */
.lightbox__close {
  position: absolute;
  top: .6rem;
  right: .7rem;
  background: rgba(0,0,0,.45);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  opacity: .8;
  transition: opacity var(--transition), background var(--transition);
  z-index: 20;
}
.lightbox__close:hover { opacity: 1; background: rgba(0,0,0,.7); }
.lightbox__nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  font-size: 2rem;
  padding: .5rem .8rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  backdrop-filter: blur(4px);
  z-index: 1010;
}
.lightbox__nav:hover { background: rgba(255,255,255,.25); }
.lightbox__nav--prev { left: 1rem; }
.lightbox__nav--next { right: 1rem; }

/* Responsive lightbox */
@media (max-width: 760px) {
  .lightbox__inner {
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .lightbox__media {
    flex: 0 0 auto;
    max-height: 46dvh;
    padding: .4rem;
  }
  .lightbox__img {
    max-height: 45dvh;
  }
  .lightbox__sidebar {
    flex: 1;
    min-height: 0;          /* clave: permite que flex-children hagan scroll */
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,.08);
    overflow: hidden;       /* el scroll lo gestionan los hijos individualmente */
  }
  .lightbox__info {
    max-height: 38%;
    overflow-y: auto;
    padding: .75rem .9rem;
  }
  .lightbox__close {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.6rem;
    top: .35rem;
    right: .35rem;
  }
  /* Flechas prev/next: ocultas en móvil, sustituidas por swipe */
  .lightbox__nav { display: none; }
}

/* ── Responsive galería ─────────────────────────────────────── */
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .gallery-grid { grid-template-columns: 1fr; } }

/* ── Modal de vídeo ─────────────────────────────────────────── */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.video-modal.open {
  opacity: 1;
  pointer-events: all;
}
/* ── Video modal dos columnas ───────────────────────────────── */
.video-modal__inner {
  position: relative;
  width: min(1080px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: #0d0b08;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.8);
}
.video-modal__close {
  position: absolute;
  top: .6rem;
  right: .7rem;
  background: rgba(0,0,0,.45);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  opacity: .8;
  transition: opacity var(--transition), background var(--transition);
  z-index: 20;
}
.video-modal__close:hover { opacity: 1; background: rgba(0,0,0,.7); }
/* Columna media (vídeo) */
.video-modal__media {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: #000;
  padding: 1.5rem;
}
.video-modal__player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.video-modal__player video {
  width: 100%;
  height: 100%;
  display: block;
}
/* Columna sidebar */
.video-modal__sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}
.video-modal__info {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: var(--text-on-dark);
  flex-shrink: 0;
}
.video-modal__caption {
  font-size: .88rem;
  opacity: .85;
  line-height: 1.6;
  white-space: pre-line;
  max-height: 6.4rem;
  overflow: hidden;
  transition: max-height .35s ease;
}
.video-modal__caption.expanded {
  max-height: 600px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.video-modal__date {
  font-size: .75rem;
  opacity: .45;
  margin-top: .4rem;
}

/* Responsive video modal */
@media (max-width: 760px) {
  .video-modal__inner {
    flex-direction: column;
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }
  .video-modal__media {
    flex-shrink: 0;
    padding: .5rem;
  }
  .video-modal__sidebar {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,.08);
    overflow: hidden;
  }
  .video-modal__info {
    max-height: 35%;
    overflow-y: auto;
    padding: .75rem .9rem;
  }
  .video-modal__close {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.6rem;
    top: .35rem;
    right: .35rem;
  }
}

@media (max-width: 640px) {
  .gallery-toolbar { gap: .6rem 1rem; padding: 1rem; }
  .filter-group--search { min-width: 100%; order: -1; }
  .filter-count { display: none; }
}

/* ── Comentarios en modales ──────────────────────────────────── */
.modal-comments {
  flex: 1;
  overflow-y: auto;
  padding: .8rem 1rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.modal-comments::-webkit-scrollbar { width: 4px; }
.modal-comments::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 2px; }

.comments-header {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  margin-bottom: .9rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.comment-item {
  display: flex;
  gap: .65rem;
  padding: .65rem 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.comment-item:last-child { border-bottom: none; }

.comment-item__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-sizing: border-box;
}
.comment-item__body { flex: 1; min-width: 0; }
.comment-item__msg {
  font-size: .82rem;
  color: rgba(255,255,255,.78);
  margin-top: .25rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-line;
}
.comment-item__meta {
  font-size: .7rem;
  color: rgba(255,255,255,.3);
  margin-top: .3rem;
  display: flex;
  gap: .6rem;
  align-items: center;
}
.comment-item__likes { color: rgba(255,200,100,.55); }

.comments-loading,
.comments-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(255,255,255,.25);
  font-size: .82rem;
}
.comments-loading::before { content: '⏳ '; }
.comments-empty::before   { content: '💬 '; }
