/* =====================================================
   HEADER — CSS v2
   Archivo: assets/header.css
   Carga global en todas las páginas (ver functions.php)
   ===================================================== */

/* ── Design tokens ─────────────────────────────────── */
:root {
  --header-height:    64px;
  --header-bg:        #0A0A0A;
  --header-border:    rgba(255, 255, 255, 0.06);
  --nav-link:         rgba(255, 255, 255, 0.60);
  --nav-link-hover:   #F0EDE6;
  --nav-link-active:  #F0EDE6;
  --orange:           #FF6A00;
  --mobile-divider:   rgba(255, 255, 255, 0.06);
  --hamburger-white:  #F0EDE6;
  --hamburger-orange: #FF6A00;
}

/* =====================================================
   SKIP LINK
   ===================================================== */
.py-skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--orange);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  z-index: 9999;
  transition: top 150ms;
}

.py-skip-link:focus { top: 0; }

/* =====================================================
   HEADER BASE
   ===================================================== */
.py-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--header-bg);
  border-bottom: 0.5px solid var(--header-border);
  transition: background 250ms, backdrop-filter 250ms;
}

/* Efecto blur al hacer scroll — JS añade .is-scrolled */
.py-header.is-scrolled {
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Compensar header fijo en el body */
body { padding-top: var(--header-height); }

/* Páginas con hero que queda bajo el header (home, landings de servicio)
   JS o body_class() añade .has-hero-overlap al <body> */
.has-hero-overlap { padding-top: 0; }

/* =====================================================
   CONTAINER
   ===================================================== */
.py-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 40px;
}

/* =====================================================
   INNER — GRID 3 COLUMNAS
   Clave del centrado matemático del nav:
   1fr (logo) | auto (nav) | 1fr (right)
   El nav queda centrado respecto al viewport,
   no respecto al espacio entre logo y CTA.
   ===================================================== */
.py-header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--header-height);
}

.py-header__logo  { justify-self: start; }
.py-nav           { justify-self: center; }
.py-header__right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* =====================================================
   LOGO
   ===================================================== */
.py-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.py-brand__logo {
  display: block;
  width: 63px;
  height: 14px;
  object-fit: contain;
}

