
/* ── Category sections ── */
.cat-section {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-top: 1px solid rgba(255,255,255,0.55);
  border-bottom: 1px solid rgba(255,255,255,0.2);

}
.cat-section .container {
  max-width: 2200px;
}
/* mas aire al cerrar la pagina, antes del footer */

.cat-section:nth-child(even) {
  background: rgba(248,245,241,0.68);
}

/* La lámina de cristal de esta página va más opaca que la del resto: las fotos
   necesitan separarse del fondo. */
.cristal-tramo {
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.74) 0, rgba(248,245,241,0.68) 900px, rgba(255,255,255,0.74) 1800px);
  -webkit-backdrop-filter: blur(34px) saturate(180%);
  backdrop-filter: blur(34px) saturate(180%);
}

.cat-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 3.25rem;
  gap: 1rem;
}
.cat-header h2 { margin-bottom: 0; }
.cat-count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--green-dark);
  background: rgba(0,136,118,.08);
  border: 1px solid rgba(0,136,118,.15);
  padding: .25rem .75rem;
  border-radius: 100px;
  white-space: nowrap;
}

/* ── Photo grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  container-type: inline-size;
}

.photo-item {
  aspect-ratio: 4 / 3;
  border-radius: 13.6px;
  overflow: hidden;
  background: rgba(89,178,166,.08);
  border: 1px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .35s cubic-bezier(0.34,1.56,0.64,1), box-shadow .25s;
  position: relative;
}
/* 140px mas altas, mismo ancho de columna y mismo gap. La cuenta repite la rejilla
   (4 columnas, 24px de gap): si cambia una, cambia la otra. */
@media(min-width:901px) {
  .photo-item { aspect-ratio: auto; width: 100%; height: calc((100cqw - 72px) / 4 * .75 + 140px); }
}
/* Portatiles: la mitad de gap y de radio; la cuenta del alto sigue al gap. */
@media(min-width:901px) and (max-width:1440px) {
  .photo-grid { gap: 12px; }
  .photo-item { border-radius: 13.6px; }
  .cat-section { padding: 1.875rem 0; }
  #content > section.cat-section:last-of-type { padding-bottom: calc(1.875rem + 64px); }
  .cat-header h2 { font-size: clamp(1.4rem, 2.6vw, 2.2rem); }
  /* Titulo de categoria centrado y contador flotando a la derecha, como en escritorio. */
  #content .cat-header { position:relative; justify-content:center; }
  #content .cat-header .cat-count { position:absolute; right:0; top:50%; transform:translateY(-50%); }
  #content .ver-mas-wrap { text-align:center; }
}
@media(min-width:901px) and (max-width:1440px) {
  .photo-item { height: calc((100cqw - 36px) / 4 * .75 + 140px); }
}
@media (min-width:601px){
.photo-item:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 32px rgba(0,136,118,.14);
}
}
.photo-item:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

.photo-item .ph-icon {
  font-size: 2.25rem;
  opacity: .18;
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Extra photos — hidden by default */
.photo-extra {
  display: none;
}
.photo-grid.expanded .photo-extra {
  display: flex;
  animation: fadeUp .45s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Ver más button ── */
.ver-mas-wrap {
  margin-top: 4rem;
  text-align: right;
}
.ver-mas-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--green-dark);
  font-family: var(--body);
  font-size: .9rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  transition: gap .2s, color .2s;
}
@media (min-width:601px){
.ver-mas-btn:hover {
  gap: 14px;
  color: var(--green-hover);
}
}

.ver-mas-btn.expanded .arrow { transform: rotate(180deg); }
.ver-mas-btn .arrow { transition: transform .3s; display: inline-block; }

/* ── Accent colors per category ── */
.c1 { background: linear-gradient(135deg, rgba(89,178,166,.12), rgba(0,136,118,.06)); }
.c2 { background: linear-gradient(135deg, rgba(100,160,200,.12), rgba(60,120,180,.06)); }
.c3 { background: linear-gradient(135deg, rgba(200,140,100,.12), rgba(180,100,60,.06)); }
.c4 { background: linear-gradient(135deg, rgba(140,100,180,.12), rgba(100,60,160,.06)); }
.c5 { background: linear-gradient(135deg, rgba(80,160,140,.12), rgba(40,130,110,.06)); }
.c6 { background: linear-gradient(135deg, rgba(200,170,80,.12), rgba(180,140,40,.06)); }
.c7 { background: linear-gradient(135deg, rgba(100,140,200,.12), rgba(60,100,180,.06)); }
.c8 { background: linear-gradient(135deg, rgba(180,100,120,.12), rgba(160,60,80,.06)); }
.c9 { background: linear-gradient(135deg, rgba(80,180,160,.12), rgba(40,160,130,.06)); }

