/* =========================================================
   LA VENTANA DEL ANUNCIO · la pieza común (anuncio.js)
   ---------------------------------------------------------
   ESTE ARCHIVO ES IGUAL EN TODAS LAS PLANTILLAS: si se cambia en
   una, se copia tal cual a las demás.

   Aquí va cómo se coloca y se porta la ventana. Su ASPECTO lo pone
   cada plantilla en su estilos.css (apartado «La ventana del
   anuncio»), dando valor a estas variables con SUS colores y SUS
   letras. Así, si el local cambia el color de fondo de la página,
   la ventana cambia con él:

     --anuncio-fondo          fondo de la tarjeta
     --anuncio-texto          letra del mensaje
     --anuncio-suave          letra de la descripción
     --anuncio-acento         la línea pequeña de arriba y la rayita
     --anuncio-borde          borde de la tarjeta
     --anuncio-radio          redondeo de la tarjeta
     --anuncio-rotulo         tipo de letra del mensaje principal
     --anuncio-letra          tipo de letra del resto
     --anuncio-boton-fondo    botón «Cerrar»: fondo,
     --anuncio-boton-texto      letra,
     --anuncio-boton-borde      borde
     --anuncio-boton-radio      y redondeo
     --anuncio-velo           el oscurecido de detrás

   Se carga ANTES que estilos.css, para que lo que diga la plantilla
   mande sobre lo de aquí.
   ========================================================= */

/* Mientras está abierta, la carta de detrás no se mueve. */
body.con-anuncio { overflow: hidden; }

.anuncio {
  width: min(100% - 32px, 420px);
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--anuncio-borde, transparent);
  border-radius: var(--anuncio-radio, 20px);
  background: var(--anuncio-fondo, #FFFFFF);
  color: var(--anuncio-texto, #1B1B1B);
  font-family: var(--anuncio-letra, system-ui, -apple-system, sans-serif);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
  overflow: auto;
  overscroll-behavior: contain;
  animation: anuncio-entra .42s cubic-bezier(.2, .8, .2, 1) both;
}

/* El velo de detrás. Lleva un color de reserva escrito: algunos móviles
   no le pasan las variables al velo. */
.anuncio::backdrop {
  background: var(--anuncio-velo, rgba(10, 8, 6, .62));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: anuncio-velo .3s ease both;
}

.anuncio__tarjeta { position: relative; }
.anuncio__tarjeta:focus { outline: none; }

.anuncio__foto {
  margin: 0;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: rgba(0, 0, 0, .06);
}
.anuncio__foto img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.anuncio__cuerpo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 26px;
  text-align: center;
}

.anuncio__titulo {
  margin: 0 0 12px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--anuncio-acento, currentColor);
}

.anuncio__mensaje {
  margin: 0;
  font-family: var(--anuncio-rotulo, inherit);
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1.1;
  color: var(--anuncio-texto, inherit);
  overflow-wrap: anywhere;
}

.anuncio__regla {
  display: block;
  width: 26px;
  height: 2px;
  margin: 16px auto;
  background: var(--anuncio-acento, currentColor);
}

.anuncio__descripcion {
  margin: 0;
  max-width: 36ch;
  font-size: .94rem;
  line-height: 1.6;
  color: var(--anuncio-suave, inherit);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.anuncio__cerrar {
  width: 100%;
  min-height: 48px;
  margin-top: 24px;
  padding: 12px 22px;
  border: 1px solid var(--anuncio-boton-borde, transparent);
  border-radius: var(--anuncio-boton-radio, 999px);
  background: var(--anuncio-boton-fondo, #1B1B1B);
  color: var(--anuncio-boton-texto, #FFFFFF);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease, transform .12s ease;
}
.anuncio__cerrar:hover { filter: brightness(1.08); }
.anuncio__cerrar:active { transform: scale(.98); }

@keyframes anuncio-entra {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes anuncio-velo {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .anuncio,
  .anuncio::backdrop { animation: none; }
}

@media (min-width: 760px) {
  .anuncio { width: min(100% - 48px, 460px); }
  .anuncio__cuerpo { padding-left: 34px; padding-right: 34px; }
}
