:root {
  --bg-color: #eee6d8;
  --text-color: #8a4513;
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Montserrat', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  color: var(--text-color);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
  /* Background color set via JS/CSS roots, but drawing an overlay on before */
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg-color);
  background-image: url('fondo-optimizado.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.locked-scroll {
  overflow: hidden;
  height: 100dvh;
}

/* Typography */
.serif-text { font-family: var(--font-serif); }
.sans-text { font-family: var(--font-serif); font-weight: 400; } /* Overriding sans-text to be playfair medium as requested globally */
.italic-text { font-style: italic; }
.fw-bold { font-weight: 600; }

.small-text { font-size: clamp(0.9rem, 2vw, 1.1rem); line-height: 1.4; }
.regular-text { font-size: clamp(1rem, 3vw, 1.25rem); line-height: 1.6; text-align: center; font-weight: 300; }
.title-text { font-size: clamp(2.5rem, 8vw, 4rem); line-height: 1; text-align: center; margin-bottom: 1.5rem; }
.giant-text { font-size: clamp(3.5rem, 10vw, 5rem); line-height: 1.1; margin: 1rem 0; text-align: center; }
.tight-line { line-height: 0.8 !important; }
.uppercase-tracking { text-transform: uppercase; letter-spacing: 2px; }
.mb-1 { margin-bottom: 0.5rem; }

h1, h2, h3, p { text-align: center; }