/* Fallback texto cuando la imagen no carga */
.py-brand__fallback {
  font-size: 14px;
  font-weight: 500;
  color: #F0EDE6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* La "Y" en naranja — referencia al isotipo */
.py-brand__fallback-y { color: var(--orange); }

/* =====================================================
   NAV DESKTOP — links con hover subrayado naranja
   ===================================================== */
.py-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

/* Links del nav — generados por wp_nav_menu() + Pylaris_Nav_Walker */
.py-nav a {
  font-size: 12px;
  color: var(--nav-link);
  text-decoration: none;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
  position: relative;
  padding-bottom: 3px;           /* espacio para el subrayado */
  transition: color 150ms;
}

/* Subrayado naranja — oculto por defecto, animado */
.py-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: var(--orange);
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover: texto blanco + subrayado aparece de izquierda a derecha */
.py-nav a:hover               { color: var(--nav-link-hover); }
.py-nav a:hover::after        { transform: scaleX(1); }

/* Página activa — WordPress añade .current-menu-item */
.py-nav a.current-menu-item,
.py-nav a[aria-current="page"] {
  color: var(--nav-link-active);
  font-weight: 500;
}

.py-nav a.current-menu-item::after,
.py-nav a[aria-current="page"]::after {
  transform: scaleX(1);          /* subrayado siempre visible */
}

/* CTA mobile dentro del nav — oculto en desktop */
.py-nav__cta-mobile { display: none; }

/* =====================================================
   CTA BOTÓN "HABLEMOS"
   ===================================================== */
.btn-header {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
  transition: background 200ms;
  flex-shrink: 0;
  font-family: inherit;
}

.btn-header:hover  { background: #e55f2e; }
.btn-header:active { transform: scale(0.98); }

/* Full width — para el CTA dentro del menú mobile */
.btn-header--full {
  display: block;
  text-align: center;
  font-size: 14px;
  padding: 13px;
}

/* =====================================================
   TOGGLE — SIN fondo, SIN borde
   ===================================================== */
.py-menu-toggle {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* Focus visible solo al navegar con teclado */
.py-menu-toggle:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 4px;
  border-radius: 3px;
}

/* =====================================================
   HAMBURGUESA — 4 barras
   Cerrado: 4 barras horizontales (3 blancas + 1 naranja)
   Abierto:  4 barras verticales  (3 blancas + 1 naranja)
   La transición horizontal → vertical referencia el isotipo Pylaris.
   ===================================================== */
.py-hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 22px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Barras — estado CERRADO: horizontales */
.py-hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 1px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.py-hamburger-line:nth-child(1) { background: var(--hamburger-white); }
.py-hamburger-line:nth-child(2) { background: var(--hamburger-white); }
.py-hamburger-line:nth-child(3) { background: var(--hamburger-white); }
.py-hamburger-line:nth-child(4) { background: var(--hamburger-orange); }

/* Estado ABIERTO — barras verticales (JS añade .is-open) */
.py-hamburger.is-open {
  flex-direction: row;
  align-items: flex-end;
  gap: 4px;
  width: 22px;
}

.py-hamburger.is-open .py-hamburger-line {
  width: 2px;
  height: 22px;
}

/* Colores se mantienen en vertical */
.py-hamburger.is-open .py-hamburger-line:nth-child(1) { background: var(--hamburger-white); }
.py-hamburger.is-open .py-hamburger-line:nth-child(2) { background: var(--hamburger-white); }
.py-hamburger.is-open .py-hamburger-line:nth-child(3) { background: var(--hamburger-white); }
.py-hamburger.is-open .py-hamburger-line:nth-child(4) { background: var(--hamburger-orange); }

/* =====================================================
   RESPONSIVE — MOBILE <1024px
   ===================================================== */
@media (max-width: 1023px) {

  /* Container más estrecho en mobile */
  .py-container { padding: 0 20px; }

  /* Grid: 2 columnas en mobile (logo + right) */
  .py-header__inner {
    grid-template-columns: auto 1fr;
    height: 60px;
  }

  /* Logo: primera columna */
  .py-header__logo { grid-column: 1; }

  /* Nav: sale del grid, se posiciona fixed debajo del header */
  .py-nav {
    position: fixed;
	width: 100%;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--header-bg);
    border-top: 0.5px solid var(--mobile-divider);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 20px 28px;
    /* Animación de apertura — max-height es animable, display no */
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transition: max-height 350ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 250ms ease,
                visibility 350ms;
  }

  /* Nav abierto — JS añade .is-open */
  .py-nav.is-open {
    max-height: 100dvh;            /* dynamic viewport height — correcto en iOS */
    visibility: visible;
    opacity: 1;
    overflow-y: auto;
  }

  /* Right: solo el toggle en mobile */
  .py-header__right {
    grid-column: 2;
    justify-self: end;
  }

  /* Ocultar CTA en mobile */
  .py-desktop-only { display: none !important; }

  /* Mostrar toggle en mobile */
  .py-mobile-only { display: flex !important; }

  /* Links en mobile: más grandes, con separador */
  .py-nav a {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.60);
    padding: 12px 0;
    border-bottom: 0.5px solid var(--mobile-divider);
    display: block;
  }

  /* Sin subrayado animado en mobile */
  .py-nav a::after { display: none; }

  /* Último link antes del CTA — sin borde inferior */
  .py-nav a:last-of-type { border-bottom: none; }

  .py-nav a:hover,
  .py-nav a.current-menu-item,
  .py-nav a[aria-current="page"] { color: #F0EDE6; }

  /* CTA al final del menú mobile — visible */
  .py-nav__cta-mobile {
    display: block;
    margin-top: 20px;
  }
}

/* Desktop: ocultar toggle, mostrar CTA */
@media (min-width: 1024px) {
  .py-mobile-only      { display: none !important; }
  .py-desktop-only     { display: inline-block !important; }
  .py-nav__cta-mobile  { display: none !important; }
}
