/**
 * Material gráfico CSAI: carrusel horizontal como galería_cobaqroo + video vertical 9:16 (object-fit contain).
 */
.csai-material-mount {
  --gap: 14px;
  width: 100%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Carrusel: mismas clases que galeria_cobaqroo (media-block, carousel, …); reglas bajo el mount para no mezclar con el carrusel de Bootstrap. */
.csai-material-mount .media-block {
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.csai-material-mount .carousel {
  display: block;
  width: 100%;
}

.csai-material-mount .carousel-track {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
  cursor: grab;
}

.csai-material-mount .carousel-track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}

.csai-material-mount .carousel-track.is-dragging img {
  user-select: none;
  pointer-events: none;
}

.csai-material-mount .carousel-track::-webkit-scrollbar {
  display: none;
}

/* Una imagen por vista (flyers más legibles que 2 columnas en 470px). */
.csai-material-mount .carousel-slide {
  flex: 0 0 100%;
  flex-shrink: 0;
  min-width: 0;
  box-sizing: border-box;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.12);
}

.csai-material-mount .carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  cursor: zoom-in;
}

.csai-material-mount .carousel:focus {
  outline: none;
}

.csai-material-mount .carousel:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Ficha de contacto (datos de mapa_cobaqroo/data/instituciones.json) */
.csai-material-mount .csai-sede-ficha {
  background: rgba(13, 110, 253, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.csai-material-mount .csai-ficha-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 32%) 1fr;
  gap: 0.25rem 0.75rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.csai-material-mount .csai-ficha-label {
  font-weight: 600;
  color: #495057;
}

.csai-material-mount .csai-ficha-val {
  color: #212529;
  word-break: break-word;
}

.csai-material-mount .csai-ficha-val a {
  word-break: break-all;
}

.csai-material-mount .csai-ficha-cap-list {
  padding-left: 1.1rem;
  margin: 0;
  color: #495057;
}

.csai-material-mount .csai-ficha-actions .btn {
  font-size: 0.8rem;
}

/* Paginación (‹ › + contador), debajo del carril y encima de los puntos */
.csai-material-mount .csai-carousel-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.65rem;
  margin-bottom: 0.15rem;
}

.csai-material-mount .csai-carousel-pager-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background: #fff;
  color: var(--bs-primary, #0d6efd);
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.csai-material-mount .csai-carousel-pager-btn:hover:not(:disabled) {
  background: rgba(13, 110, 253, 0.08);
  border-color: rgba(13, 110, 253, 0.35);
}

.csai-material-mount .csai-carousel-pager-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.csai-material-mount .csai-carousel-pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.csai-material-mount .csai-carousel-pager-btn:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
}

.csai-material-mount .csai-carousel-pager-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
  min-width: 4.5rem;
  text-align: center;
  user-select: none;
}

/* Lightbox flyers (misma idea que galeria_cobaqroo) */
#csai-flyer-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  box-sizing: border-box;
}

#csai-flyer-lightbox.is-open {
  display: flex !important;
}

#csai-flyer-lightbox .csai-lb-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#csai-flyer-lightbox .csai-lb-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

#csai-flyer-lightbox .csai-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#csai-flyer-lightbox .csai-lb-nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

#csai-flyer-lightbox .csai-lb-prev {
  left: max(8px, env(safe-area-inset-left));
}

#csai-flyer-lightbox .csai-lb-next {
  right: max(8px, env(safe-area-inset-right));
}

#csai-flyer-lightbox .csai-lb-img {
  max-width: min(96vw, 1200px);
  max-height: min(88vh, 1200px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  user-select: none;
  -webkit-user-drag: none;
}

#csai-flyer-lightbox .csai-lb-hint {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  pointer-events: none;
}

.csai-material-mount .carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--bs-primary, #0d6efd);
}

.csai-material-mount .carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: currentColor;
  opacity: 0.35;
  cursor: pointer;
  position: relative;
  transition: transform 140ms ease, opacity 140ms ease;
}

.csai-material-mount .carousel-dot.is-active {
  opacity: 0.8;
}

.csai-material-mount .carousel-dot::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.csai-material-mount .carousel-dot:hover {
  opacity: 0.6;
  transform: translateY(-1px);
}

.csai-material-mount .carousel-dot:active {
  opacity: 0.45;
  transform: scale(0.92);
}

.csai-material-mount .carousel-dot:focus-visible {
  opacity: 0.75;
  transform: translateY(-1px);
}

/* Video 9:16 — proporción real; contenido completo visible (barras laterales si hace falta) */
.csai-video-frame {
  width: 100%;
  max-width: min(100%, 28rem);
  margin: 0 auto 0.75rem;
  aspect-ratio: 9 / 16;
  background: #0a0a0a;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.csai-video-frame .csai-video-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.csai-video-frame .csai-video-el {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
}

/* Pantalla completa explícita (complementa controles nativos; útil en móvil / Safari) */
.csai-video-fs-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
  backdrop-filter: blur(6px);
}

.csai-video-fs-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: scale(1.05);
}

.csai-video-fs-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  opacity: 0.95;
}

.csai-video-frame:fullscreen,
.csai-video-frame:-webkit-full-screen {
  max-width: none;
  width: 100vw;
  height: 100vh;
  aspect-ratio: unset;
  border-radius: 0;
  background: #000;
}

.csai-video-frame:fullscreen .csai-video-inner,
.csai-video-frame:-webkit-full-screen .csai-video-inner {
  position: static;
  width: 100%;
  height: 100%;
}

.csai-video-frame:fullscreen .csai-video-el,
.csai-video-frame:-webkit-full-screen .csai-video-el {
  width: 100%;
  height: 100%;
  max-height: none;
}

@supports not (aspect-ratio: 9 / 16) {
  .csai-video-frame {
    position: relative;
    height: 0;
    padding-bottom: 177.777%;
    max-height: none;
  }
  .csai-video-frame .csai-video-inner {
    position: absolute;
    inset: 0;
  }
  .csai-video-frame .csai-video-el {
    width: 100%;
    height: 100%;
  }
}

@supports not (aspect-ratio: 1 / 1) {
  .csai-material-mount .carousel-slide {
    position: relative;
  }
  .csai-material-mount .carousel-slide::before {
    content: "";
    display: block;
    padding-top: 100%;
  }
  .csai-material-mount .carousel-slide > img {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
  }
}

@media (max-width: 360px) {
  .csai-material-mount {
    --gap: 8px;
  }
}
