:root {
  --noche: #0c0a12;
  --oro: #c9a45c;
  --oro-suave: rgba(201, 164, 92, 0.65);
  --papel: #f4ecdb;
  --papel-oscuro: #ddcfb2;
  --tinta: #2a2420;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --ancho: min(84vw, 380px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--noche);
  color: #efe6d2;
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse 80% 55% at 50% 42%, rgba(201, 164, 92, 0.13), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 120%, #1b1528, transparent 60%),
    var(--noche);
  background-attachment: fixed;
}

.escena {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 6vh, 48px);
  padding: max(32px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
  text-align: center;
}

.escena[data-estado='cargando'] {
  opacity: 0;
}

.escena {
  transition: opacity 0.6s ease;
}

/* ------------------------------------------------ cabecera */

.antetitulo {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--oro);
}

.evento {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

/* Durante la apertura la solapa sube por encima del sobre: el título se aparta un momento. */
.cabecera {
  transition: opacity 0.4s ease;
}

.escena[data-estado='abriendo'] .cabecera {
  opacity: 0;
}

/* ------------------------------------------------ sobre */

.sobre {
  position: relative;
  width: var(--ancho);
  aspect-ratio: 1.56;
  perspective: 1400px;
  transition:
    opacity 0.7s ease,
    transform 0.7s ease;
  animation: flotar 6s ease-in-out infinite;
}

@keyframes flotar {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.sobre > div {
  position: absolute;
  border-radius: 6px;
}

.sobre__fondo {
  inset: 0;
  z-index: 1;
  background: linear-gradient(170deg, #d9cbad, #c9b893);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}

.sobre__papel {
  z-index: 2;
  left: 6%;
  right: 6%;
  top: 6%;
  height: 88%;
  background:
    repeating-linear-gradient(180deg, transparent 0 17px, rgba(60, 40, 20, 0.07) 17px 18px) 0 30% / 100% 50% no-repeat,
    var(--papel);
  transition: transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sobre__frente {
  inset: 0;
  z-index: 3;
  background: linear-gradient(175deg, #efe5cf, #e2d4b7);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}

.sobre__frente::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(120, 95, 50, 0.1), rgba(120, 95, 50, 0.02));
  clip-path: polygon(0 100%, 50% 46%, 100% 100%);
}

.sobre__solapa {
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(180deg, #e8dcc2, #d5c4a1);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform 0.8s cubic-bezier(0.5, 0, 0.3, 1);
}

.sobre__lacre {
  z-index: 5;
  left: 50%;
  top: 60%;
  width: 21%;
  aspect-ratio: 1;
  border-radius: 50% !important;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 34% 30%, #cf3b42, #8f1820 55%, #6a1016 100%);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.sobre__lacre::before {
  content: '';
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 190, 0.28);
}

.sobre__lacre span {
  font-size: calc(var(--ancho) * 0.085);
  font-style: italic;
  color: rgba(255, 222, 205, 0.78);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.35);
}

/* Pasos de la apertura (las clases las añade sobre.js) */
.sobre.paso-1 {
  animation: none;
}

.sobre.paso-1 .sobre__lacre {
  animation: romperLacre 0.55s ease-in forwards;
}

@keyframes romperLacre {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  35% {
    transform: translate(-50%, -50%) scale(1.12) rotate(-5deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(0.5) rotate(12deg);
    opacity: 0;
  }
}

.sobre.paso-2 .sobre__solapa {
  transform: rotateX(180deg);
}

.sobre.paso-2b .sobre__solapa {
  z-index: 1;
}

.sobre.paso-3 .sobre__papel {
  transform: translateY(-58%);
}

.escena[data-estado='abierto'] .sobre,
.escena[data-estado='abierto'] .info {
  display: none;
}

/* ------------------------------------------------ información */

.info {
  max-width: 30rem;
  transition: opacity 0.5s ease;
}

.escena[data-estado='abriendo'] .info {
  opacity: 0;
}

.info__sello {
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--oro);
}

.info__texto {
  margin: 0;
  font-style: italic;
  color: rgba(239, 230, 210, 0.7);
}

/* ------------------------------------------------ carta revelada */

.carta {
  width: min(90vw, 440px);
  padding: clamp(28px, 7vw, 40px) clamp(22px, 6vw, 36px) 26px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.6), transparent 70%),
    var(--papel);
  color: var(--tinta);
  border-radius: 4px;
  box-shadow:
    0 40px 80px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.4) inset;
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transition:
    opacity 0.9s ease,
    transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.carta--visible {
  opacity: 1;
  transform: none;
}

.carta__intro {
  margin: 0;
  font-size: 1.06rem;
  font-style: italic;
  line-height: 1.5;
  text-wrap: balance;
}

.carta__prediccion {
  margin: 26px 0 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.carta__prediccion .naipe {
  width: min(52vw, 210px);
}

.carta__nombre {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.carta__texto {
  margin: 0;
  font-size: clamp(2rem, 10vw, 3.1rem);
  line-height: 1.1;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.carta__firma {
  margin: 0;
  font-size: 1.15rem;
  font-style: italic;
}

.carta__pie {
  margin: 22px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(42, 36, 32, 0.15);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(42, 36, 32, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .sobre {
    animation: none;
  }
  .carta {
    transition: opacity 0.3s ease;
    transform: none;
  }
}
