/* Mejoras comunes a las 4 webs. Las 4 copias son idénticas (mantenerlas sincronizadas).
   Todo es mejora progresiva: un navegador antiguo simplemente lo ignora. */

/* Tipografía: titulares equilibrados y párrafos sin palabras sueltas al final */
h1, h2, h3, h4 { text-wrap: balance; }
p, blockquote { text-wrap: pretty; }

/* Las anclas no quedan debajo de la cabecera fija */
html { scroll-padding-top: 5rem; }

/* Foco visible al navegar con teclado */
:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
#contact-form :is(input, select, textarea):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
#contact-form :is(input, select, textarea):user-invalid { border-color: #dc2626; box-shadow: inset 0 -2px #dc2626; }

/* Preguntas frecuentes: apertura suave */
details::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}
details:not([open])::details-content { block-size: 0; }
summary::-webkit-details-marker { display: none; }

/* Botón (creado por moderno.js) dentro del título de las tarjetas que abren una ventana */
.titulo-boton { font: inherit; color: inherit; letter-spacing: inherit; text-align: inherit; }
.titulo-boton:focus-visible { outline: none; }
.tarjeta-modal:has(.titulo-boton:focus-visible) { outline: 3px solid #2563eb; outline-offset: 3px; }

/* Ventanas modales: <dialog> nativo */
dialog.ventana {
  width: min(42rem, calc(100vw - 2rem));
  max-width: none;
  max-height: 90vh;
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: .25s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog.ventana[open] { opacity: 1; }
dialog.ventana #modal-title { padding-right: 2rem; }
dialog.ventana:modal { overscroll-behavior: contain; }
dialog.ventana::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgb(4 22 39 / 0);
  transition-property: background-color, display, overlay;
  transition-duration: .25s;
  transition-behavior: allow-discrete;
}
dialog.ventana[open]::backdrop {
  background-color: rgb(4 22 39 / .75);
  backdrop-filter: blur(4px);
}
@starting-style {
  dialog.ventana[open] { opacity: 0; }
  dialog.ventana[open]::backdrop { background-color: rgb(4 22 39 / 0); }
}

@media (prefers-reduced-motion: no-preference) {
  /* Fundido entre páginas de la misma web */
  @view-transition { navigation: auto; }

  dialog.ventana { transform: scale(.95); }
  dialog.ventana[open] { transform: none; }
  @starting-style { dialog.ventana[open] { transform: scale(.95); } }

  details::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: .3s;
    transition-timing-function: ease-in-out;
    transition-behavior: allow-discrete;
  }

  /* Aparición al hacer scroll (sustituye a la librería AOS; se usan los mismos data-aos) */
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes aparecer { from { opacity: 0; translate: var(--desde, 0 2rem); scale: var(--escala, 1); filter: blur(6px); } }
    [data-aos] {
      animation: aparecer auto ease-out backwards;
      animation-timeline: view();
      animation-range: entry 0px entry 240px;
    }
    /* overflow: hidden crearía otro contenedor de scroll y la animación quedaría a medias; clip recorta igual */
    .overflow-hidden:has([data-aos]) { overflow: clip; }
    .overflow-x-hidden:has([data-aos]) { overflow-x: clip; }
    /* Portada (primera sección): entra al cargar, no con el scroll */
    :is(main > section:first-of-type, [data-rejilla]) [data-aos] {
      animation: aparecer 1s var(--fx-ease) backwards;
      animation-timeline: auto;
    }
    :is(main > section:first-of-type, [data-rejilla]) [data-aos-delay="100"] { animation-delay: .1s; }
    :is(main > section:first-of-type, [data-rejilla]) [data-aos-delay="200"] { animation-delay: .2s; }
    :is(main > section:first-of-type, [data-rejilla]) [data-aos-delay="300"] { animation-delay: .3s; }
    [data-aos="zoom-in"] { --desde: 0 0; --escala: .95; }
    @media (min-width: 1024px) {
      [data-aos="fade-left"] { --desde: 2rem 0; }
      [data-aos="fade-right"] { --desde: -2rem 0; }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html, html.scroll-smooth { scroll-behavior: auto; }
  dialog.ventana, dialog.ventana::backdrop { transition-duration: .1s; }
  *, ::before, ::after { animation-duration: .01ms; animation-iteration-count: 1; }
}

/* ── Efectos de la landing (betanet /soluciones), activados con atributos en el HTML ──
   --acento / --acento-2: color de la marca (en el style del <html> de cada portada).
   Sin JS o con movimiento reducido todo se ve igual, sin animar. */
:root { --acento: #2563eb; --acento-2: var(--acento); --fx-ease: cubic-bezier(.2, .7, .2, 1); }

/* Portada [data-rejilla]: rejilla tenue, rejilla que se ilumina bajo el puntero y halos de color */
.fx-capa { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.fx-rejilla, .fx-rejilla-luz { position: absolute; inset: 0; background-size: 36px 36px; }
.fx-rejilla {
  background-image: linear-gradient(rgb(4 22 39 / .05) 1px, transparent 1px), linear-gradient(90deg, rgb(4 22 39 / .05) 1px, transparent 1px);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}
.fx-rejilla-luz {
  background-image: linear-gradient(color-mix(in srgb, var(--acento) 45%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--acento) 45%, transparent) 1px, transparent 1px);
  opacity: 0; transition: opacity .4s;
  mask-image: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), #000, transparent 75%);
}
.fx-rejilla-luz.activa { opacity: 1; }
.fx-halo { position: absolute; width: 520px; height: 520px; max-width: 80vw; max-height: 80vw; border-radius: 50%; filter: blur(90px); opacity: .18; }
.fx-halo--a { background: var(--acento); top: -220px; right: -140px; }
.fx-halo--b { background: var(--acento-2); bottom: -260px; left: -180px; opacity: .14; }

/* Titular palabra a palabra [data-palabras] */
.fx-palabra { display: inline-block; }

/* Tarjetas con foco de luz que sigue al puntero y borde degradado al pasar */
.fx-foco { position: relative; isolation: isolate; }
.fx-foco::after, .fx-foco::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .4s var(--fx-ease); }
.fx-foco::after { z-index: 1; background: radial-gradient(380px circle at var(--x, 50%) var(--y, 0%), color-mix(in srgb, var(--acento) 22%, transparent), transparent 65%); }
.fx-foco::before {
  z-index: 3; padding: 1px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--acento) 70%, transparent), transparent 50%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.fx-foco:hover::after, .fx-foco:hover::before { opacity: 1; }
