/* ============================================================
   mejoras.css — Capa de mejoras de Soluciones Eléctricas
   Animaciones de entrada, responsividad y ajustes visuales.
   ============================================================ */

/* ---------- 1. Quitar las "píldoras" decorativas ---------- */
/* Etiquetas tipo "Experiencia profesional" que restaban seriedad. */
[data-quitar-pildora] {
  display: none !important;
}

/* ---------- 2. Aparición al hacer scroll ---------- */
.has-js [data-revelar] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.has-js [data-revelar].es-visible {
  opacity: 1;
  transform: none;
}
/* Escalonado dentro de rejillas */
.has-js [data-revelar-hijos] > * {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.has-js [data-revelar-hijos].es-visible > * {
  opacity: 1;
  transform: none;
}
.has-js [data-revelar-hijos].es-visible > *:nth-child(1) { transition-delay: 0.05s; }
.has-js [data-revelar-hijos].es-visible > *:nth-child(2) { transition-delay: 0.13s; }
.has-js [data-revelar-hijos].es-visible > *:nth-child(3) { transition-delay: 0.21s; }
.has-js [data-revelar-hijos].es-visible > *:nth-child(4) { transition-delay: 0.29s; }
.has-js [data-revelar-hijos].es-visible > *:nth-child(5) { transition-delay: 0.37s; }
.has-js [data-revelar-hijos].es-visible > *:nth-child(6) { transition-delay: 0.45s; }

/* ---------- 3. Micro-interacciones ---------- */
/* Tarjetas: elevación suave */
main .rounded-xl,
main .rounded-2xl,
footer .rounded-xl {
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
main .shadow-lg:hover,
main .shadow-md:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.22);
}
/* Botones y enlaces de acción */
main a[href^="http"],
main a[href^="tel"],
main button {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}
main a[class*="bg-accent"]:hover,
main button[class*="bg-accent"]:hover,
main a[class*="bg-primary"]:hover,
main button[class*="bg-primary"]:hover {
  transform: translateY(-2px) scale(1.02);
}
main a[class*="bg-accent"]:active,
main button[class*="bg-accent"]:active {
  transform: scale(0.97);
}
/* Imágenes de proyecto: acercamiento suave */
main img {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
main .overflow-hidden:hover > img {
  transform: scale(1.05);
}

/* ---------- 4. Mapa embebido ---------- */
.mapa-embebido {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 0;
  display: block;
  filter: grayscale(30%);
  transition: filter 0.6s ease;
}
.mapa-embebido:hover {
  filter: grayscale(0%);
}

/* ---------- 5. Responsividad ---------- */
@media (max-width: 640px) {
  /* Áreas táctiles cómodas */
  main a[class*="px-"],
  main button[class*="px-"] {
    min-height: 44px;
  }
  /* Titulares: nunca partir palabras con guion; ajustar tamaño para que quepan */
  h1, h2, h3, p {
    hyphens: none !important;
    -webkit-hyphens: none !important;
    overflow-wrap: break-word;
    word-break: normal;
  }
  h1 {
    font-size: clamp(1.75rem, 8.5vw, 2.5rem) !important;
    line-height: 1.15 !important;
  }
  h2 {
    font-size: clamp(1.4rem, 6.5vw, 2rem) !important;
    line-height: 1.2 !important;
  }
  /* El logo del pie, a tamaño legible */
  footer img {
    max-width: 220px;
    height: auto;
  }
}

/* Nunca permitir desbordamiento horizontal */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* ---------- 6. Accesibilidad ---------- */
:focus-visible {
  outline: 3px solid #c0a040;
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .has-js [data-revelar],
  .has-js [data-revelar-hijos] > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  main .shadow-lg:hover,
  main .shadow-md:hover,
  main a:hover,
  main button:hover,
  main .overflow-hidden:hover > img {
    transform: none !important;
  }
}

/* ============================================================
   NIVEL 2 — Animaciones avanzadas
   ============================================================ */

/* ---------- Barra de progreso de lectura ---------- */
.barra-progreso {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #1b3a5c 0%, #c0a040 100%);
  z-index: 9999;
  pointer-events: none;
  will-change: transform;
}

/* ---------- Titulares palabra por palabra ---------- */
.palabra {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}
.has-js .palabra > [data-p] {
  display: inline-block;
  transform: translateY(105%) rotate(2deg);
  opacity: 0;
  transition:
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.6s ease;
  transition-delay: calc(var(--i, 0) * 55ms);
  will-change: transform, opacity;
}
.has-js h1.es-visible .palabra > [data-p],
.has-js h2.es-visible .palabra > [data-p] {
  transform: none;
  opacity: 1;
}

/* ---------- Tarjetas con inclinación 3D ---------- */
.tarjeta-3d {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}
/* Brillo que sigue al cursor */
.tarjeta-3d::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    420px circle at var(--mx, 50%) var(--my, 50%),
    rgb(255 255 255 / 0.16),
    transparent 45%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.tarjeta-3d:hover::after {
  opacity: 1;
}

/* La elevación genérica no debe pelearse con la inclinación 3D */
main .tarjeta-3d:hover {
  transform: none;
  box-shadow: 0 22px 48px -14px rgb(0 0 0 / 0.28);
}

/* ---------- Preferencia de movimiento reducido ---------- */
.sin-movimiento .barra-progreso {
  display: none;
}
.sin-movimiento .palabra > [data-p] {
  transform: none !important;
  opacity: 1 !important;
  transition: none !important;
}
.sin-movimiento .tarjeta-3d,
.sin-movimiento main img {
  transform: none !important;
}
.sin-movimiento .tarjeta-3d::after {
  display: none;
}

/* ---------- Titulares fluidos también en tablet ---------- */
@media (min-width: 641px) and (max-width: 1023px) {
  h1, h2, h3, p {
    hyphens: none !important;
    -webkit-hyphens: none !important;
    overflow-wrap: break-word;
  }
  h1 {
    font-size: clamp(2.25rem, 6vw, 3rem) !important;
    line-height: 1.14 !important;
  }
  h2 {
    font-size: clamp(1.75rem, 4.4vw, 2.35rem) !important;
    line-height: 1.2 !important;
  }
  h3 {
    font-size: clamp(1.15rem, 2.6vw, 1.5rem) !important;
  }
}

/* Ningún titular debe partirse con guion en ninguna anchura */
h1, h2, h3, h4 {
  hyphens: none;
  -webkit-hyphens: none;
}
