/* =====================
   CUATRO AÑOS · GALERÍA EN BUCLE
====================== */
body.cuatro-anios {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(35, 79, 158, 0.35), transparent 60%),
    #040d1e;
  color: #ffffff;
}

body.reposo,
body.reposo * {
  cursor: none;
}

/* ── Header ───────────────────────────── */
/* Logo + "4 AÑOS" como un solo bloque centrado, subtítulo debajo */
/* width y min-width evitan que la pista de la galería (muy ancha) ensanche la página en móvil */
.ca-header {
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.2vh 32px 1.8vh;
  text-align: center;
}

.ca-marca {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.2vw, 36px);
}

.ca-logo img {
  height: clamp(44px, 8vh, 92px);
  width: auto;
  display: block;
}

.ca-separador {
  width: 3px;
  height: clamp(44px, 8vh, 92px);
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--primary, #234f9e), var(--secondary, #e23c1b));
}

.ca-marca h1 {
  margin: 0;
  font-size: clamp(2.4rem, 9vh, 6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ca-numero {
  color: var(--secondary, #e23c1b);
  font-size: 1.25em;
}

.ca-subtitulo {
  margin: 1.2vh 0 0;
  font-size: clamp(0.85rem, 2vh, 1.15rem);
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.65);
}

/* Controles flotantes en la esquina, fuera del flujo del header */
.ca-controles {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 10;
  display: flex;
  gap: 10px;
  transition: opacity 0.4s ease;
}

.ca-boton {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ca-boton:hover {
  background: var(--secondary, #e23c1b);
}

body.reposo .ca-controles {
  opacity: 0;
}

/* ── Galería ──────────────────────────── */
/* Aparece suavemente cuando las fotos ya están precargadas */
.ca-galeria {
  opacity: 0;
  transition: opacity 1s ease;
}

body.lista .ca-galeria {
  opacity: 1;
}

.ca-galeria {
  flex: 1;
  min-height: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 2.5vh;
  /* Desvanecer los bordes izquierdo y derecho */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

.ca-fila {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ca-pista {
  display: flex;
  height: 100%;
  width: max-content;
  animation: ca-desplazar linear infinite;
  will-change: transform;
}

/* Izquierda → derecha: la pista (contenido duplicado) avanza media longitud y vuelve a empezar */
@keyframes ca-desplazar {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

.ca-galeria.pausada .ca-pista {
  animation-play-state: paused;
}

/* ── Casillas ─────────────────────────── */
.ca-casilla {
  position: relative;
  height: 100%;
  margin: 0 16px 0 0; /* debe coincidir con la separación usada en cuatro-anios.js */
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: zoom-in;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.ca-casilla img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.8s ease, transform 0.6s ease, filter 0.4s ease;
}

/* Imágenes con fondo transparente: completas, sin recorte */
.ca-casilla--contain {
  background: linear-gradient(135deg, rgba(35, 79, 158, 0.35), rgba(226, 60, 27, 0.2));
}

.ca-casilla--contain img {
  object-fit: contain;
  padding: 4%;
}

.ca-casilla.cargada img {
  opacity: 1;
  transform: scale(1);
}

.ca-casilla:hover img,
.ca-casilla:focus-visible img {
  transform: scale(1.06);
  filter: brightness(1.08);
}

.ca-casilla::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
  pointer-events: none;
}

.ca-casilla:hover::after,
.ca-casilla:focus-visible::after {
  border-color: var(--secondary, #e23c1b);
}

.ca-casilla:focus-visible {
  outline: none;
}

/* ── Visor ────────────────────────────── */
.ca-visor {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: none;
  background: transparent;
}

.ca-visor[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ca-aparecer 0.25s ease;
}

.ca-visor::backdrop {
  background: rgba(2, 8, 20, 0.92);
}

@keyframes ca-aparecer {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ca-visor img {
  max-width: calc(100vw - 160px);
  max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.ca-visor-cerrar {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 1.6rem;
}

.ca-visor-flecha {
  position: absolute;
  top: 50%;
  margin-top: -24px;
  width: 48px;
  height: 48px;
  font-size: 2rem;
}

.ca-visor-flecha--prev { left: 24px; }
.ca-visor-flecha--next { right: 24px; }

/* ── Responsive ───────────────────────── */
@media (max-width: 700px) {
  .ca-header {
    padding: 60px 16px 10px;
  }
  .ca-marca {
    gap: 12px;
  }
  .ca-logo img,
  .ca-separador {
    height: 40px;
  }
  .ca-marca h1 {
    font-size: 2.2rem;
  }
  .ca-subtitulo {
    max-width: 100%;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }
  .ca-boton {
    width: 36px;
    height: 36px;
  }
  .ca-galeria {
    gap: 10px;
  }
  .ca-visor img {
    max-width: calc(100vw - 32px);
  }
  .ca-visor-flecha {
    top: auto;
    bottom: 24px;
    margin-top: 0;
  }
}
