/* ============================================================================
 * SeptiGenesis — Encabezado delgado de UNA sola fila (header.sg-hdr).
 *   Computador (>= 1024 px): 48 px · logo 30 px · enlaces al centro · sol/luna,
 *     chip de idioma (2 letras) y "Solicita una cotización" a la derecha.
 *   Celular y tableta (< 1024 px): 44 px · logo 26 px · cotizar (o su icono si
 *     no cabe) · menú. Idioma y sol/luna van dentro del menú desplegable.
 *   Al bajar se esconde (translateY(-100%)) y reaparece al subir: js/header.js.
 *   El alto NUNCA cambia: se mueve con transform, el contenido no salta.
 * header.sg-bar: páginas con su propio sistema de idiomas (agendar, legal, faq,
 *   encuesta, embajadores). Toman de aquí solo la barra pegajosa y el esconderse;
 *   su alto lo fija la hoja de cada página (<= 48 / 44 px).
 * ==========================================================================*/
:root { --sg-hdr-h: 48px; }
@media (max-width: 1023.98px) { :root { --sg-hdr-h: 44px; } }
/* Anclas: el destino queda por debajo de la barra (que además se fija visible al saltar). */
html { scroll-padding-top: calc(var(--sg-hdr-h) + 16px); }

/* ---------- Comportamiento común: pegajoso + esconderse al bajar ---------- */
body header.sg-hdr,
body header.sg-bar {
  position: sticky;
  top: 0;
  /* Sin transform mientras se ve: un transform volvería a la barra el bloque contenedor
     de los menús position:fixed (idioma en celular) y los descolocaría. */
  transition: transform .2s ease, box-shadow .2s ease;
}
body header.sg-hdr.sg-hdr--hidden,
body header.sg-bar.sg-hdr--hidden {
  transform: translateY(-100%);
  box-shadow: none;
}
@media (prefers-reduced-motion: reduce) {
  body header.sg-hdr,
  body header.sg-bar { transition: none; }
}

/* ---------- Barra ---------- */
body header.sg-hdr { padding: 0; z-index: 100; } /* sg-bar conserva el z-index de su página (sus modales van encima) */
body header.sg-hdr .header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.4vw, 20px);
  height: calc(var(--sg-hdr-h) - 1px); /* + 1 px del borde inferior = 48 / 44 */
  padding: 0;
  position: relative;
}
body header.sg-hdr .header-logo { flex-shrink: 0; display: flex; align-items: center; }
body header.sg-hdr .header-logo a { display: flex; align-items: center; }
body header.sg-hdr .header-logo img {
  display: block;
  height: 30px;
  max-height: 30px;
  width: auto;
  max-width: 120px;
  margin: 0;
  object-fit: contain;
}

