@font-face {
  font-family: 'slight';
  font-style: normal;
  font-weight: normal;
  src: url('https://royal-invite.com/wp-content/uploads/2026/01/slight-regular.ttf') format('truetype');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --crema: #FAF7F2;
  --papel: #F7F3EC;
  --tinta: #3D3028;
  --tinta-media: #5C4A3A;
  --tinta-suave: #7A6B5C;
  --tinta-clara: #9A8B7A;
  --cdn: https://pub-a65601eb9ffe4b62a9bcbf111a23ee8c.r2.dev/invitations/custom-orders/pao;
  --fondo-papel: url('https://pub-a65601eb9ffe4b62a9bcbf111a23ee8c.r2.dev/invitations/custom-orders/pao/fondo%20ultimo1.webp');
  /* ↓ Pega aquí la URL de tu Google Apps Script desplegado como aplicación web */
  --script-url: '';
}

html {
  min-height: 100%;
  background-color: var(--crema);
}

html, body {
  overflow-x: hidden;
  width: 100%;
  color: var(--tinta);
  font-family: 'Antic Didone', serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  padding-bottom: 40px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--crema);
  background-image:
    linear-gradient(180deg,
      rgba(250, 247, 242, 0.28) 0%,
      rgba(250, 247, 242, 0.18) 50%,
      rgba(250, 247, 242, 0.24) 100%),
    var(--fondo-papel);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.page-top {
  text-align: center;
  padding: 20px 16px 8px;
  position: relative;
  z-index: 2;
}

.back-link {
  display: inline-block;
  font-family: 'Antic Didone', serif;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--tinta-suave);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.25s;
}

.back-link:hover { color: var(--tinta); }

.page-logo {
  width: clamp(64px, 18vw, 88px);
  margin: 0 auto 12px;
  display: block;
  opacity: 0.95;
}

.page-title {
  font-family: 'slight', cursive;
  font-size: clamp(28px, 7vw, 42px);
  font-weight: normal;
  color: var(--tinta);
  line-height: 1.15;
  margin-bottom: 6px;
}

.page-sub {
  font-family: 'Lustria', serif;
  font-size: clamp(13px, 3.2vw, 15px);
  color: var(--tinta-media);
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.55;
}

/* ===== CARTA / SOBRE ===== */
.upload-carta {
  padding: 12px 16px 0;
  position: relative;
  z-index: 1;
  margin-bottom: clamp(-48px, -10vw, -32px);
}

.inv-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: clamp(560px, 148vw, 680px);
  overflow: visible;
}

@media (max-width: 480px) {
  .inv-container { min-height: 148vw; }
}

.layer {
  position: absolute;
  width: 100%;
  height: auto;
  top: 0;
  left: 0;
  pointer-events: none;
  user-select: none;
}

.z1 { z-index: 1; }

.inv-sello {
  width: 24%;
  left: 39%;
  top: 21%;
  z-index: 10;
}

.paper-wrapper {
  position: absolute;
  top: 23.5%;
  left: 50%;
  width: 86%;
  transform: translateX(-50%);
  z-index: 5;
}

