* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --fondo-exterior: #1f1f1f;
  --fondo-pagina: #f7f2e9;
  --sombra: 0 0 28px rgba(0, 0, 0, 0.22);
}

html {
  scroll-behavior: smooth;
  background: var(--fondo-exterior);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--fondo-exterior);
}

.revista {
  width: 100%;
  max-width: 853px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--fondo-pagina);
  box-shadow: var(--sombra);
}

.pagina {
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: 0;
}

.pagina img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: 0;
}

.saltar {
  position: fixed;
  top: -70px;
  left: 16px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: #5d431d;
  text-decoration: none;
  font-family: Georgia, serif;
  transition: top 0.2s ease;
}

.saltar:focus {
  top: 16px;
}

.volver-arriba {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  color: #fff;
  background: rgba(74, 52, 21, 0.82);
  text-decoration: none;
  font: 700 24px/1 Georgia, serif;
  backdrop-filter: blur(5px);
}

@media (max-width: 540px) {
  .volver-arriba {
    right: 10px;
    bottom: 10px;
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* =========================================================
   APERTURA ANIMADA DEL SOBRE
   ========================================================= */

body.bloqueado {
  overflow: hidden;
}

.intro-sobre {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: grid;
  place-items: center;

  overflow: hidden;

  background: #1f1f1f;

  transition:
    background-color 1.25s ease,
    visibility 0s linear 1.7s;
}

.intro-sobre[hidden] {
  display: none !important;
}

.sobre-panel {
  position: relative;

  width: min(100vw, 853px);
  height: 100dvh;

  overflow: hidden;

  background: #f7f2e9;
}

/* Las dos imágenes forman una sola portada */
.sobre-mitad {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  object-fit: contain;
  object-position: center;

  user-select: none;
  pointer-events: none;

  transition:
    transform 1.55s cubic-bezier(0.72, 0, 0.2, 1),
    opacity 1.25s ease,
    filter 1.25s ease;
}

/* Solo muestra la mitad superior */
.sobre-arriba {
  clip-path: inset(0 0 50% 0);
}

/* Solo muestra la mitad inferior */
.sobre-abajo {
  clip-path: inset(50% 0 0 0);
}

/* Botón de apertura */
.abrir-invitacion {
  position: absolute;
  left: 50%;
  top: 57%;
  z-index: 5;

  transform: translate(-50%, -50%);

  min-width: 170px;
  min-height: 48px;

  padding: 12px 22px;

  border: 1px solid rgba(151, 111, 39, 0.85);
  border-radius: 999px;

  color: #721414;
  background: rgba(255, 250, 241, 0.94);

  box-shadow:
    0 8px 30px rgba(61, 20, 10, 0.3),
    0 0 0 0 rgba(132, 19, 19, 0.35);

  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.02em;

  cursor: pointer;

  animation: pulsoAbrir 2s ease-in-out infinite;

  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    box-shadow 0.35s ease;
}

.abrir-invitacion:hover {
  transform: translate(-50%, -50%) scale(1.04);

  box-shadow:
    0 10px 34px rgba(61, 20, 10, 0.38),
    0 0 0 10px rgba(132, 19, 19, 0.08);
}

.abrir-invitacion:focus-visible {
  outline: 3px solid #b78b37;
  outline-offset: 4px;
}

/* Apertura: ambas mitades se separan */
.intro-sobre.abriendo {
  background-color: transparent;
  pointer-events: none;
}

.intro-sobre.abriendo .sobre-arriba {
  transform: translateY(-110%) scale(1.04);
  opacity: 0;
  filter: blur(4px);
}

.intro-sobre.abriendo .sobre-abajo {
  transform: translateY(110%) scale(1.04);
  opacity: 0;
  filter: blur(4px);
}

.intro-sobre.abriendo .abrir-invitacion {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.72);
  animation: none;
}

/* Botón para controlar la música */
.control-musica {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 100;

  display: grid;
  place-items: center;

  width: 46px;
  height: 46px;

  padding: 0;

  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;

  color: #fff;
  background: rgba(83, 54, 22, 0.86);

  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);

  font-size: 21px;

  cursor: pointer;
  backdrop-filter: blur(6px);
}

.control-musica[hidden] {
  display: none !important;
}

.control-musica:hover {
  transform: scale(1.05);
}

@keyframes pulsoAbrir {
  0%,
  100% {
    box-shadow:
      0 8px 30px rgba(61, 20, 10, 0.3),
      0 0 0 0 rgba(132, 19, 19, 0.25);
  }

  50% {
    box-shadow:
      0 10px 35px rgba(61, 20, 10, 0.38),
      0 0 0 13px rgba(132, 19, 19, 0);
  }
}

@media (max-width: 540px) {
  .abrir-invitacion {
    top: 57%;
    min-width: 155px;
    min-height: 44px;

    padding: 10px 18px;

    font-size: 19px;
  }

  .control-musica {
    left: 10px;
    bottom: 10px;

    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .abrir-invitacion {
    animation: none;
  }

  .sobre-mitad,
  .intro-sobre,
  .abrir-invitacion {
    transition-duration: 0.2s;
  }
}
