/* ==========================================================================
   Popup — se dibuja con js/popup.js (elemento <dialog> nativo)
   Medidas del original: fondo azul marino que tapa la página, caja de ~810×572,
   mitad izquierda rosa claro con el formulario y foto a la derecha,
   botón "Cerrar" negro montado sobre el borde inferior.
   ========================================================================== */

html.popup-open { overflow: hidden; }

.popup {
  --popup-overlay: #191761;
  --popup-bg: #fff5f0;
  --popup-text: #222;

  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: var(--popup-overlay);
  color: var(--popup-text);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.popup[open] {
  display: grid;
  place-items: center;
  animation: popup-fade .35s ease;
}
.popup::backdrop { background: transparent; }

@keyframes popup-fade { from { opacity: 0; } }
@keyframes popup-rise { from { opacity: 0; transform: translateY(16px); } }

/* "X" en la esquina superior derecha de la pantalla */
.popup__x {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 2;
  width: 44px;
  height: 44px;
  color: #fff;
}
.popup__x::before,
.popup__x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}
.popup__x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.popup__x:hover { opacity: .75; }

/* ---------- Caja ---------- */

.popup__panel {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(810px, 100%);
  min-height: 572px;
  background: var(--popup-bg);
  animation: popup-rise .45s ease;
}
.popup__panel:focus { outline: none; }
.popup__panel--img-left { grid-template-columns: 1fr 1fr; }
.popup__panel--img-left .popup__media { order: -1; }
.popup__panel--no-img { grid-template-columns: 1fr; width: min(520px, 100%); min-height: 0; }

.popup__content {
  display: flex;
  flex-direction: column;
  padding: 52px 58px 80px;
}

.popup__title {
  margin: 0 0 30px;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.02em;
  white-space: pre-line;
}

.popup__text {
  margin: 0 0 40px;
  font-size: 16px;
  font-weight: 300;
  line-height: 1.5;
}

/* ---------- Formulario (estilo del original: línea inferior y botón de borde) ---------- */

.popup__form { display: flex; flex-direction: column; }

.popup__label {
  margin: 0 0 6px 4px;
  font-size: 15px;
  font-weight: 300;
}

.popup__input {
  height: 42px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
}
.popup__input::placeholder { color: #6b6b6b; font-style: italic; }
.popup__input:focus-visible { outline: none; border-bottom-width: 2px; }
.popup__input[aria-invalid="true"] { border-bottom: 2px solid #d72d2d; }

.popup__consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  cursor: pointer;
}
.popup__check { flex: none; width: 16px; height: 16px; margin: 1px 0 0; accent-color: #000; }

.popup__submit {
  height: 44px;
  margin-top: 18px;
  border: 1px solid currentColor;
  background: transparent;
  font-size: 16px;
  font-weight: 400;
  transition: background-color .3s ease, color .3s ease;
}
.popup__submit:hover { background: #000; color: #fff; }
.popup__submit:disabled { opacity: .6; cursor: progress; }

.popup__status {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 14px;
}
.popup__status.is-error { color: #b3261e; font-weight: 700; }
.popup__status.is-success { font-weight: 700; }
.popup__status.is-success::before { content: "✓ "; }

.popup__buttons { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Imagen ---------- */

.popup__media { position: relative; overflow: hidden; background: #2b2b2b; }
.popup__media picture { display: contents; }
.popup__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal, 50% 50%);
}

/* Botón "Cerrar" negro montado sobre el borde inferior, en el centro de la caja */
.popup__close {
  position: absolute;
  bottom: -19px;
  left: 50%;
  z-index: 1;
  min-width: 140px;
  height: 38px;
  padding: 0 24px;
  border: 1px solid #fff;
  background: #000;
  color: #fff;
  font-size: 16px;
  transform: translateX(-50%);
  transition: background-color .3s ease, color .3s ease;
}
.popup__close:hover { background: #fff; color: #000; }

.popup button:focus-visible,
.popup a:focus-visible { outline: 2px solid #751fff; outline-offset: 2px; }

/* ==========================================================================
   Móvil: foto arriba (más baja) y formulario debajo
   ========================================================================== */

@media (max-width: 700px) {
  .popup { padding: 64px 16px 40px; place-items: start center; }
  .popup__x { top: 10px; right: 10px; }
  .popup__x::before,
  .popup__x::after { width: 28px; }

  .popup__panel,
  .popup__panel--img-left {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .popup__media,
  .popup__panel--img-left .popup__media { order: -1; aspect-ratio: 16 / 9; }

  .popup__content { padding: 28px 24px 48px; }
  .popup__title { font-size: 30px; margin-bottom: 16px; }
  .popup__text { margin-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .popup[open],
  .popup__panel { animation: none; }
}
