/* ============================================================
   CIFH — Header, navegacion y footer
   ============================================================ */

/* ---------- Barra de progreso de scroll ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 300;
  pointer-events: none;
  background: transparent;
}
.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-brand), #FFB27A);
  transition: width 80ms linear;
}

.topbar {
  background: var(--color-navy);
  color: #fff;
}
.topbar .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2) var(--sp-6);
  padding-block: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
@media (max-width: 480px) {
  .topbar .container { justify-content: center; }
}
.topbar a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: #EAECF7;
  transition: color var(--dur-fast) var(--ease);
}
.topbar a:hover { color: #fff; }
.topbar svg { width: 14px; height: 14px; flex: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-line);
  transition: box-shadow var(--dur-base) var(--ease);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding-block: var(--sp-3);
  transition: padding-block var(--dur-base) var(--ease);
}
.site-header.is-scrolled { box-shadow: 0 8px 30px rgba(17, 28, 78, 0.08); }
.site-header.is-scrolled .container { padding-block: var(--sp-2); }

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand img { height: 32px; width: auto; transition: height var(--dur-base) var(--ease); }
.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--color-navy);
}
.site-header.is-scrolled .brand img { height: 26px; }

.nav-primary { display: none; }
.nav-primary ul { display: flex; align-items: center; gap: var(--sp-6); list-style: none; padding: 0; }
.nav-primary a {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-ink);
  padding: var(--sp-2) 0;
  position: relative;
}
.nav-primary a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 2px;
  background: var(--color-brand);
  transition: right var(--dur-base) var(--ease);
}
.nav-primary a:hover::after,
.nav-primary li.is-active a::after { right: 0; }

.has-submenu { position: relative; }
.has-submenu > a { display: inline-flex; align-items: center; gap: 6px; }
.has-submenu > a svg { width: 12px; height: 12px; transition: transform var(--dur-base) var(--ease); }
.has-submenu:hover > a svg { transform: rotate(180deg); }

/* Mega-menu de Servicios: ancho FIJO (definido explicitamente) para que
   "1fr 1fr" tenga una base real que repartir -- sin esto, un grid dentro
   de un contenedor con posicion absoluta y ancho automatico colapsa cada
   columna a su max-content y rompe el layout en una sola fila gigante. */
.mega-menu {
  position: absolute;
  top: 100%; left: 0;
  transform: translateY(10px);
  width: 620px;
  max-width: calc(100vw - 2 * var(--container-pad));
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
  display: flex;
  align-items: stretch;
  gap: var(--sp-4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility var(--dur-base);
}
.has-submenu:hover .mega-menu,
.has-submenu:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.nav-primary .mega-menu-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  align-content: start;
  flex: 1 1 0;
  min-width: 0;
}
.mega-menu-grid li { min-width: 0; opacity: 0; transform: translateY(6px); transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease); transition-delay: calc(var(--i, 0) * 25ms); }
.has-submenu:hover .mega-menu-grid li,
.has-submenu:focus-within .mega-menu-grid li { opacity: 1; transform: translateY(0); }
.mega-menu-grid a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--color-body);
}
.mega-menu-grid a::after { display: none; }
.mega-menu-grid a:hover { background: var(--color-surface-alt); }
.mega-menu-grid a > span:last-child { min-width: 0; }
.mega-menu-icon {
  flex: none;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--color-brand-light);
  color: var(--color-brand);
}
.mega-menu-icon svg { width: 17px; height: 17px; }
.mega-menu-grid strong { display: block; font-size: 0.85rem; font-weight: 600; color: var(--color-ink); line-height: 1.3; white-space: normal; }
.mega-menu-grid small { display: block; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--color-muted); margin-top: 2px; }
.mega-menu-grid a:hover strong { color: var(--color-brand); }