/* Enlaces */
body header.sg-hdr .header-nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 26px);
}
body header.sg-hdr .header-nav > a,
body header.sg-hdr .sg-more > .nav-group-btn {
  white-space: nowrap;
  font-size: 0.88rem;
  line-height: 1.2;
  font-weight: var(--font-weight-medium, 500);
  color: var(--body-text-color, #3d4a57);
  text-decoration: none;
  padding: 6px 0;
}
body header.sg-hdr .header-nav > a:hover,
body header.sg-hdr .header-nav > a.active,
body header.sg-hdr .sg-more > .nav-group-btn:hover,
body header.sg-hdr .sg-more > .nav-group-btn[aria-expanded="true"] { color: var(--gcid-primary-text, #007a71); }
body header.sg-hdr .header-nav a:focus-visible,
body header.sg-hdr .nav-group-btn:focus-visible,
body header.sg-hdr .header-logo a:focus-visible {
  outline: 3px solid var(--gcid-primary-color, #00a99d);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Menú "Más" */
body header.sg-hdr .sg-more { position: relative; }
body header.sg-hdr .sg-more > .nav-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 0;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
}
body header.sg-hdr .sg-more .nav-caret { display: inline-flex; font-size: inherit; opacity: 1; transition: transform .18s ease; }
body header.sg-hdr .sg-more > .nav-group-btn[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }
body header.sg-hdr .sg-more > .nav-group-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  min-width: 210px;
  max-height: calc(100dvh - var(--sg-hdr-h) - 24px);
  overflow-y: auto;
  padding: 6px;
  background: var(--bg-white, #fff);
  border: 1px solid rgba(0, 169, 157, 0.18);
  border-radius: 14px;
  box-shadow: 0 18px 40px -20px rgba(20, 62, 107, 0.45);
  z-index: 300;
}
[dir="rtl"] body header.sg-hdr .sg-more > .nav-group-menu { transform: translateX(50%); }
body header.sg-hdr .sg-more > .nav-group-btn[aria-expanded="true"] + .nav-group-menu { display: block; }
body header.sg-hdr .sg-more .nav-group-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 9px;
  white-space: nowrap;
  font-size: 0.92rem;
  color: var(--body-text-color, #3d4a57);
  text-decoration: none;
}
body header.sg-hdr .sg-more .nav-group-menu a:hover,
body header.sg-hdr .sg-more .nav-group-menu a:focus-visible { background: rgba(0, 169, 157, 0.1); color: var(--gcid-primary-text, #007a71); outline-offset: -2px; }
body header.sg-hdr .sg-more .nav-group-menu a.active { color: var(--gcid-primary-text, #007a71); font-weight: 600; }

/* Derecha: día/noche · idioma · cotizar */
body header.sg-hdr .sg-hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}
body header.sg-hdr .sg-hdr-lang-home { display: flex; align-items: center; gap: 8px; }
body header.sg-hdr .sg-hdr-right .sg-theme { width: 32px; height: 32px; }
body header.sg-hdr #lang-switch { order: 0; flex-shrink: 0; }
body header.sg-hdr .sg-hdr-right .lang-btn { height: 32px; padding: 0 9px; gap: 5px; font-size: 0.8rem; }
body header.sg-hdr .lang-btn .lang-label { display: none; }
body header.sg-hdr .header-cta { flex-shrink: 1; min-width: 0; order: 0; display: flex; }
body header.sg-hdr .header-cta .sg-quote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 34px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 14px;
  font-size: 0.84rem;
  line-height: 1.2;
}
body header.sg-hdr .sg-quote .sg-quote-ico { display: none; width: 18px; height: 18px; flex-shrink: 0; }
body header.sg-hdr .nav-toggle { display: none; }

/* ---------- Celular y tableta ---------- */
@media (max-width: 1023.98px) {
  body header.sg-hdr .container { padding-left: 16px; padding-right: 16px; }
  body header.sg-hdr .header { gap: 8px; position: static; }
  body header.sg-hdr .header-logo img { height: 26px; max-height: 26px; max-width: 96px; }
  body header.sg-hdr .sg-hdr-right { margin-inline-start: auto; gap: 6px; }
  body header.sg-hdr .header-cta .sg-quote { height: 32px; padding: 0 12px; font-size: 0.78rem; }
  /* Cotizar no cabe (lo decide js/header.js midiendo): queda solo el icono, con su nombre accesible. */
  body header.sg-hdr.sg-hdr--cta-icon .header-cta .sg-quote { width: 40px; height: 40px; padding: 0; border-radius: 999px; }
  body header.sg-hdr.sg-hdr--cta-icon .sg-quote .sg-quote-ico { display: block; }
  body header.sg-hdr.sg-hdr--cta-icon .sg-quote .sg-quote-txt {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  body header.sg-hdr .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    order: 3;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    font-size: 1.5rem;
    border-radius: 10px;
  }
  body header.sg-hdr .nav-toggle:focus-visible { outline: 3px solid var(--gcid-primary-color, #00a99d); outline-offset: 1px; }
  body header.sg-hdr .header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    width: auto;
    order: 0;
    margin: 0;
    padding: 8px 16px 24px;
    background: var(--bg-white, #fff);
    border-top: 1px solid rgba(0, 169, 157, 0.15);
    box-shadow: 0 24px 40px -24px rgba(20, 62, 107, 0.45);
    max-height: calc(100dvh - var(--sg-hdr-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body header.sg-hdr .header-nav.mobile-open { display: flex; margin: 0; padding: 8px 16px 24px; }
  body header.sg-hdr .header-nav > a,
  body header.sg-hdr .sg-more .nav-group-menu a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 4px;
    font-size: 1rem;
    border-radius: 8px;
    white-space: normal;
  }
  body header.sg-hdr .sg-more > .nav-group-btn { display: none; }
  body header.sg-hdr .sg-more > .nav-group-menu {
    display: flex;
    flex-direction: column;
    position: static;
    transform: none;
    min-width: 0;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
  }
  /* Idioma y sol/luna dentro del menú: objetivos táctiles de 44 px. */
  body header.sg-hdr .sg-hdr-lang-slot {
    display: flex;
    padding: 12px 4px 0;
    margin-top: 6px;
    border-top: 1px solid rgba(0, 169, 157, 0.15);
  }
  body header.sg-hdr .sg-hdr-lang-slot .sg-hdr-lang-home { gap: 12px; flex-wrap: wrap; }
  body header.sg-hdr .sg-hdr-lang-slot .sg-theme { width: 44px; height: 44px; }
  body header.sg-hdr .sg-hdr-lang-slot .lang-btn { min-height: 44px; padding: 0 14px; font-size: 0.95rem; }
  body header.sg-hdr .sg-hdr-lang-slot .lang-btn .lang-label { display: inline; }
}

/* Enlace "saltar al contenido": fuera de pantalla por ARRIBA (no a un lado), para que en
   árabe (RTL) no cree desplazamiento horizontal. Al recibir foco vuelve a su sitio. */
.skip-link:not(:focus) { position: absolute; left: auto; right: auto; inset-inline-start: auto; top: -200px; }