/* Utilities */
.hidden-initially { display: none; }
.hidden { opacity: 0 !important; pointer-events: none !important; transform: translateY(100%); transition: all 0.5s ease; }
.center-content { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.margin-top-lg { margin-top: 3rem; }
.margin-top-xl { margin-top: 5rem; }
.mt-2 { margin-top: 1rem; }
.pb-extra { padding-bottom: 12rem !important; } /* Space for sticky bar */

/* Sections */
.section {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 2.5rem 2rem; /* Reduced vertical padding */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Divider block */
.divider {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}
.divider img {
  width: 80%; /* Expand to span the section */
  max-width: 400px;
  opacity: 0.8;
}

.screen-height {
  min-height: 100dvh;
  padding: 2rem;
}

/* Entry Screen */
.entry-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  z-index: 1000;
  background-color: transparent; /* No background here to avoid double-painting lag */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.entry-screen.slide-up-out {
  transform: translateY(-100%);
}

.fade-in-delay {
  opacity: 0;
  animation: fadeIn 2s ease forwards 0.5s;
}

@keyframes fadeIn { to { opacity: 1; } }

.swipe-indicator {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.8;
}

.absolute-bottom {
  position: absolute;
  bottom: max(5rem, 12dvh);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}

.swipe-icon {
  width: 40px;
  height: 40px;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.swipe-text {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.bounce {
  animation: bounce 2s infinite ease-in-out;
}

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

/* Typewriter */
.typewriter-text {
  font-size: clamp(1rem, 3.5vw, 1.4rem); /* Slightly smaller than before */
  line-height: 1.8;
  max-width: 90%;
  text-align: center;
  font-weight: 300;
  text-wrap: balance;
}

.typewriter-text span.script-highlight {
  font-family: var(--font-serif);
  font-size: 2.2em; /* Made this significantly larger */
  font-style: italic;
  display: block;
  line-height: 0.9;
  margin-top: 0.2rem;
}

.cursor {
  display: inline-block;
  color: var(--text-color);
  animation: blink 0.7s infinite;
  margin-left: 2px;
  font-style: normal; /* keep pipe straight even in italics if desired, or let it inherit */
}
@keyframes blink { 0%, 100% { opacity: 1;} 50% { opacity: 0; } }

/* Images */
.image-wrapper {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}
.couple-img {
  width: 80%;
  max-width: 300px;
  object-fit: cover;
  mix-blend-mode: multiply; /* Helps with sketches on light bg */
}
.hacienda-img {
  width: 90%;
  max-width: 400px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

/* Timeline - redesign */
.timeline {
  position: relative;
  width: 100%;
  padding: 0;
  margin: 2rem 0;
}
.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px; /* Thinner line */
  height: 100%;
  background-color: var(--text-color);
  opacity: 0.5; /* Softer line */
}
.timeline-item {
  position: relative;
  width: 100%;
  margin-bottom: 4rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-left: 0;
  padding-right: calc(50% + 20px); /* Push icon away from the center line */
}
.timeline-item:last-child {
  margin-bottom: 0; /* Shrink central line to end exactly at the last item */
}
.timeline-item.right-align {
  justify-content: flex-start;
  padding-right: 0;
  padding-left: calc(50% + 20px); /* Symmetry with left blocks */
}

/* We ditch the absolute positioning of the icon and put it in the flex flow */
.timeline-icon {
  width: 55px; /* Slightly smaller to save space */
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Remove border and background */
}
.timeline-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.timeline-content {
  padding: 0 0.5rem; /* Less padding to fit on mobile */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Left block (icon on left, text on right) */
.timeline-item:not(.right-align) {
  flex-direction: row; 
}
.timeline-item:not(.right-align) .timeline-content {
  text-align: left;
}

/* Right block (text on left, icon on right) */
.timeline-item.right-align {
  flex-direction: row-reverse;
}
.timeline-item.right-align .timeline-content {
  text-align: right;
}

.timeline-content h3 {
  font-size: 1.15rem;
  margin-bottom: 0.2rem;
  color: var(--text-color);
  white-space: nowrap; /* Prevent time from splitting */
}
.timeline-content p {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-color);
  opacity: 0.9;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  font-family: var(--font-serif); /* Changed back to serif */
  font-style: italic; /* Added italic for all buttons */
  font-size: 1.2rem;
  text-decoration: none;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
  min-width: 180px;
  text-align: center;
  border: 1px solid #0d2240; /* Dark navy border globally */
  background-color: #0d2240; /* Dark navy background globally */
  color: #fff;               /* White text globally */
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background-color: #1a3a6c;
    border-color: #1a3a6c;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 34, 64, 0.3);
  }
}
.btn-small {
  padding: 0.6rem 1.2rem;
  min-width: auto;
  font-size: 1.1rem;
}

.btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
}

/* RSVP Block Specific */
.rsvp-block {
  margin: 5rem 0 3rem 0; /* Reduced margins to bring gallery closer */
}
.rsvp-title {
  margin-bottom: 4rem;
  line-height: 0.85 !important; /* Loosened from 0.7 to prevent vertical clash */
  font-size: clamp(2.5rem, 13vw, 7.5rem); /* Reduced vw to prevent horizontal overflow */
  white-space: nowrap; /* Never break the word in half */
}
.rsvp-top {
  font-size: 0.7em;
  font-style: italic; /* Match bottom */
  display: inline-block;
  transform: translateX(-10%); /* Slight offset to the left like in the picture */
}
.rsvp-bottom {
  font-size: 1.1em;
  letter-spacing: -2px;
}

/* Sticky Countdown */
.sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.35); /* Liquid glass base (more transparent) */
  backdrop-filter: blur(20px) saturate(160%); /* Intense blur and saturation for the liquid glass effect */
  -webkit-backdrop-filter: blur(20px) saturate(160%); /* For Safari/iOS */
  border-top: 1px solid rgba(255, 255, 255, 0.5); /* Etched top edge */
  padding: 1rem;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.05);
  z-index: 100;
  transition: transform 0.5s ease;
  transform: translateY(0);
}
.countdown-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  max-width: 400px;
  margin: 0 auto;
}
.cd-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cd-item span {
  font-size: 1.5rem;
  font-weight: bold;
}
.cd-item small {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

/* Modal */
.modal {
  border: none;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  background: transparent; /* Removiendo la caja oscura de fondo */
  position: fixed;
  inset: 0; /* top: 0, right: 0, bottom: 0, left: 0 */
  width: 100vw;
  height: 100dvh;
  max-width: none; /* Sobrescribir limite nativo de <dialog> en celulares */
  max-height: none; /* Sobrescribir limite nativo de <dialog> en celulares */
  z-index: 2000;
  display: flex !important; /* Forzar el centrado flex siempre */
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal[open] {
  opacity: 1;
  pointer-events: auto;
  display: flex !important; /* Enforce flex container over native dialog block */
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.4); /* Capa oscura real para toda la pantalla */
}
.modal-content {
  padding: 0;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  margin: 0 auto; /* Explicitly force horizontal centering */
  position: relative;
  text-align: center;
  border: none;
  background: transparent;
  -webkit-transform: scale(0.95) translateZ(0);
  transform: scale(0.95) translateZ(0);
  transition: transform 0.3s ease, -webkit-transform 0.3s ease;
}
.modal-inner-bg {
  background: rgba(255, 255, 255, 0.65); /* Much brighter base to avoid muddy grey look */
  backdrop-filter: blur(15px) saturate(160%);
  -webkit-backdrop-filter: blur(15px) saturate(160%);
  border: 1.5px solid rgba(255, 255, 255, 0.9); /* Solid glass edge */
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), inset 0 0 15px rgba(255, 255, 255, 0.6); /* Inner glassy glow */
  padding: 3rem 1.5rem 2.5rem; /* Ajuste arriba para la "X" de cerrar */
  border-radius: 20px;
  width: 100%;
  /* Eliminado: height: 100% (esto provocaba que se estirara verticalmente todo el teléfono) */
  overflow: hidden;
}
.modal[open] .modal-content {
  -webkit-transform: scale(1) translateZ(0);
  transform: scale(1) translateZ(0);
}
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-color);
  cursor: pointer;
  line-height: 1;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.modal-data {
  margin: 1.5rem 0;
  line-height: 1.8;
  font-size: 0.95rem;
}
/* Fallback if iOS ignores meta tag for numbers */
.modal-data a {
  color: inherit !important;
  text-decoration: none !important;
  pointer-events: none;
}
.modal-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}
.modal-data strong {
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: rgba(138, 69, 19, 0.7);
}
.modal-clabe {
  font-size: 1.2rem;
  letter-spacing: 1px;
}

