/* ===== COMUNICADOS.CSS ===== */
/* Módulo visual para comunicados públicos — v2 */

/* ── Overlay ──────────────────────────────────────────── */
.ec-comunicado-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: ecFadeIn 0.26s ease-out both;
  overflow-y: auto;
}

.ec-comunicado-open {
  overflow: hidden;
}

/* ── Modal base ───────────────────────────────────────── */
.ec-comunicado-modal {
  position: relative;
  width: min(100%, 960px);
  border-radius: 20px;
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.06),
    0 20px 60px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  animation: ecPopIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
  margin: auto;
  /* NO max-height aquí — cada tipo lo gestiona */
}

/* ── Variante: solo texto ─────────────────────────────── */
.ec-comunicado-modal.ec-tipo-text {
  width: min(100%, 680px);
}

/* ── Variante: solo imagen ────────────────────────────── */
.ec-comunicado-modal.ec-tipo-image_only {
  width: auto;
  max-width: min(96vw, 1060px);
  background: transparent !important;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

/* ── Botón cerrar ─────────────────────────────────────── */
.ec-comunicado-close {
  position: absolute;
  /* Posición por defecto (image_text y text): esquina sup-derecha del modal */
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Botón siempre visible con buen contraste */
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.14),
    0 8px 20px rgba(0, 0, 0, 0.10);
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  /* Evita que quede bajo la imagen en image_text */
  isolation: isolate;
}

.ec-comunicado-close:hover {
  transform: scale(1.08);
  background: #ffffff;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.16),
    0 12px 28px rgba(0, 0, 0, 0.12);
}

.ec-comunicado-close:active {
  transform: scale(0.96);
}

/* En image_only el modal es transparente:
   el botón se posiciona en la esquina del OVERLAY */
.ec-comunicado-modal.ec-tipo-image_only .ec-comunicado-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ec-comunicado-modal.ec-tipo-image_only .ec-comunicado-close:hover {
  background: rgba(15, 23, 42, 0.90);
}

/* ── Grid contenedor ──────────────────────────────────── */
.ec-comunicado-grid {
  display: grid;
  width: 100%;
}

/* image_text: dos columnas equilibradas en desktop */
.ec-comunicado-grid.ec-tipo-image_text {
  grid-template-columns: 1fr 1fr;
  /* Altura mínima para que no sea demasiado chico */
  min-height: 420px;
  /* Altura máxima: que quepa en pantalla */
  max-height: min(86vh, 780px);
}

/* image_only: columna única centrada */
.ec-comunicado-grid.ec-tipo-image_only {
  grid-template-columns: 1fr;
  place-items: center;
  background: transparent;
}

/* text: columna única */
.ec-comunicado-grid.ec-tipo-text {
  grid-template-columns: 1fr;
}

/* ── Media (lado imagen) ──────────────────────────────── */
.ec-comunicado-media {
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
  /* Fondo de fallback mientras carga la imagen */
}

/* image_text: la media ocupa toda la altura del grid */
.ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media {
  /* stretch para llenar toda la altura disponible */
  align-self: stretch;
}

/* image_only: la media es transparente, solo muestra la img */
.ec-comunicado-grid.ec-tipo-image_only .ec-comunicado-media {
  background: transparent;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Imagen ───────────────────────────────────────────── */

/* image_text: cubre todo el panel izquierdo */
.ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* image_only: muestra la imagen en su tamaño natural, sin recortar */
.ec-comunicado-grid.ec-tipo-image_only .ec-comunicado-media img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(94vw, 1020px);
  max-height: min(88vh, 860px);
  object-fit: contain;
  border-radius: 16px;
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.14),
    0 24px 56px rgba(15, 23, 42, 0.30);
}

/* ── Placeholder sin imagen ───────────────────────────── */
.ec-comunicado-media-empty {
  width: 100%;
  height: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.ec-comunicado-grid.ec-tipo-image_only .ec-comunicado-media-empty {
  width: min(90vw, 820px);
  min-height: 240px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  background: linear-gradient(135deg, #f8fafc, #e5e7eb);
  height: auto;
}

/* ── Contenido (texto) ────────────────────────────────── */
.ec-comunicado-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 44px 40px 36px;
  min-width: 0; /* evita overflow en grid */
  overflow-y: auto;
}

/* image_text: el contenido tiene scroll si es muy largo */
.ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-content {
  max-height: min(86vh, 780px);
  overflow-y: auto;
  /* padding-top extra para no quedar bajo el botón X */
  padding-top: 52px;
}

/* text: centrado, con límite de ancho para legibilidad */
.ec-comunicado-grid.ec-tipo-text .ec-comunicado-content {
  max-width: 600px;
  margin-inline: auto;
  padding: 52px 40px 44px;
  text-align: left;
}

/* ── Tipografía interior ──────────────────────────────── */
.ec-comunicado-title {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  line-height: 1.12;
  font-weight: 800;
  color: inherit;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.ec-comunicado-subtitle {
  margin: 0;
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  line-height: 1.5;
  font-weight: 600;
  color: inherit;
  opacity: 0.85;
}

.ec-comunicado-body {
  margin: 0;
  font-size: clamp(0.9rem, 1.1vw, 1rem);
  line-height: 1.72;
  color: inherit;
  opacity: 0.90;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── CTA ──────────────────────────────────────────────── */
.ec-comunicado-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
}

.ec-comunicado-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.10),
    0 8px 20px rgba(0, 0, 0, 0.10);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

.ec-comunicado-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.14),
    0 14px 28px rgba(0, 0, 0, 0.14);
  text-decoration: none;
}

