/* ===== Scroll suave ===== */
html {
  scroll-behavior: smooth;
}

/* Evita scroll horizontal por las animaciones laterales */
html, body {
  overflow-x: clip;
}

/* Que el header fijo no tape el título al navegar por el menú */
section[id] {
  scroll-margin-top: 88px;
}

/* ===== Animaciones Scroll Reveal ===== */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-left {
  opacity: 0;
  transform: translateX(-50px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}
.reveal-right {
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}
.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* ===== Retrasos escalonados para tarjetas ===== */
.stagger-1 { transition-delay: 0.05s; }
.stagger-2 { transition-delay: 0.1s; }
.stagger-3 { transition-delay: 0.15s; }
.stagger-4 { transition-delay: 0.2s; }
.stagger-5 { transition-delay: 0.25s; }
.stagger-6 { transition-delay: 0.3s; }
.stagger-7 { transition-delay: 0.35s; }
.stagger-8 { transition-delay: 0.4s; }
.stagger-9 { transition-delay: 0.45s; }
.stagger-10 { transition-delay: 0.5s; }

/* ===== Botón Volver Arriba ===== */
#back-to-top {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1D6FA8;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.3s ease;
}
#back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#back-to-top:hover {
  background: #E30B14;
  transform: translateY(-3px);
}

/* ===== Botón Flotante WhatsApp ===== */
#whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 40;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: whatsapp-pulse 2s infinite;
}
#whatsapp-float:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(37, 211, 102, 0.6);
  animation: none;
}
@keyframes whatsapp-pulse {
  0% { box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); }
  50% { box-shadow: 0 6px 30px rgba(37, 211, 102, 0.7); }
  100% { box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); }
}

/* Tooltip del WhatsApp */
#whatsapp-tooltip {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 39;
  background: white;
  color: #0E3557;
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}
#whatsapp-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#whatsapp-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid white;
}

/* ===== Indicador de sección activa en nav ===== */
.nav-link.active {
  color: #1D6FA8;
  position: relative;
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #E30B14;
  border-radius: 2px;
}

/* ===== Hover mejorado para tarjetas de servicio ===== */
.service-card {
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}
.service-card:hover {
  transform: translateY(-8px) scale(1.02);
}

/* ===== Testimonios mejorados ===== */
.testimonial-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.testimonial-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.1);
}

/* ===== Imagen de fachada en Hero ===== */
.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.hero-image:hover {
  transform: scale(1.05);
}

/* ===== Responsive: ajustar tooltip en mobile ===== */
@media (max-width: 640px) {
  #whatsapp-float {
    width: 54px;
    height: 54px;
    font-size: 1.7rem;
    right: 16px;
    bottom: 20px;
  }
  #back-to-top {
    right: 16px;
    bottom: 82px;
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }
  #whatsapp-tooltip {
    font-size: 0.75rem;
    padding: 8px 14px;
    right: 16px;
    bottom: 82px;
  }
}

/* ===== Galería de instalaciones ===== */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  aspect-ratio: 3 / 4;
  background: #f1f5f9;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.08);
}
.gallery-item.col-span-2 {
  aspect-ratio: auto;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.gallery-item:hover img {
  transform: scale(1.05);
}
.gallery-item figcaption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(14, 53, 87, 0.85);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}
@media (max-width: 1023px) {
  .gallery-item.col-span-2 {
    aspect-ratio: 4 / 3;
  }
}

/* ===== Accesibilidad: menos movimiento ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal-left, .reveal-right, .reveal-scale {
    opacity: 1;
    transform: none;
    transition: none;
  }
  #whatsapp-float { animation: none; }
}