/* Animations */
.animate-on-scroll {
  will-change: transform, opacity, filter;
}
.slide-up {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.slide-up.in-view { opacity: 1; transform: translateY(0); }

.slide-right {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1);
}
.slide-right.in-view { opacity: 1; transform: translateX(0); }

.slide-left {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1);
}
.slide-left.in-view { opacity: 1; transform: translateX(0); }

.zoom-in {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.zoom-in.in-view { opacity: 1; transform: scale(1); }

.blur-in {
  opacity: 0;
  filter: blur(10px);
  transform: scale(1.05);
  transition: opacity 1s ease, filter 1s ease, transform 1s ease;
}
.blur-in.in-view { opacity: 1; filter: blur(0); transform: scale(1); }

.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }
.delay-6 { transition-delay: 0.6s; }

/* Desktop overrides / tweaks */
@media (min-width: 768px) {
  .timeline::before {
    left: 15%;
  }
  .timeline-item {
    padding-left: 15% !important;
    padding-right: 0 !important;
  }
  .timeline-item.right-align {
    padding-left: 15% !important;
  }
  /* On desktop, keep everything uniform like the left-block style */
  .timeline-item:not(.right-align),
  .timeline-item.right-align {
    flex-direction: row;
    justify-content: flex-start;
  }
  .timeline-item:not(.right-align) .timeline-content,
  .timeline-item.right-align .timeline-content {
    text-align: left;
  }
}

/* Photo Gallery (Overlapping Collage) */
.photo-gallery-wrapper {
  width: 100%;
  padding: 0 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 3rem;
  margin-bottom: 2rem;
  overflow: visible;
}

.photo-gallery {
  position: relative;
  width: 100%;
  max-width: 350px;
  height: 600px; /* Reduced to bring them closer together but not as much as original */
  margin: 0 auto;
}

.gallery-img {
  position: absolute;
  object-fit: cover;
}

/* Individual photo positioning vertically with slight overlaps */
.gal-1 { 
  width: 55%; 
  height: auto; 
  top: 0%; 
  left: 5%; 
  transform: rotate(-6deg); 
  z-index: 1; 
}
.gal-2 { 
  width: 50%; 
  height: auto; 
  top: 15%; 
  right: 5%; 
  transform: rotate(8deg); 
  z-index: 2; 
}
.gal-3 { 
  width: 55%; 
  height: auto; 
  top: 30%; 
  left: 2%; 
  transform: rotate(-5deg); 
  z-index: 3; 
}
.gal-4 { 
  width: 50%; 
  height: auto; 
  top: 45%; 
  right: 0%; 
  transform: rotate(10deg); 
  z-index: 4; 
}
.gal-5 { 
  width: 60%; 
  height: auto; 
  top: 60%; 
  left: 15%; 
  transform: rotate(-8deg); 
  z-index: 5; 
}

/* Responsive tweaks for wider screens */
@media (min-width: 768px) {
  .photo-gallery {
    max-width: 500px;
    height: 1500px;
  }
  .gal-1 { transform: rotate(-8deg); }
  .gal-2 { transform: rotate(10deg); }
  .gal-3 { transform: rotate(-14deg); }
  .gal-4 { transform: rotate(12deg); }
  .gal-5 { transform: rotate(-10deg); }
}