.ec-comunicado-btn:active {
  transform: translateY(0);
}

/* ── Animaciones ──────────────────────────────────────── */
@keyframes ecFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ecPopIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Responsive: tablet (≤ 900px) ────────────────────── */
@media (max-width: 900px) {
  .ec-comunicado-overlay {
    padding: 16px;
  }

  /* image_text: apilamos imagen encima del texto */
  .ec-comunicado-grid.ec-tipo-image_text {
    grid-template-columns: 1fr;
    max-height: none;
    min-height: auto;
  }

  /* La imagen usa aspect-ratio — se ve completa sin recorte */
  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media {
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: unset;
    max-height: 300px;
    overflow: hidden;
  }

  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media img {
    width: 100%;
    height: 100%;
    max-height: 300px;
    object-fit: cover;
  }

  /* El contenido ya no tiene max-height en tablet */
  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-content {
    max-height: none;
    overflow-y: visible;
    padding-top: 32px;
  }

  .ec-comunicado-grid.ec-tipo-text .ec-comunicado-content {
    padding: 40px 28px 32px;
    max-width: 100%;
  }

  .ec-comunicado-content {
    padding: 32px 28px 28px;
  }
}

/* ── Responsive: móvil (≤ 640px) ─────────────────────── */
@media (max-width: 640px) {
  .ec-comunicado-overlay {
    padding: 10px;
    align-items: flex-start;
    padding-top: clamp(16px, 5vh, 40px);
  }

  /* Modal general en móvil */
  .ec-comunicado-modal {
    width: 100%;
    border-radius: 18px;
  }

  /* image_only sigue sin fondo */
  .ec-comunicado-modal.ec-tipo-image_only {
    width: auto;
    max-width: 100%;
    background: transparent !important;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  /* image_text en móvil:
     sigue siendo UN SOLO card, pero con imagen arriba y texto abajo */
  .ec-comunicado-modal.ec-tipo-image_text {
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
    overflow: hidden;
    background: inherit;
    box-shadow:
      0 2px 4px rgba(15, 23, 42, 0.06),
      0 20px 60px rgba(15, 23, 42, 0.28);
  }

  .ec-comunicado-grid.ec-tipo-image_text {
    grid-template-columns: 1fr;
    gap: 0;
    max-height: none;
    overflow: visible;
    background: transparent;
  }

  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media {
    aspect-ratio: auto;
    height: auto;
    min-height: 220px;
    max-height: 52vh;
    overflow: hidden;
    background: transparent;
    display: block;
  }

  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 52vh;
    object-fit: contain;
    object-position: center;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    background: #f8fafc;
  }

  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-content {
    background: transparent;
    border-radius: 0;
    padding: 20px 18px 20px;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }

  /* image_only en móvil */
  .ec-comunicado-grid.ec-tipo-image_only .ec-comunicado-media img {
    max-width: calc(100vw - 20px);
    max-height: 80vh;
    border-radius: 12px;
  }

  /* text en móvil */
  .ec-comunicado-grid.ec-tipo-text .ec-comunicado-content {
    padding: 44px 20px 28px;
    max-width: 100%;
  }

  /* Contenido general en móvil */
  .ec-comunicado-content {
    gap: 12px;
    padding: 20px;
  }

  /* Tipografía móvil */
  .ec-comunicado-title {
    font-size: clamp(1.35rem, 6.5vw, 1.75rem);
  }

  .ec-comunicado-subtitle {
    font-size: 0.93rem;
  }

  .ec-comunicado-body {
    font-size: 0.91rem;
    line-height: 1.65;
  }

  /* CTA: botón a ancho completo en pantallas chicas */
  .ec-comunicado-actions {
    flex-direction: column;
  }

  .ec-comunicado-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Botón X en móvil */
  .ec-comunicado-close {
    width: 38px;
    height: 38px;
    top: 10px;
    right: 10px;
  }

  .ec-comunicado-modal.ec-tipo-image_only .ec-comunicado-close {
    top: 12px;
    right: 12px;
  }

  /* En image_text NO lo saques del card */
  .ec-comunicado-modal.ec-tipo-image_text .ec-comunicado-close {
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #1e293b;
    box-shadow:
      0 2px 6px rgba(0, 0, 0, 0.14),
      0 8px 20px rgba(0, 0, 0, 0.10);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ── Pantallas muy pequeñas (≤ 380px) ────────────────── */
@media (max-width: 380px) {
  .ec-comunicado-overlay {
    padding: 8px;
    padding-top: 12px;
  }

  .ec-comunicado-modal {
    border-radius: 14px;
  }

  .ec-comunicado-grid.ec-tipo-image_text .ec-comunicado-media {
    aspect-ratio: 3 / 2;
    max-height: 52vw;
  }

  .ec-comunicado-content {
    padding: 16px;
  }

  .ec-comunicado-grid.ec-tipo-text .ec-comunicado-content {
    padding: 42px 16px 24px;
  }

  .ec-comunicado-title {
    font-size: clamp(1.2rem, 6vw, 1.5rem);
  }
}

/* ── Sin movimiento (accesibilidad) ──────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ec-comunicado-overlay,
  .ec-comunicado-modal,
  .ec-comunicado-close,
  .ec-comunicado-btn {
    animation: none !important;
    transition: none !important;
  }
}

