/* El header marca el ancho del contenedor: usa el mismo margen
   lateral (--edge) que el hero y el footer, en los dos estados. */
.site-header {
  position: fixed;
  z-index: 10;
  top: calc(var(--edge) + env(safe-area-inset-top));
  right: calc(var(--edge) + env(safe-area-inset-right));
  left: calc(var(--edge) + env(safe-area-inset-left));
  display: flex;
  padding: 10px 10px 10px 18px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #fff;
  transition: top .45s cubic-bezier(.16, 1, .3, 1), padding .45s cubic-bezier(.16, 1, .3, 1), background-color .35s ease, color .35s ease, border-color .35s ease;
}

.site-header.is-scrolled {
  border-color: rgba(19, 28, 122, .1);
  background: var(--color-surface);
  color: var(--color-text);
}

.wordmark {
  padding: 8px 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -.03em;
  text-decoration: none;
}

.site-header nav a {
  text-decoration: none;
}

/* Contacto siempre a un toque, en cualquier punto de la página. */
.header-cta {
  display: inline-flex;
  min-height: 40px;
  margin-left: auto;
  padding: 8px 16px;
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 10px;
  font-size: 0.9375rem;
  line-height: 1.2;
  letter-spacing: 0;
  text-decoration: none;
  transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}

.header-cta:hover {
  border-color: var(--star-yellow);
  background: var(--star-yellow);
  color: var(--night-deep);
}

.site-header.is-scrolled .header-cta {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.site-header.is-scrolled .header-cta:hover {
  border-color: var(--night-blue);
  background: var(--night-blue);
}

/* ---------- Móvil: menú desplegable ---------- */
.menu-button {
  display: flex;
  width: 44px;
  height: 44px;
  margin-left: 6px;
  padding: 0;
  gap: 7px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.menu-button span {
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}

.menu-button[aria-expanded="true"] span:first-child {
  transform: translateY(4.5px) rotate(45deg);
}

.menu-button[aria-expanded="true"] span:last-child {
  transform: translateY(-4.5px) rotate(-45deg);
}

.site-header nav {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: none;
  padding: 8px;
  flex-direction: column;
  border-radius: 14px;
  background: var(--night-deep);
  color: #fff;
  /* El menú es oscuro en los dos estados del header. */
  --color-focus: var(--star-yellow);
}

.site-header nav.is-open {
  display: flex;
}

.site-header nav a {
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 1.125rem;
  line-height: 1.2;
}

.site-header nav a:active {
  background: rgba(255, 255, 255, .1);
}

/* ---------- Escritorio: barra con enlaces ---------- */
@media (min-width: 768px) {
  .site-header {
    /* El panel llega de borde a borde; su contenido se alinea al
       contenedor (38 y 27px son la diferencia con el margen del texto). */
    padding: 30px max(clamp(24px, 3.5vw, 51px), calc(var(--gutter) - 27px)) 30px max(clamp(20px, 2.8vw, 40px), calc(var(--gutter) - 38px));
    border-radius: 16px;
  }

  /* Al hacer scroll baja y reduce su altura, pero no el ancho. */
  .site-header.is-scrolled {
    top: calc(20px + env(safe-area-inset-top));
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .wordmark {
    font-size: 1.8125rem;
  }

  .menu-button {
    display: none;
  }

  .site-header nav {
    position: static;
    display: flex;
    margin-left: auto;
    padding: 0;
    gap: clamp(18px, 2.9vw, 42px);
    flex-direction: row;
    border-radius: 0;
    background: none;
    color: inherit;
    text-transform: uppercase;
  }

  .site-header.is-scrolled nav {
    --color-focus: var(--starry-blue);
  }

  .site-header nav a {
    padding: 0;
    border-radius: 0;
    font-size: clamp(0.9375rem, 1.25vw, 1.125rem);
    letter-spacing: -.02em;
  }

  /* En escritorio el contacto es el botón, no un enlace más. */
  .site-header nav a[href="#contact"] {
    display: none;
  }

  .header-cta {
    margin-left: clamp(18px, 2.9vw, 42px);
    padding: 9px 20px;
    font-size: 1rem;
  }

  .site-header.is-scrolled .text-swap__character > span:last-child {
    color: var(--color-accent);
  }
}

/* Teléfono en horizontal: poca altura, así que la barra se adelgaza. */
@media (min-width: 768px) and (max-height: 520px) {
  .site-header,
  .site-header.is-scrolled {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}