:where(.fx-foco > :not(.absolute, .hidden, .service-detail, .permit-detail)) { position: relative; z-index: 2; }

/* Cinta de servicios en movimiento .fx-cinta > .fx-cinta__pista > ul ×2 */
.fx-cinta { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 120px, #000 calc(100% - 120px), transparent); }
.fx-cinta__pista { display: flex; width: max-content; }
.fx-cinta ul { display: flex; gap: 3.25rem; margin: 0; padding: 0 1.625rem; list-style: none; }
.fx-cinta li { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }

@media (prefers-reduced-motion: no-preference) {
  @keyframes fx-subir { to { opacity: 1; transform: none; filter: none; } }
  @keyframes fx-flotar { 50% { transform: translateY(-14px); } }
  @keyframes fx-desliza { to { transform: translateX(-50%); } }
  @keyframes fx-entrar { from { opacity: 0; } }

  .fx-halo--a { animation: fx-flotar 14s ease-in-out infinite; }
  .fx-halo--b { animation: fx-flotar 18s ease-in-out infinite reverse; }
  .fx-flota { animation: fx-flotar 7s ease-in-out infinite; }
  .fx-cinta__pista { animation: fx-desliza 38s linear infinite; }
  .fx-cinta:hover .fx-cinta__pista { animation-play-state: paused; }

  /* Hasta que moderno.js parte el titular, se oculta; si el JS no llega, aparece solo a los 1,2 s */
  [data-palabras]:not(.fx-listo) { animation: fx-entrar .6s ease-out 1.2s backwards; }
  /* Las palabras entran cuando el titular se ve (.fx-ver la pone moderno.js) */
  .fx-palabra { opacity: 0; transform: translateY(.45em); filter: blur(8px); }
  .fx-ver .fx-palabra { animation: fx-subir 1s var(--fx-ease) forwards; animation-delay: calc(var(--i) * 70ms + 150ms); }

  /* Navegadores sin animation-timeline (Firefox, Safari): moderno.js marca [data-aos] con .fx-revela y .visible */
  @keyframes fx-aparecer { from { opacity: 0; translate: var(--desde, 0 2rem); scale: var(--escala, 1); filter: blur(6px); } }
  .fx-revela:not(.visible) { opacity: 0; }
  .fx-revela.visible { animation: fx-aparecer 1s var(--fx-ease) backwards; animation-delay: var(--fx-retraso, 0s); }
  .fx-revela[data-aos="zoom-in"] { --desde: 0 0; --escala: .95; }
  @media (min-width: 1024px) {
    .fx-revela[data-aos="fade-left"] { --desde: 2rem 0; }
    .fx-revela[data-aos="fade-right"] { --desde: -2rem 0; }
  }
}