.inv-paper {
  width: 100%;
  min-height: clamp(340px, 88vw, 420px);
  background-color: var(--papel);
  border: 1px solid rgba(61, 48, 40, 0.18);
  box-shadow: 0 18px 50px rgba(61, 48, 40, 0.1);
  padding: clamp(18px, 4.5vw, 28px) clamp(18px, 4.5vw, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.inv-paper::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(61, 48, 40, 0.1);
  pointer-events: none;
}

.inv-paper-inner {
  width: 100%;
  max-width: 300px;
  position: relative;
  z-index: 1;
  transform: translateY(clamp(-18px, -4.5vw, -12px));
}

.upload-camara-spacer {
  width: clamp(72px, 20vw, 96px);
  height: clamp(50px, 14vw, 68px);
  margin: 0 auto 8px;
  flex-shrink: 0;
}

@keyframes camara-salto {
  0%, 100% { transform: translateY(0); }
  18% { transform: translateY(-10px); }
  36% { transform: translateY(0); }
  48% { transform: translateY(-5px); }
  60% { transform: translateY(0); }
}

.upload-names {
  font-family: 'slight', cursive;
  font-size: clamp(22px, 6vw, 32px);
  color: var(--tinta);
  margin-bottom: 12px;
  line-height: 1.1;
}

.upload-desc {
  font-family: 'Lustria', serif;
  font-size: clamp(11px, 2.8vw, 13px);
  line-height: 1.65;
  color: var(--tinta-media);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.upload-wrapper {
  width: 100%;
  padding: 8px 4px 4px;
  text-align: center;
}

.upload-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.btn-subir-fotos {
  display: inline-block;
  width: 100%;
  max-width: 280px;
  padding: 13px 20px;
  background: #3D3028;
  color: #FAF7F2;
  border: 1.5px solid #3D3028;
  border-radius: 10px;
  font-family: 'Antic Didone', serif;
  font-size: 12px;
  font-weight: 100;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(61, 48, 40, 0.2);
  transition: background 0.25s, transform 0.2s, color 0.25s;
}

.btn-subir-fotos--sec {
  background: transparent;
  color: #3D3028;
  box-shadow: none;
}

.btn-subir-fotos:hover {
  background: #2A221C;
  color: #FAF7F2;
  transform: translateY(-1px);
}

.btn-subir-fotos--sec:hover {
  background: rgba(61, 48, 40, 0.08);
  color: #3D3028;
}

.btn-subir-fotos:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.upload-hint.ok { color: var(--tinta); }
.upload-hint.err { color: #8B4513; }

.upload-hint {
  font-family: 'Lustria', serif;
  font-size: 11px;
  line-height: 1.55;
  color: var(--tinta-suave);
  margin-top: 10px;
  padding: 0 6px;
}

.btn-refrescar {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid rgba(61, 48, 40, 0.25);
  color: var(--tinta-media);
  font-family: 'Antic Didone', serif;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 6px;
}

.btn-refrescar:hover {
  background: rgba(61, 48, 40, 0.06);
}

/* ===== GALERÍA EN VIVO ===== */
.gallery-section {
  max-width: 520px;
  margin: 14px auto 0;
  padding: 0 12px 24px;
  text-align: center;
  position: relative;
  z-index: 2;
  transition: opacity 0.45s ease;
}

.gallery-camara {
  width: clamp(96px, 26vw, 132px);
  margin: 0 auto 4px;
  animation: camara-salto 2.2s ease-in-out infinite;
}

.gallery-camara img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 5px 12px rgba(61, 48, 40, 0.14));
}

.gallery-title {
  font-family: 'slight', cursive;
  font-size: clamp(26px, 6.5vw, 36px);
  color: var(--tinta);
  margin-bottom: 8px;
  margin-top: 0;
}

.gallery-hint {
  font-family: 'Lustria', serif;
  font-size: clamp(12px, 3vw, 14px);
  color: var(--tinta-suave);
  margin-bottom: 22px;
}

.mosaico-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 10px;
  padding: 8px 4px 20px;
  background: transparent;
  border: none;
  min-height: 100px;
  align-items: start;
  justify-items: center;
}

#status-msg {
  grid-column: 1 / -1;
  font-family: 'Lustria', serif;
  font-size: 13px;
  color: var(--tinta-clara);
  padding: 24px 8px;
}

.polaroid-item {
  width: 100%;
  max-width: 148px;
  background: #fff;
  padding: 7px 7px 22px;
  box-shadow:
    0 3px 10px rgba(61, 48, 40, 0.14),
    0 8px 22px rgba(61, 48, 40, 0.08);
  cursor: pointer;
  transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
  position: relative;
  z-index: 1;
  will-change: transform;
}

.polaroid-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--papel);
}

.polaroid-item:hover {
  z-index: 5;
  box-shadow:
    0 6px 16px rgba(61, 48, 40, 0.18),
    0 14px 28px rgba(61, 48, 40, 0.12);
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--ty, 0px) - 3px)) scale(1.04);
}

.polaroid-item.is-new {
  animation: polaroidEnter 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
  z-index: 6;
}

.polaroid-item.is-shift {
  animation: polaroidShift 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes polaroidEnter {
  from {
    opacity: 0;
    transform: translateX(-36px) rotate(calc(var(--rot, 0deg) - 4deg)) scale(0.88);
  }
  to {
    opacity: 1;
    transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px)) scale(1);
  }
}

@keyframes polaroidShift {
  0% {
    transform: translateX(-32px) rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
  }
  45% {
    transform: translateX(16px) rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
  }
  100% {
    transform: rotate(var(--rot, 0deg)) translateY(var(--ty, 0px));
  }
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  z-index: 9999;
  inset: 0;
  background: rgba(61, 48, 40, 0.88);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: 16px;
}

.modal-content-wrapper {
  position: relative;
  max-width: 92%;
  width: 100%;
  max-width: 480px;
  text-align: center;
}

#modal-img {
  max-width: 100%;
  max-height: 68vh;
  border: 1px solid rgba(250, 247, 242, 0.35);
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.modal-controls {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-nav, .btn-download {
  display: inline-block;
  padding: 11px 20px;
  background: transparent;
  color: var(--crema);
  border: 1.5px solid rgba(250, 247, 242, 0.65);
  font-family: 'Antic Didone', serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}

.btn-nav:hover, .btn-download:hover {
  background: var(--crema);
  color: var(--tinta);
}

.modal-close {
  position: absolute;
  top: -44px;
  right: 0;
  color: var(--crema);
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-camara { animation: none; }
  .polaroid-item.is-new,
  .polaroid-item.is-shift { animation: none; }
}
