/* ==========================================================================
   ÁLBUM DIGITAL — EMStudioDigital
   ==========================================================================
   Para cambiar la paleta de colores, edita únicamente las variables de
   este bloque ":root". No necesitas tocar nada más abajo.
   ========================================================================== */

:root{
  /* Encuadernación / cubierta */
  --cover: #2E1F17;
  --cover-light: #4A3527;

  /* Papel de las hojas interiores */
  --page: #FBF6EC;
  --page-shadow: #E9DFC8;

  /* Acentos */
  --gold: #B8925A;
  --gold-light: #E4C795;
  --accent2: #6B2737;

  /* Texto */
  --ink: #2B2622;
  --ink-soft: #6b5f52;

  --font-script: 'Alex Brush', cursive;
  --font-serif: 'Cormorant Garamond', serif;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  font-family: var(--font-serif);
  color: var(--ink);
  overflow: hidden;
}

/* Escenario: mesa oscura y difusa donde "reposa" el álbum */
.scene{
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background:
    radial-gradient(ellipse at center, #3a2f28 0%, #1a1512 72%, #0d0a08 100%);
  position: relative;
  padding: 20px;
}

.album-wrap{
  position: relative;
}

/* Cinta/marcador colgante — detalle de firma del diseño */
.ribbon{
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 92px;
  background: linear-gradient(180deg, var(--accent2), #4d1c26 85%);
  clip-path: polygon(0 0, 100% 0, 100% 82%, 50% 100%, 0 82%);
  z-index: 500;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  pointer-events: none;
}

.book{
  position: relative;
  width: min(78vw, 420px);
  height: min(78vw, 420px);
  aspect-ratio: 3 / 4;
  height: auto;
  box-shadow:
    0 30px 60px rgba(0,0,0,.55),
    0 4px 0 var(--cover-light);
  border-radius: 4px 10px 10px 4px;
  background: var(--cover);
  overflow: hidden;
}

/* Lomo del álbum, a la izquierda */
.book::before{
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 14px;
  background: linear-gradient(90deg, #1c130d, var(--cover-light) 60%, var(--cover));
  z-index: 600;
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

.page{
  position: absolute;
  inset: 0;
  left: 14px;
  background: var(--page);
  border-radius: 0 8px 8px 0;
  box-shadow: inset -1px 0 0 rgba(0,0,0,.06), 6px 6px 18px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7% 8%;
  text-align: center;
  cursor: pointer;
  opacity: 1;
  /* Solo se anima la opacidad (lo más barato que existe para la GPU).
     Nada de desplazamiento, escala ni giro: cualquiera de esos obliga
     al navegador a recalcular geometría en cada cuadro, y en iOS eso
     es justo lo que se percibe como "trabado". */
  transition: opacity .45s linear;
  transform: translateZ(0);          /* fuerza capa propia en la GPU */
  will-change: opacity;
}

/* Desvanecido puro — sin ningún giro 3D, así se evita por completo el
   hueco de renderizado que Safari/iOS tiene en el volteo 3D al cruzar
   los 90°, y sin transformaciones que encarezcan cada cuadro. */
.page.pre-enter{ opacity: 0; }
.page.leave{ opacity: 0; pointer-events: none; }

/* Sutil viñeta de "papel" en cada hoja, para dar profundidad.
   Se dejó UN solo degradado (antes eran dos superpuestos): dos capas
   de degradado sobre cada página encarecen el pintado en celular sin
   aportar una diferencia visual real. */
.page::after{
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 100%, var(--page-shadow), transparent 60%);
  opacity: .6;
  pointer-events: none;
  border-radius: inherit;
}

/* ---------- CUBIERTA (portada) ---------- */
.page.cover{
  background: linear-gradient(160deg, var(--cover) 0%, var(--cover-light) 100%);
  color: var(--gold-light);
}
.page.cover::after{ display:none; }

.seal{
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 60%, #8a6a3d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-script);
  font-size: 30px;
  color: #3a2712;
  box-shadow: 0 4px 14px rgba(0,0,0,.4), inset 0 0 0 2px rgba(255,255,255,.25);
  margin-bottom: 18px;
}

.cover-eyebrow{
  letter-spacing: .35em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
  margin: 0 0 10px;
}

.cover-names{
  font-family: var(--font-script);
  font-size: clamp(30px, 8vw, 42px);
  margin: 0;
  line-height: 1.15;
  color: #fdf3df;
}

.cover-rule{
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 16px 0;
}

.cover-date{
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-serif);
}
.cover-date .day{ font-size: 34px; font-weight: 600; }
.cover-date .month-year{
  text-align: left;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1.5;
}

.cover-tag{
  margin-top: 20px;
  font-size: 12px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: .85;
}

.cover-location{
  margin-top: 8px;
  font-size: 11.5px;
  letter-spacing: .05em;
  font-style: italic;
  color: var(--gold-light);
  opacity: .75;
}

.cover-open-hint{
  position: absolute;
  bottom: 6%;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .75;
}

/* ---------- PÁGINAS DE FOTOS ---------- */
.photo-frame{
  position: relative;
  width: 100%;
  flex: 1;
  background: #fff;
  padding: 6% 6% 0 6%;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.photo-frame img{
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
}

/* Esquineras estilo "portafotos de álbum" */
.photo-frame .corner{
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
  z-index: 5;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.3));
}
.corner.tl{ top: -1px; left: -1px; border-width: 16px 16px 0 0; border-color: var(--gold) transparent transparent transparent; }
.corner.tr{ top: -1px; right: -1px; border-width: 16px 0 0 16px; border-color: transparent transparent transparent var(--gold); transform: rotate(0deg); }
.corner.bl{ bottom: -1px; left: -1px; border-width: 0 0 16px 16px; border-color: transparent transparent var(--gold) transparent; }
.corner.br{ bottom: -1px; right: -1px; border-width: 0 16px 16px 0; border-color: transparent var(--gold) transparent transparent; }

/* Botón para descargar la foto */
.download-btn{
  position: absolute;
  top: 9px;
  right: 9px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(43,38,34,.55);
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  text-decoration: none;
  /* Sin backdrop-filter (desenfoque): en iOS obliga a recomponer el
     fondo en cada cuadro y encarece mucho cualquier animación. */
  transition: background .18s, transform .15s;
}
.download-btn svg{ width: 15px; height: 15px; }
.download-btn:hover{ background: rgba(43,38,34,.8); transform: scale(1.08); }
.photo-frame.img-missing .download-btn{ display: none; }

.photo-caption{
  padding: 4% 4% 2%;
  font-style: italic;
  font-size: clamp(13px, 3.4vw, 16px);
  color: var(--ink);
  line-height: 1.35;
}
.photo-date{
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 2px;
}

.page-index{
  position: absolute;
  bottom: 3%;
  font-size: 10px;
  color: var(--ink-soft);
  letter-spacing: .1em;
}

/* Placeholder cuando falta la foto: guía visual para el cliente */
.photo-frame.img-missing{
  background: repeating-linear-gradient(135deg, #f4ecdb, #f4ecdb 10px, #eee2c8 10px, #eee2c8 20px);
  flex-direction: column;
  gap: 8px;
  color: #8a7350;
}
.photo-frame.img-missing img{ display: none; }
.img-missing-icon{ font-size: 28px; }
.img-missing-text{
  font-size: 12px;
  padding: 0 10%;
  font-family: var(--font-serif);
  line-height: 1.4;
}
.img-missing-file{
  font-size: 10.5px;
  background: rgba(255,255,255,.6);
  padding: 3px 8px;
  border-radius: 20px;
  font-family: monospace;
  color: #6b5a3b;
}

/* ---------- CONTRAPORTADA (cierre) ---------- */
.page.closing{
  background: linear-gradient(160deg, var(--cover-light) 0%, var(--cover) 100%);
  color: var(--gold-light);
}
.page.closing::after{ display:none; }
.closing-message{
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(15px, 4vw, 18px);
  max-width: 85%;
  line-height: 1.5;
  color: #fdf3df;
}
.closing-names{
  font-family: var(--font-script);
  font-size: clamp(24px, 6vw, 30px);
  margin-top: 18px;
  color: var(--gold-light);
}

/* ---------- CONTROLES ---------- */
.controls{
  display: flex;
  align-items: center;
  gap: 22px;
}
.nav-arrow{
  background: none;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
}
.nav-arrow:hover:not(:disabled){ background: rgba(184,146,90,.18); transform: scale(1.05); }
.nav-arrow:disabled{ opacity: .25; cursor: default; }

.indicator{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--gold-light);
  font-size: 12px;
  letter-spacing: .1em;
  min-width: 110px;
}
.progress-track{
  width: 110px;
  height: 2px;
  background: rgba(184,146,90,.25);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill{
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width .4s ease;
}

.hint{
  color: var(--gold-light);
  opacity: .6;
  font-size: 11.5px;
  letter-spacing: .06em;
  font-style: italic;
  margin: 0;
}

/* Botón de música de fondo (opcional) */
.music-toggle{
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  z-index: 700;
  transition: background .2s, transform .15s;
}
.music-toggle:hover{ background: rgba(0,0,0,.4); transform: scale(1.05); }
.music-toggle .bar{
  width: 3px;
  height: 7px;
  border-radius: 2px;
  background: var(--gold-light);
  opacity: .7;
  transition: height .2s;
}
.music-toggle.is-playing .bar{ animation: eq 0.9s ease-in-out infinite; opacity: 1; }
.music-toggle.is-playing .bar:nth-child(1){ animation-delay: 0s; }
.music-toggle.is-playing .bar:nth-child(2){ animation-delay: .2s; }
.music-toggle.is-playing .bar:nth-child(3){ animation-delay: .4s; }

@keyframes eq{
  0%, 100% { height: 6px; }
  50% { height: 15px; }
}

@media (max-width: 480px){
  .book{ width: 84vw; }
  .controls{ gap: 16px; }
}

@media (prefers-reduced-motion: reduce){
  .page{ transition-duration: .01ms; }
}

/* ---------- PANTALLA DE CARGA ---------- */
/* Cubre todo mientras se precargan y decodifican las fotos, para que
   al empezar a interactuar el pase de página se sienta tan fluido
   como en computadora — sin competir con descargas/decodificación
   de imágenes a medio camino. Se oculta sola cuando todo está listo. */
.loading-screen{
  position: absolute;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, #3a2f28 0%, #1a1512 72%, #0d0a08 100%);
  transition: opacity .5s ease;
}
.loading-screen.is-hidden{
  opacity: 0;
  pointer-events: none;
}
.loading-mark{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(228,199,149,.25);
  border-top-color: var(--gold);
  animation: loading-spin 0.9s linear infinite;
}
@keyframes loading-spin{ to{ transform: rotate(360deg); } }
.loading-text{
  color: var(--gold-light);
  font-size: 12px;
  letter-spacing: .1em;
  font-style: italic;
  opacity: .85;
  margin: 0;
}
.loading-track{
  width: 140px;
  height: 2px;
  background: rgba(184,146,90,.25);
  border-radius: 2px;
  overflow: hidden;
}
.loading-fill{
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width .3s ease;
}

/* ==========================================================================
   VISTA DE GALERIA (indice) — permite saltar directo a cualquier foto
   sin tener que pasar hoja por hoja.
   ========================================================================== */
.grid-toggle{
  position: absolute;
  top: 18px;
  left: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 700;
  padding: 0;
  transition: background .2s, transform .15s;
}
.grid-toggle:hover{ background: rgba(0,0,0,.45); transform: scale(1.05); }
.grid-toggle .g{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5px;
}
.grid-toggle .g span{
  width: 5px; height: 5px;
  background: var(--gold);
  border-radius: 1px;
}

.gallery-view{
  position: absolute;
  inset: 0;
  z-index: 800;
  background: var(--page);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 60px 18px 30px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.gallery-view.is-open{ opacity: 1; visibility: visible; }

.gallery-head{
  text-align: center;
  margin-bottom: 20px;
}
.gallery-title{
  font-family: var(--font-script);
  font-size: 26px;
  color: var(--ink);
  margin: 0;
}
.gallery-sub{
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 4px 0 0;
}
.gallery-close{
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.gallery-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}
@media (max-width: 380px){
  .gallery-grid{ grid-template-columns: repeat(2, 1fr); }
}
.gallery-item{
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--gold);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}
.gallery-item img{
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item .num{
  position: absolute;
  bottom: 3px; right: 5px;
  font-size: 9px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  letter-spacing: .08em;
}
.gallery-item.is-empty{
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(135deg, #f4ecdb, #f4ecdb 8px, #eee2c8 8px, #eee2c8 16px);
  color: var(--gold);
  font-size: 20px;
}

/* ==========================================================================
   HOJA PARA SUBIR FOTO (muro de invitados)
   ========================================================================== */
.upload-slot{
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 1px dashed var(--gold);
  background: rgba(255,255,255,.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8%;
}
.upload-icon{
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: 20px;
}
.upload-legend{
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.45;
  margin: 0;
}
.upload-btn{
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 11.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: 2px;
  cursor: pointer;
}
.upload-note{
  font-size: 9.5px;
  color: var(--ink-soft);
  letter-spacing: .05em;
  margin: 0;
}
.upload-status{
  font-size: 11px;
  font-style: italic;
  color: var(--gold);
  margin: 0;
  min-height: 14px;
}

/* Firma bajo una foto subida por un invitado */
.guest-signature{
  padding: 3% 4% 0;
  font-family: var(--font-script);
  font-size: clamp(15px, 4vw, 19px);
  color: var(--ink);
  line-height: 1.2;
}
.guest-message{
  font-size: 11.5px;
  font-style: italic;
  color: var(--ink-soft);
  padding: 0 6%;
  line-height: 1.4;
  margin-top: 2px;
}

/* Formulario emergente para subir */
.upload-modal{
  position: absolute;
  inset: 0;
  z-index: 950;
  background: rgba(25,18,12,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s;
}
.upload-modal.is-open{ opacity: 1; visibility: visible; }
.upload-card{
  background: var(--page);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 22px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.upload-card h3{
  font-family: var(--font-script);
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--ink);
  font-weight: 400;
}
.upload-card p.hintline{
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 16px;
  font-style: italic;
}
.upload-preview{
  width: 100%;
  aspect-ratio: 4/3;
  border: 1px dashed var(--gold);
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 11px;
  margin-bottom: 12px;
  overflow: hidden;
  cursor: pointer;
}
.upload-preview img{ width: 100%; height: 100%; object-fit: cover; }
.upload-card input[type="text"],
.upload-card textarea{
  width: 100%;
  border: 1px solid var(--gold);
  background: rgba(255,255,255,.7);
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink);
  padding: 9px 10px;
  margin-bottom: 9px;
  border-radius: 2px;
  resize: none;
}
.upload-card textarea{ height: 58px; }
.upload-actions{ display: flex; gap: 8px; margin-top: 4px; }
.upload-actions button{
  flex: 1;
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 10px;
  border-radius: 2px;
  cursor: pointer;
}
.btn-cancel{ border: 1px solid var(--gold); background: transparent; color: var(--ink); }
.btn-send{ border: 1px solid var(--gold); background: var(--gold); color: #fff; }
.btn-send:disabled{ opacity: .5; cursor: default; }

/* Boton para quitar una foto de invitado — solo visible en modo
   administrador (abriendo el album con ?admin=CLAVE en la direccion) */
.guest-delete{
  margin-top: 6px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
}
.guest-delete:hover:not(:disabled){ background: rgba(0,0,0,.06); }
.guest-delete:disabled{ opacity: .5; cursor: default; }
