/* ==========================================================================
   Header — Shell, Logo, CTA, Search, Sticky behaviour
   BEM: .jsf-header__*, state classes .jsf-header--*
   ========================================================================== */

.jsf-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  width: 100%;
  height: var(--header-height, 88px);
  background: var(--header-bg-color, transparent);
  border-bottom: 1px solid transparent;
  transition: background-color var(--transition), box-shadow var(--transition),
              backdrop-filter var(--transition), border-color var(--transition),
              height var(--transition);
}

/* Header is taken out of flow (fixed) so it overlaps the hero;
   this spacer pushes non-hero page content down by the header's
   height wherever a template doesn't want the overlap. */

.jsf-header-spacer {
  height: var(--header-height, 88px);
}

@media (max-width: 1024px) {
  .jsf-header-spacer {
    height: var(--header-height-mobile, 72px);
  }
}

.jsf-header--transparent:not(.jsf-header--is-stuck) {
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.jsf-header--is-stuck {
  background: var(--header-sticky-bg-color, rgba(255, 255, 255, .75));
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom-color: var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.jsf-header__inner {
  max-width: var(--header-container-width, var(--container-width));
  height: 100%;
  margin-inline: auto;
  padding-inline: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
}

/* ---------- Logo ---------- */

.jsf-header__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.jsf-header__logo .custom-logo-link {
  display: block;
}

.jsf-header__logo img {
  width: var(--header-logo-width, 160px);
  height: auto;
  max-height: calc(var(--header-height, 88px) - 24px);
  object-fit: contain;
  transition: width var(--transition);
}

/* Auto light/dark logo switch — only relevant when a Light Logo has
   been set in the Customizer, in which case both markups render into
   .jsf-header__logo side by side and visibility toggles on sticky state. */

.jsf-header__logo .jsf-header__logo-img.jsf-header__logo-img--light ~ .jsf-header__logo-img:not(.jsf-header__logo-img--light) {
  display: none;
}

.jsf-header--is-stuck .jsf-header__logo .jsf-header__logo-img--light {
  display: none;
}

.jsf-header--is-stuck .jsf-header__logo .jsf-header__logo-img--light ~ .jsf-header__logo-img:not(.jsf-header__logo-img--light) {
  display: block;
}

.jsf-header__site-title {
  font-family: var(--font-heading);
  font-size: var(--fs-h4);
  font-weight: var(--fw-extrabold);
  color: var(--color-heading);
  letter-spacing: var(--ls-tight);
}

/* ---------- Actions cluster (search + CTA + hamburger) ---------- */

.jsf-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.jsf-header__search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--color-heading);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.jsf-header__search-toggle svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  max-width: none;
}

.jsf-header__search-toggle:hover,
.jsf-header__search-toggle:focus-visible {
  background: var(--color-highlight);
  color: var(--color-primary);
}

.jsf-header__cta {
  padding: 14px 26px;
  font-size: var(--fs-body);
  gap: var(--space-xs);
}

.jsf-header__cta-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  max-width: none;
  transition: transform var(--transition-fast);
}

.jsf-header__cta:hover .jsf-header__cta-icon {
  transform: scale(1.1) rotate(-8deg);
}

/* ---------- Search popup ---------- */

.jsf-search-popup {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-2xl) var(--space-md);
}

.jsf-search-popup[hidden] { display: none; }

.jsf-search-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--transition);
}

.jsf-search-popup.is-visible .jsf-search-popup__backdrop {
  opacity: 1;
}

.jsf-search-popup__panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  padding: var(--space-lg);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-large);
  opacity: 0;
  transform: translateY(-16px) scale(.98);
  transition: opacity 300ms var(--ease-premium), transform 300ms var(--ease-premium);
}

.jsf-search-popup.is-visible .jsf-search-popup__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.jsf-search-popup__form {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-md);
}

.jsf-search-popup__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  max-width: none;
  color: var(--color-light);
}

.jsf-search-popup__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-body-lg);
  color: var(--color-heading);
  padding: var(--space-xs) 0;
}

.jsf-search-popup__input::placeholder {
  color: var(--color-light);
}

.jsf-search-popup__input:focus {
  box-shadow: none;
  outline: none;
}

.jsf-search-popup__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-white);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.jsf-search-popup__submit svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  max-width: none;
}

.jsf-search-popup__submit:hover,
.jsf-search-popup__submit:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

@media (max-width: 767px) {
  .jsf-search-popup {
    padding-top: var(--space-xl);
  }

  .jsf-search-popup__panel {
    padding: var(--space-md);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .jsf-header {
    height: var(--header-height-mobile, 72px);
  }

  .jsf-header__inner {
    padding-inline: var(--space-sm);
  }

  .jsf-header__cta {
    display: none;
  }

  .jsf-header__logo img {
    width: min(var(--header-logo-width, 160px), 140px);
  }
}

@media (max-width: 480px) {
  .jsf-header__logo img {
    width: 120px;
  }

  .jsf-header__actions {
    gap: var(--space-sm);
  }
}
