/* ============================================================
   HOMBRE ALFA — Header
   ============================================================ */

/* Elimina el header/footer heredados del tema padre (bloque
   wp:template-part) en plantillas de WooCommerce que no tienen
   una plantilla PHP propia (Tienda, producto individual). La
   cabecera/pie de página reales son los de hombrealfa_header()
   y hombrealfa_footer() en functions.php. */
header.wp-block-template-part,
footer.wp-block-template-part {
  display: none !important;
}

/* Espacio bajo la cabecera fija en páginas de WooCommerce sin
   plantilla PHP propia (Tienda, Producto, Carrito): su contenido
   empieza pegado arriba y choca con el header fijo. */
body.woocommerce-page main {
  padding-top: 130px;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  body.woocommerce-page main {
    padding-top: 90px;
  }
}

/* Corrige imágenes de producto desproporcionadas en grids de
   bloques de WooCommerce (relacionados, novedades, cross-sells) */
.wc-block-grid__product-image img,
.wp-block-woocommerce-product-image img,
ul.products li.product img,
.products img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  object-fit: cover !important;
}

/* ----- Base ----- */
.ha-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 1000;
  height: 108px;
  overflow: hidden;
  background: transparent;
  transition: background 200ms ease, backdrop-filter 200ms ease, box-shadow 200ms ease, transform 300ms ease;
  will-change: background;
}

.ha-header--scrolled {
  background: rgba(17, 17, 17, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--ha-hairline);
}

.ha-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 2rem;
  gap: 2rem;
}

/* ----- Logo ----- */
.ha-header__logo {
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ha-header .ha-header__logo-img {
  height: 84px;
  width: auto;
  display: block;
  border-radius: 0;
  object-fit: contain;
  background: transparent !important;
  background-color: transparent !important;
}

.ha-header__logo-text {
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #D9822B;
  line-height: 1;
}

.ha-header__logo-text sup {
  font-size: 0.55em;
  vertical-align: super;
  letter-spacing: 0;
}

/* ----- Nav desktop ----- */
.ha-header__nav {
  flex: 1;
  display: flex;
  justify-content: center;
}

.ha-header__nav-list {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ha-nav__link {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ha-text);
  text-decoration: none;
  border-radius: 2px;
  transition: color 150ms ease;
  white-space: nowrap;
}

.ha-nav__link:hover,
.ha-nav__link:focus-visible {
  color: var(--ha-amber);
  outline: none;
}

.ha-nav__link--accent {
  color: var(--ha-amber);
  border: 1px solid var(--ha-amber);
  padding: 4px 10px;
  border-radius: 2px;
  transition: background 150ms ease, color 150ms ease;
}

.ha-nav__link--accent:hover,
.ha-nav__link--accent:focus-visible {
  background: var(--ha-amber);
  color: var(--ha-text-on-amber);
  outline: none;
}

/* ----- Acciones ----- */
.ha-header__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.ha-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ha-text);
  border-radius: 4px;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}

.ha-action:hover,
.ha-action:focus-visible {
  color: var(--ha-amber);
  background: var(--ha-glow);
  outline: none;
}

.ha-icon {
  display: block;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

/* Carrito badge */
.ha-cart-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  background: var(--ha-amber);
  color: var(--ha-text-on-amber);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  pointer-events: none;
}

.ha-cart-badge[hidden] {
  display: none;
}

/* ----- Hamburguesa ----- */
.ha-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
}

.ha-hamburger__bar {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--ha-white);
  border-radius: 1px;
  transition: transform 220ms ease, opacity 150ms ease;
  transform-origin: center;
}

.ha-hamburger.is-open .ha-hamburger__bar:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.ha-hamburger.is-open .ha-hamburger__bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.ha-hamburger.is-open .ha-hamburger__bar:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ============================================================
   Overlay menú móvil
   ============================================================ */
.ha-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--ha-charcoal);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  visibility: hidden;
}

.ha-nav-overlay.is-open {
  transform: translateX(0);
  visibility: visible;
}

.ha-nav-overlay__backdrop {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: var(--ha-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.ha-nav-overlay__backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.ha-nav-overlay__inner {
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.5rem 3rem;
  height: 100%;
  overflow-y: auto;
}

.ha-nav-overlay__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ha-text);
  align-self: flex-end;
  margin-bottom: 2rem;
  border-radius: 4px;
  transition: color 150ms ease;
}

.ha-nav-overlay__close:hover { color: var(--ha-amber); }

.ha-nav-overlay__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ha-nav-overlay__link {
  display: block;
  padding: 1rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ha-text);
  text-decoration: none;
  border-bottom: 1px solid var(--ha-hairline);
  transition: color 150ms ease;
}

.ha-nav-overlay__link:hover,
.ha-nav-overlay__link:focus-visible {
  color: var(--ha-amber);
  outline: none;
}

.ha-nav-overlay__link--accent {
  color: var(--ha-amber);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .ha-header {
    height: 64px;
    min-height: unset;
    padding-top: 0;
    padding-bottom: 0;
  }

  .ha-header .ha-header__logo-img {
    height: 48px;
    width: auto;
  }

  .ha-header__logo-text {
    font-size: 11px;
  }

  .ha-header__inner {
    padding-inline: 1.25rem;
    gap: 1rem;
  }

  .ha-header__nav {
    display: none;
  }

  .ha-hamburger {
    display: inline-flex;
  }

  /* En móvil ocultar buscar y cuenta del header, dejarlos en overlay si se añaden */
  .ha-action:not(.ha-action--cart):not(.ha-hamburger) {
    display: none;
  }
}

@media (min-width: 901px) {
  .ha-hamburger {
    display: none;
  }
}

.ha-header--hidden {
  transform: translateY(-100%);
}

/* En móvil, ocultar por transform dejaba la cabecera "cortada a la
   mitad" en algunos dispositivos. Aquí se oculta de forma binaria
   (opacidad + visibilidad), sin desplazamiento, para que desaparezca
   por completo en cuanto se hace scroll hacia abajo. */
@media (max-width: 768px) {
  .ha-header {
    transform: none !important;
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease, visibility 0s linear 0s;
  }

  .ha-header--hidden {
    transform: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 0s linear 200ms;
  }
}

/* ----- Botón scroll-to-top (universal, todas las páginas) ----- */
#ha-scroll-top {
  display: flex;
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #D9822B;
  color: #fff;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease, background 150ms ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

#ha-scroll-top:hover {
  background: #E8963D;
}

/* Body offset para que el contenido no quede bajo el header */
body {
  padding-block-start: 0; /* El hero debe ir edge-to-edge; cada page template gestiona su propio padding */
}

/* Offset para la barra de administración de WordPress */
body.admin-bar .ha-header {
  top: 32px;
}
@media screen and (max-width: 782px) {
  body.admin-bar .ha-header {
    top: 46px;
  }
}
