/* Header sticky + glass */

.ps-site-header-wrap {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 76px;
  max-height: 76px;
  margin: 0;
  background: transparent;
  overflow: visible;
  isolation: isolate;
}

.ps-site-header-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--ps-header-fill) 92%, transparent) 0%,
    color-mix(in srgb, var(--ps-header-fill) 72%, transparent) 100%
  );
  backdrop-filter: blur(24px) saturate(1.55);
  -webkit-backdrop-filter: blur(24px) saturate(1.55);
  border-bottom: 1px solid var(--ps-border);
  box-shadow:
    inset 0 1px 0 var(--ps-glass),
    0 8px 32px color-mix(in srgb, var(--ps-bg) 18%, transparent);
}

body.admin-bar .ps-site-header-wrap {
  top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar .ps-site-header-wrap {
    top: 46px;
  }
}

.ps-site-header {
  position: relative;
  width: 100%;
  height: 76px;
  z-index: 1;
  background: transparent;
  margin: 0;
}

.ps-site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1140px, calc(100% - 48px));
  height: 76px;
  margin: 0 auto;
}

.ps-site-header__logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none !important;
  z-index: 2;
}

.ps-site-header__logo-img {
  display: block;
  height: 46px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}

html[data-ps-scheme="dark"] .ps-site-header__logo-img--light,
html:not([data-ps-scheme]) .ps-site-header__logo-img--light,
body.pst-scheme-active-dark .ps-site-header__logo-img--light {
  display: none;
}

html[data-ps-scheme="light"] .ps-site-header__logo-img--dark,
body.pst-scheme-active-light .ps-site-header__logo-img--dark {
  display: none;
}

.ps-site-header__logo-text {
  color: var(--ps-heading);
  font-size: 16px;
  font-weight: 700;
}

.ps-site-header__toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--ps-heading);
  cursor: pointer;
  z-index: 2;
}

.ps-site-header__toggle-bars {
  position: relative;
  display: block;
  width: 22px;
  height: 16px;
}

.ps-site-header__toggle-bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition:
    top 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
}

.ps-site-header__toggle-bars span:nth-child(1) { top: 0; }
.ps-site-header__toggle-bars span:nth-child(2) { top: 7px; }
.ps-site-header__toggle-bars span:nth-child(3) { top: 14px; }

.ps-site-header.is-open .ps-site-header__toggle-bars span:nth-child(1) {
  top: 7px;
  transform: rotate(45deg);
}

.ps-site-header.is-open .ps-site-header__toggle-bars span:nth-child(2) {
  opacity: 0;
}

.ps-site-header.is-open .ps-site-header__toggle-bars span:nth-child(3) {
  top: 7px;
  transform: rotate(-45deg);
}

.ps-site-header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}

.ps-site-header__menu,
.ps-site-header__menu ul {
  list-style: none;
}

.ps-site-header__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.ps-site-header__menu > li {
  position: relative;
  list-style: none;
}

.ps-site-header__menu > li > a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  color: var(--ps-nav) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  white-space: nowrap;
}

.ps-site-header__menu > li.menu-item-has-children > a::after {
  content: "";
  width: 0;
  height: 0;
  margin-top: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.72;
}

/* Puente invisible: mantiene hover al bajar hacia el submenú */
.ps-site-header__menu > li.menu-item-has-children::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
}

.ps-site-header__menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: color-mix(in srgb, var(--ps-bg-soft) 94%, transparent);
  border: 1px solid var(--ps-border);
  border-radius: 14px;
  box-shadow:
    0 16px 40px color-mix(in srgb, var(--ps-bg) 28%, transparent),
    inset 0 1px 0 var(--ps-glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
  z-index: 30;
}

/* Segundo puente dentro del submenú (zona superior transparente) */
.ps-site-header__menu .sub-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -14px;
  height: 14px;
}

.ps-site-header__menu > li:hover > .sub-menu,
.ps-site-header__menu > li:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.ps-site-header__menu .sub-menu li {
  list-style: none;
}

.ps-site-header__menu .sub-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ps-nav) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  white-space: normal;
}

.ps-site-header__menu .sub-menu a:hover,
.ps-site-header__menu .sub-menu .current-menu-item > a,
.ps-site-header__menu .sub-menu .current_page_item > a {
  color: var(--ps-nav-hover) !important;
  background: color-mix(in srgb, var(--ps-primary) 10%, transparent);
}

.ps-site-header__menu > li > a:hover,
.ps-site-header__menu > li.current-menu-item > a,
.ps-site-header__menu > li.current_page_item > a {
  color: var(--ps-nav-hover) !important;
}

.ps-site-header__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--ps-accent) 72%, transparent);
  background: color-mix(in srgb, var(--ps-accent) 8%, transparent);
  color: var(--ps-cta-text) !important;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none !important;
}

.ps-site-header__cta:hover {
  background: color-mix(in srgb, var(--ps-accent) 18%, transparent);
  border-color: var(--ps-accent);
}

.ps-site-header__cta--mobile {
  display: none;
}

.ps-site-header__tools {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

.ps-theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ps-nav);
  cursor: pointer;
  line-height: 0;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.ps-theme-switch:hover {
  color: var(--ps-nav-hover);
  background: transparent;
}