/* ── Lightbox ── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.85);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
#lightbox.open { display: flex; }
#lightbox-inner {
  width: min(80vw, 900px);
  max-height: 85vh;
  aspect-ratio: 4/3;
  background: rgba(89,178,166,.12);
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
#lightbox-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}
#lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
@media (min-width:601px){
#lightbox-close:hover { background: rgba(255,255,255,.3); }
}


@media(max-width:900px) { .photo-grid { grid-template-columns: repeat(2,1fr); } }

@media(max-width:600px) {
  .cat-header { flex-direction:column; align-items:flex-start; }

  /* Carrusel horizontal en móvil */
  .photo-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: .85rem;
    padding-bottom: .75rem;
    cursor: grab;
    /* ocultar scrollbar visualmente */
    scrollbar-width: none;
  }
  .photo-grid::-webkit-scrollbar { display: none; }
  .photo-grid.dragging { cursor: grabbing; }
  /* Refuerzo ademas del preventDefault() del JS: sin esto, en algunos
     navegadores el primer movimiento del raton sobre una imagen dispara su
     drag nativo (o selecciona texto) antes de que el JS pueda evitarlo. */
  .photo-grid { user-select: none; -webkit-user-select: none; }
  .photo-grid img { -webkit-user-drag: none; user-drag: none; }

  .photo-item {
    flex: 0 0 72vw;
    scroll-snap-align: start;
    aspect-ratio: 4 / 3;
  }

  /* El carrusel arranca con las cuatro primeras y el enlace de "Ver mas" despliega el
     resto, igual que en escritorio. Antes se mostraban las 49 de golpe y el enlace
     sobraba; con el enlace a la vista tiene que tener algo que hacer. */
  .photo-grid.expanded .photo-extra { display: flex; }

  /* El carrusel llega al borde derecho de la pantalla y arranca a 16px del izquierdo,
     como las galerias de Personas afectadas y Sociedad. Se cancelan los 28px de padding
     del contenedor en vez de usar 100vw, que incluiria la barra de scroll. */
  .photo-grid {
    margin-left: -12px;
    margin-right: -28px;
    gap: 16px;
    scroll-padding-left: 16px;
  }
  .photo-item {
    height: 351px;
    aspect-ratio: auto;
    border-radius: 13.6px;  /* mismo radio en las tres versiones, ya no solo en movil */
    /* Deja asomar la mitad de la siguiente foto, como invitacion clara a arrastrar. */
    flex: 0 0 calc((100% - 16px) / 1.5);
  }

  /* "Ver mas fotos": deja de ser carrusel y pasa a una rejilla de 2 columnas con
     todas las fotos de la categoria completas y al mismo tamano, con el mismo
     padding lateral que el resto de secciones (se cancela el sangrado del
     carrusel) y un gap uniforme. "Ver menos" quita la clase .expanded y esto
     deja de aplicarse solo, sin JS aparte. */
  .photo-grid.expanded {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    overflow: visible;
    scroll-snap-type: none;
    margin-left: 0;
    margin-right: 0;
    padding-bottom: 0;
  }
  .photo-grid.expanded .photo-item {
    flex: none;
    width: auto;
    height: auto;
    aspect-ratio: 4 / 3;
    scroll-snap-align: none;
  }

  /* Pie de cada galeria: el contador a la izquierda y el enlace a la derecha, en la
     misma linea. Se rehace el contenedor como rejilla y se colocan las cuatro piezas
     por fila y columna; .cat-header pasa a display:contents para que su titulo y su
     contador sean hijos directos de la rejilla y se puedan colocar por separado. */
  .cat-section .container {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .cat-header { display: contents; }
  .cat-header .section-title { grid-row: 1; grid-column: 1 / -1; }
  .photo-grid { grid-row: 2; grid-column: 1 / -1; }
  .cat-count {
    grid-row: 3; grid-column: 1; justify-self: start;
    margin-top: 24px; margin-left: -12px;
  }
  .ver-mas-wrap {
    display: block;
    grid-row: 3; grid-column: 2; justify-self: end;
    margin-top: 24px; margin-right: -12px;
  }
}

/* Escritorio: titulos de categoria centrados, con mas aire respecto a las fotos,
   y 24px menos de separacion entre categorias. */
@media(min-width:1441px){
  #content .cat-header { position:relative; justify-content:center; margin-bottom:68px; }
  #content .cat-header .cat-count { position:absolute; right:0; top:50%; transform:translateY(-50%); }
  #content > section.cat-section:not(#hero):not(.vista-fondo) { padding-top:89px !important; padding-bottom:89px !important; }
  #content > section.cat-section:not(#hero):not(.vista-fondo):last-of-type { padding-bottom:200px !important; }
  #content .ver-mas-wrap { text-align:center; }
  #content .ver-mas-btn { font-size:clamp(1rem,1.4vw,1.15rem); }
}

#back-link {
  position: fixed;
  top: 5.5rem;
  left: 2rem;
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--green-dark);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: gap .2s;
}
@media (min-width:601px){
#back-link:hover { gap: .65rem; }
}