.mega-menu-feature {
  flex: 0 0 200px;
  background: linear-gradient(155deg, var(--color-navy), #1B2A66);
  border-radius: var(--radius-sm);
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  color: #fff;
}
.mega-menu-feature .eyebrow { background: rgba(255,255,255,0.14); color: #FFD9BE; }
.mega-menu-feature h4 { color: #fff; font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.mega-menu-feature p { font-size: 0.8125rem; color: #C7CBE0; margin-bottom: var(--sp-4); flex: 1; }
.mega-menu-feature .btn { font-size: 0.8125rem; padding: 0.7rem 1rem; }

.site-header .header-cta { display: none; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.nav-toggle svg { width: 20px; height: 20px; }

.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--color-surface);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
  overflow-y: auto;
}
.mobile-nav.is-open { transform: translateX(0); }
.mobile-nav .container { padding-block: var(--sp-5); }
.mobile-nav-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-6); }
.mobile-nav ul { list-style: none; padding: 0; display: flex; flex-direction: column; }
.mobile-nav > .container > ul > li { border-bottom: 1px solid var(--color-line-soft); }
.mobile-nav a { display: block; padding: var(--sp-4) 0; font-weight: 600; font-size: var(--fs-lg); font-family: var(--font-display); }
.mobile-nav-head .brand { display: flex; padding: 0; }
.mobile-nav .submenu-mobile { list-style: none; padding-left: var(--sp-4); display: none; }
.mobile-nav .submenu-mobile.is-open { display: block; }
.mobile-nav .submenu-mobile a { font-size: var(--fs-sm); font-weight: 500; padding: var(--sp-3) 0; color: var(--color-muted); }
.mobile-nav-toggle-btn { background: none; border: none; width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; }

@media (min-width: 1024px) {
  .nav-primary { display: block; }
  .site-header .header-cta { display: inline-flex; }
  .nav-toggle { display: none; }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-surface-navy);
  color: #C7CBE0;
  padding-block: var(--sp-10) var(--sp-6);
}
.footer-top {
  display: grid;
  gap: var(--sp-8);
  grid-template-columns: 1.4fr 1fr 1fr;
  padding-bottom: var(--sp-8);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.footer-brand img { height: 32px; margin-bottom: var(--sp-4); }
.footer-brand p { color: #A9AEC7; font-size: var(--fs-sm); max-width: 34ch; }
.footer-social { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); }
.footer-social a {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.08);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.footer-social a:hover { background: var(--color-brand); transform: translateY(-2px); }
.footer-social svg { width: 17px; height: 17px; }

.footer-col h4 { color: #fff; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-4); }
.footer-col ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.footer-col a, .footer-col p { color: #A9AEC7; font-size: var(--fs-sm); }
.footer-col a:hover { color: #fff; }
.footer-col address { font-style: normal; }

.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-3);
  padding-top: var(--sp-6);
  font-size: var(--fs-xs);
  color: #7B81A0;
}
.footer-bottom a { color: #7B81A0; }
.footer-bottom a:hover { color: #fff; }

@media (max-width: 860px) {
  .footer-top { grid-template-columns: 1fr; }
}

/* ---------- Botones flotantes (WhatsApp + volver arriba) ---------- */
.float-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}
.whatsapp-float {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: #25D366;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--dur-fast) var(--ease);
}
.whatsapp-float:hover { transform: scale(1.08); }
.whatsapp-float svg { width: 28px; height: 28px; fill: #fff; }

.back-to-top {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  color: var(--color-navy);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.9);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility var(--dur-base), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.back-to-top:hover { border-color: var(--color-brand); color: var(--color-brand); }
.back-to-top svg { width: 18px; height: 18px; }

/* ---------- Cursor personalizado ----------
   Solo se activa por JS (pointer:fine + sin reduced-motion) agregando
   ".custom-cursor" a <html>; hasta entonces el cursor nativo sigue
   funcionando con normalidad (mejora progresiva). */
html.custom-cursor,
html.custom-cursor a,
html.custom-cursor button,
html.custom-cursor input,
html.custom-cursor textarea,
html.custom-cursor [role="button"] {
  cursor: none !important;
}
/* mix-blend-mode:difference garantiza contraste sobre cualquier fondo
   (claro, oscuro, naranja) sin tener que adivinar el color de cada seccion */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  mix-blend-mode: difference;
  transition: opacity var(--dur-base) var(--ease), width var(--dur-base) var(--ease-spring), height var(--dur-base) var(--ease-spring);
  will-change: transform;
}
html.custom-cursor .cursor-dot,
html.custom-cursor .cursor-ring {
  opacity: 1;
}
.cursor-dot {
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
}
.cursor-ring {
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cursor-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-navy);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.cursor-ring.is-active {
  width: 60px; height: 60px;
  margin: -30px 0 0 -30px;
  background: #fff;
  border-color: #fff;
}
.cursor-ring.is-active .cursor-label { opacity: 1; }
.cursor-dot.is-hidden { opacity: 0; }

@media (hover: none), (pointer: coarse) {
  .cursor-dot, .cursor-ring { display: none; }
}