.ps-theme-switch:focus {
  outline: none;
}

.ps-theme-switch:focus-visible {
  outline: 2px solid var(--ps-primary);
  outline-offset: 4px;
  border-radius: 2px;
}

.ps-theme-switch__icon {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: inherit;
}

.ps-theme-switch__icon svg {
  display: block;
  flex-shrink: 0;
}

.ps-theme-switch__icon .swp-icon-sun circle,
.ps-theme-switch__icon .swp-icon-sun path {
  fill: none;
  stroke: currentColor;
}

.ps-theme-switch__icon .swp-icon-moon path {
  fill: currentColor;
}

.ps-theme-switch[data-ps-active="dark"] .ps-theme-switch__icon--sun,
.ps-theme-switch[data-ps-active="light"] .ps-theme-switch__icon--moon {
  display: flex;
}

body.ps-nav-open {
  overflow: hidden;
}

@media (max-width: 1024px) {
  .ps-site-header-wrap {
    height: 68px;
    max-height: 68px;
    overflow: visible;
  }

  .ps-site-header,
  .ps-site-header.is-open {
    height: 68px;
    max-height: 68px;
    overflow: visible;
  }

  .ps-site-header__inner {
    height: 68px;
    min-height: 68px;
    max-height: 68px;
    width: calc(100% - 32px);
    overflow: visible;
  }

  .ps-site-header__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .ps-site-header__tools {
    margin-left: auto;
  }

  .ps-site-header__cta--desktop {
    display: none;
  }

  /* top lo define JS según la posición real del header */
  .ps-site-header__nav {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 20px 0;
    background: linear-gradient(
      180deg,
      color-mix(in srgb, var(--ps-header-fill) 94%, transparent) 0%,
      color-mix(in srgb, var(--ps-header-fill) 78%, transparent) 100%
    );
    border-bottom: 1px solid var(--ps-border);
    box-shadow: 0 24px 48px color-mix(in srgb, var(--ps-bg) 22%, transparent);
    backdrop-filter: blur(26px) saturate(1.45);
    -webkit-backdrop-filter: blur(26px) saturate(1.45);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-12px);
    z-index: 1001;
    transition:
      max-height 0.42s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.28s ease,
      transform 0.36s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.28s ease,
      padding 0.36s ease;
  }

  .ps-site-header.is-open .ps-site-header__nav {
    max-height: min(78vh, 560px);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    padding: 12px 20px 22px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ps-site-header__menu {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
  }

  .ps-site-header__menu > li {
    opacity: 0;
    transform: translateY(10px);
    transition:
      opacity 0.3s ease,
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .ps-site-header.is-open .ps-site-header__menu > li {
    opacity: 1;
    transform: translateY(0);
  }

  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(1) { transition-delay: 0.04s; }
  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(2) { transition-delay: 0.08s; }
  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(3) { transition-delay: 0.12s; }
  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(4) { transition-delay: 0.16s; }
  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(5) { transition-delay: 0.2s; }
  .ps-site-header.is-open .ps-site-header__menu > li:nth-child(6) { transition-delay: 0.24s; }

  .ps-site-header__menu > li > a {
    width: 100%;
    padding: 14px 12px !important;
    border-radius: 12px;
    color: var(--ps-heading) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    white-space: normal;
  }

  .ps-site-header__menu > li.menu-item-has-children > a::after {
    margin-left: auto;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
  }

  .ps-site-header__menu > li.menu-item-has-children.is-submenu-open > a::after {
    transform: rotate(180deg);
  }

  .ps-site-header__menu > li.menu-item-has-children::after {
    display: none;
  }

  .ps-site-header__menu .sub-menu::before {
    display: none;
  }

  .ps-site-header__menu .sub-menu {
    position: static;
    min-width: 0;
    margin: 0;
    padding: 0 0 0 8px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
  }

  .ps-site-header__menu > li.menu-item-has-children.is-submenu-open > .sub-menu {
    max-height: 480px;
    margin-top: 2px;
    margin-bottom: 4px;
  }

  .ps-site-header__menu .sub-menu a {
    padding: 12px 12px 12px 16px !important;
    font-size: 15px !important;
    color: var(--ps-muted) !important;
  }

  .ps-site-header__menu .sub-menu a:hover,
  .ps-site-header__menu .sub-menu .current-menu-item > a,
  .ps-site-header__menu .sub-menu .current_page_item > a {
    color: var(--ps-heading) !important;
    background: color-mix(in srgb, var(--ps-primary) 12%, transparent);
  }

  .ps-site-header__cta--mobile {
    display: inline-flex;
    margin-top: 8px;
    width: 100%;
    opacity: 0;
    transform: translateY(8px);
    transition:
      opacity 0.3s ease 0.12s,
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.12s,
      background 0.2s ease,
      border-color 0.2s ease;
  }

  .ps-site-header.is-open .ps-site-header__cta--mobile {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ps-site-header__toggle-bars span,
  .ps-site-header__nav,
  .ps-site-header__menu > li,
  .ps-site-header__cta--mobile {
    transition: none !important;
  }

  .ps-site-header__nav {
    transform: none !important;
  }

  .ps-site-header__menu > li,
  .ps-site-header__cta--mobile {
    opacity: 1;
    transform: none;
  }
}
