/* ---------------------------------------------------------------
   Capa de fondo: centra el popup con flex (funciona en cualquier
   pantalla sin depender de position/transform).
   --------------------------------------------------------------- */
/* El JS lo pasa a display:flex al mostrarlo, y a none al cerrarlo */
#sombrapopup {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  z-index: 999999999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #00000080;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

/* ---------------------------------------------------------------
   Caja del popup (modo texto)
   --------------------------------------------------------------- */
#dbspopup {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  padding: 2em;
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  margin: auto;
}

#dbspopup img {
  max-width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------
   Caja del popup (modo imagen de fondo): se ajusta a la imagen,
   sin marco blanco ni recortes.
   --------------------------------------------------------------- */
.fondo_popup {
  max-width: 800px !important;
  width: auto !important;
  background: none !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: visible !important;
}

.fondo_popup a {
  display: block;
  line-height: 0;
  max-width: 100%;
}

/* La imagen manda: se escala entera, nunca se corta ni se deforma */
.imagen_fondo_escritorio,
.imagen_fondo_movil {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  object-fit: contain;
  margin: 0 auto;
}

/* Conmutación escritorio / movil */
.imagen_fondo_escritorio {
  display: block;
}

.imagen_fondo_movil {
  display: none;
}

/* ---------------------------------------------------------------
   Boton de cerrar
   --------------------------------------------------------------- */
.dbsclose {
  position: absolute;
  right: 10px;
  top: 5px;
  font-size: 28px;
  font-weight: bold;
  line-height: 30px;
  color: #090909;
  z-index: 2;
}

.dbsclose:hover,
.dbsclose:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

/* Sobre una imagen necesita contraste propio */
.dbsclose_fondo {
  right: 8px !important;
  top: 8px !important;
  width: 34px;
  height: 34px;
  line-height: 34px !important;
  text-align: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px #0000004d;
}

/* ---------------------------------------------------------------
   Tipografia del contenido (modo texto)
   --------------------------------------------------------------- */
#dbspopup .h1 {
  font-size: 40px;
  font-weight: bold;
  margin-bottom: 0.8em;
  line-height: 1.5em;
  text-align: center;
}

#dbspopup .h2 {
  font-size: 30px;
  font-weight: bold;
  margin-bottom: 0.8em;
  line-height: 1.5em;
  text-align: center;
}

#dbspopup .h3 {
  font-size: 20px;
  font-weight: normal;
  margin-bottom: 0.8em;
  line-height: 1.5em;
  text-align: center;
}

#dbspopup img.aligncenter {
  clear: none;
  margin-top: 0;
  margin-bottom: 0;
}

#dbspopup .aligncenter {
  margin-right: auto;
  margin-left: auto;
}

/* ---------------------------------------------------------------
   Movil: se sirve la imagen vertical y se centra en pantalla
   --------------------------------------------------------------- */
@media only screen and (max-width: 767px) {
  #sombrapopup {
    padding: 12px;
  }

  #dbspopup {
    max-width: 100%;
    max-height: calc(100vh - 24px);
    padding: 1.5em;
  }

  .fondo_popup {
    max-width: 100% !important;
  }

  .imagen_fondo_escritorio,
  .imagen_fondo_movil {
    max-height: calc(100vh - 24px);
  }

  .imagen_fondo_escritorio {
    display: none;
  }

  .imagen_fondo_movil {
    display: block;
  }

  #dbspopup .h1 {
    font-size: 28px;
  }

  #dbspopup .h2 {
    font-size: 24px;
  }

  #dbspopup .h3 {
    font-size: 18px;
  }
}
