/* ============================================================
   Modales legales (Privacidad / Términos) — CERO JavaScript.
   Porteo de Modal.module.css de la v1, con clases BEM a mano.

   Mecanismo: el modal está oculto por defecto (display:none) y se
   muestra cuando su id es el :target de la URL (link del footer).
   Sin JS funciona igual. Ver ADR-0011.
   ============================================================ */

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none; /* oculto hasta que el link del footer lo "apunte" (:target) */
  place-items: center;
  padding: var(--space-6);
}

/* El modal apuntado por la URL se muestra. */
.legal-modal:target {
  display: grid;
}

/* Bloquea el scroll del fondo mientras hay un modal abierto (progressive:
   si :has() no está soportado, simplemente no se bloquea; no se rompe nada). */
html:has(.legal-modal:target) {
  overflow: hidden;
}

/* Fondo oscuro: es un link que cubre todo → click afuera cierra. */
.legal-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 23, 0.55);
  animation: legal-fade 180ms ease-out;
}

.legal-modal__dialog {
  position: relative; /* por encima del overlay */
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  box-shadow: var(--shadow-lg);
  animation: legal-pop 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.legal-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.legal-modal__title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  color: var(--color-ink);
}

.legal-modal__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  text-decoration: none;
  transition:
    background var(--transition),
    color var(--transition);
}

.legal-modal__close:hover {
  background: var(--color-neutral-200);
  color: var(--color-ink);
}

/* Cuerpo: es texto enriquecido (richtext) del Setting → estilamos por descendencia
   los <p> y <h3> que genera el editor. */
.legal-modal__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text-muted);
}

.legal-modal__body h3 {
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body-lg);
  color: var(--color-ink);
}

.legal-modal__body a {
  color: var(--color-primary);
  text-decoration: underline;
}

.legal-modal__body ul,
.legal-modal__body ol {
  padding-left: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

@keyframes legal-fade {
  from {
    opacity: 0;
  }
}

@keyframes legal-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .legal-modal__overlay,
  .legal-modal__dialog {
    animation: none;
  }
}

/* Pantallas de poco alto (notebooks): compactamos el modal para que el texto
   largo no empuje los bordes. */
@media (max-height: 860px) {
  .legal-modal__dialog {
    max-height: 92vh;
    padding: var(--space-6);
  }
  .legal-modal__head {
    margin-bottom: var(--space-4);
  }
  .legal-modal__title {
    font-size: var(--fs-h4);
  }
  .legal-modal__body {
    gap: var(--space-3);
  }
}
