/* ==========================================================================
   VARIABLES DE DISEÑO (Fáciles de cambiar sin tocar la funcionalidad)
   ========================================================================== */
:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-surface-alt: #f2eee8;
  --color-text: #2c2a29;
  --color-text-muted: #6b6560;
  --color-primary: #5c6b57;       /* Verde oliva neutro por defecto */
  --color-primary-hover: #495645;
  --color-border: #e3ddd5;
  --color-success-bg: #edf5ee;
  --color-success-text: #255a2c;
  --color-warning-bg: #fdf6e7;
  --color-warning-text: #7a5410;

  --font-heading: "Georgia", "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 12px;
  --max-width: 780px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   BASE Y TIPOGRAFÍA
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.25;
  margin-top: 0;
}

a {
  color: var(--color-primary);
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.section {
  padding: 3rem 0;
  border-bottom: 1px solid var(--color-border);
}

.section:last-of-type {
  border-bottom: none;
}

.section-title {
  text-align: center;
  font-size: 1.85rem;
  margin-bottom: 1.5rem;
}

.muted {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   PORTADA / BIENVENIDA PERSONALIZADA
   ========================================================================== */
.hero {
  text-align: center;
  padding: 4rem 1.25rem 3.5rem;
  background: linear-gradient(180deg, var(--color-surface-alt) 0%, var(--color-bg) 100%);
  border-bottom: 1px solid var(--color-border);
}

.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.hero-names {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  margin-bottom: 0.5rem;
}

.hero-date {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.invite-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
}

.invite-greeting {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.invite-note {
  margin: 0;
  color: var(--color-text);
}

/* ==========================================================================
   CUENTA ATRÁS (HORARIO DE ESPAÑA)
   ========================================================================== */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  max-width: 520px;
  margin: 0 auto;
}

.countdown-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.countdown-num {
  display: block;
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  color: var(--color-primary);
}

.countdown-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.countdown-tz {
  text-align: center;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   HORARIOS Y UBICACIÓN
   ========================================================================== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px dashed var(--color-border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-time {
  min-width: 110px;
  font-weight: 600;
  color: var(--color-primary);
}

.map-frame {
  width: 100%;
  height: 280px;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  margin-top: 1rem;
}

/* ==========================================================================
   INFORMACIÓN PRÁCTICA
   ========================================================================== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.info-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   BOTONES Y FORMULARIO RSVP
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.35rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.btn:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-surface-alt);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.form-control[readonly] {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

.radio-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--color-surface);
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid #c5dfc9;
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid #f0dfb6;
}

/* ==========================================================================
   FALLBACK SIN CÓDIGO EN LA URL
   ========================================================================== */
.manual-lookup {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.manual-lookup input {
  max-width: 240px;
}

/* ==========================================================================
   REGALO / IBAN Y LISTA DE CANCIONES
   ========================================================================== */
.iban-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.85rem;
}

.iban-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.songs-input-row {
  display: flex;
  gap: 0.5rem;
}

.song-tags {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.song-tag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.92rem;
}

.song-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
}

.song-remove:hover {
  color: var(--color-text);
}

.field-error {
  color: #a63429;
  font-size: 0.88rem;
  margin-top: 0.35rem;
}

.spotify-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.spotify-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}

.spotify-track-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.spotify-track-cover {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.spotify-track-meta {
  min-width: 0;
}

.spotify-track-title,
.spotify-track-artist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotify-track-title {
  font-weight: 500;
  font-size: 0.94rem;
}

.spotify-track-artist {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   PANTALLA DE ACCESO (SOLO PANEL DE CÓDIGO) Y CARGA
   ========================================================================== */
.gate-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--color-surface-alt) 0%, var(--color-bg) 100%);
}

.gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2.25rem 1.75rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 1rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   TRANSICIÓN DE APERTURA DE CARTA (SOBRE)
   ========================================================================== */
.envelope-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at center, var(--color-surface-alt) 0%, var(--color-bg) 100%);
  transition: opacity 0.65s ease, visibility 0.65s ease;
}

.envelope-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.envelope-wrapper {
  width: 100%;
  max-width: 540px;
  perspective: 1400px;
  cursor: pointer;
}

.envelope {
  position: relative;
  width: 100%;
  height: 340px;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.envelope-wrapper:hover .envelope {
  transform: translateY(-6px);
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: #e9e3da;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  z-index: 0;
}

.envelope-letter {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 22px;
  bottom: 22px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.22s;
}

.envelope-monogram {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: 0.14em;
  color: var(--color-primary);
  margin: 0;
}

.envelope.is-open .envelope-letter {
  transform: translateY(-110px) scale(1.03);
}

.envelope-pocket {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}

.envelope-pocket::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-surface);
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
  border: 1px solid var(--color-border);
}

.envelope-pocket::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.03) 0%, transparent 45%);
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 56%;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  border-radius: 12px 12px 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  z-index: 4;
  transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s linear 0.25s;
}

.envelope.is-open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-seal {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2), inset 0 0 0 3px rgba(255, 255, 255, 0.22);
  z-index: 5;
  transition: opacity 0.3s ease, transform 0.35s ease;
}

.envelope.is-open .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
}

.envelope-hint {
  margin-top: 1.75rem;
  text-align: center;
}

@media (max-width: 560px) {
  .envelope-wrapper {
    max-width: 92vw;
  }
  .envelope {
    height: 230px;
  }
  .envelope.is-open .envelope-letter {
    transform: translateY(-72px) scale(1.02);
  }
  .envelope-seal {
    width: 58px;
    height: 58px;
    font-size: 0.98rem;
  }
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

@media (max-width: 520px) {
  .timeline-item {
    flex-direction: column;
    gap: 0.25rem;
  }
}
