/* =========================
   VD · Custom Header
   Sostituisce l'header del parent theme Kadence. Hamburger 2-bars → X,
   sticky semplice, drawer-only navigation.
   ========================= */

.vd-header {
  --vd-header-bg: #4a5f6a;
  --vd-header-ink: #ededed;
  --vd-header-line: rgba(237, 237, 237, 0.16);
  --vd-header-pad-x: clamp(20px, 4vw, 56px);
  --vd-header-pad-y: clamp(12px, 1.6vw, 20px);
  --vd-header-toggle-offset-y: clamp(11px, calc(2.25vw - 7px), 21px);
  --vd-header-icon-ink: #ededed;
  --vd-header-icon-hover: #ff810a;
  --vd-header-icon-open: #ffffff;
  --vd-header-ease: ease;

  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--vd-header-bg);
  color: var(--vd-header-ink);
  border-bottom: 1px solid var(--vd-header-line);
}

/* WP admin bar quando loggato: l'header sta sotto la toolbar. */
body.admin-bar .vd-header { top: 32px; }
@media (max-width: 782px) {
  body.admin-bar .vd-header { top: 46px; }
}

body.vd-drawer-shell-active .vd-header {
  z-index: 100;
  pointer-events: none;
}

.vd-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--vd-header-pad-y) var(--vd-header-pad-x);
}

/* ═══ Brand / logo ═══ */

.vd-header__brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.vd-header__brand .custom-logo-link {
  display: inline-flex;
  align-items: center;
}

.vd-header__brand .custom-logo {
  max-height: clamp(36px, 4.5vw, 56px);
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  transition: none;
}

.vd-header__wordmark {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--vd-header-ink);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.25s var(--vd-header-ease);
}

.vd-header__brand:hover .custom-logo,
.vd-header__brand:focus-within .custom-logo {
  filter: brightness(0) saturate(100%) invert(58%) sepia(94%) saturate(2369%) hue-rotate(356deg) brightness(101%) contrast(103%);
}

.vd-header__wordmark:hover,
.vd-header__wordmark:focus-visible {
  color: var(--vd-header-icon-hover);
}

/* ═══ Hamburger toggle (2 bars → X) ═══ */

.vd-header__toggle {
  --vd-header-pad-x: clamp(20px, 4vw, 56px);
  --vd-header-pad-y: clamp(12px, 1.6vw, 20px);
  --vd-header-toggle-offset-y: clamp(11px, calc(2.25vw - 7px), 21px);
  --vd-header-icon-ink: #ededed;
  --vd-header-icon-hover: #ff810a;
  --vd-header-icon-open: #ffffff;
  --vd-header-ease: ease;

  position: relative;
  display: block;
  flex-shrink: 0;
  width: 30px;
  height: 14px;
  padding: 0;
  margin: 0;
  z-index: 200;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  color: inherit;
  appearance: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  box-shadow: none !important;
  outline: none;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  line-height: 0;
}

body .drawer-toggle.vd-header__toggle {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

.vd-header__toggle::before,
.vd-header__toggle::after {
  content: none !important;
  display: none !important;
}

.vd-header__toggle:focus,
.vd-header__toggle:active {
  background: transparent !important;
  box-shadow: none !important;
}

@media (min-width: 768px) {
  .vd-header__toggle {
    width: 50px;
  }
}

@media (pointer: fine) {
  .vd-header__toggle:hover .vd-header__bar {
    background-color: var(--vd-header-icon-hover);
  }
}

.vd-header__toggle:focus-visible {
  outline: 2px solid #ff810a;
  outline-offset: 3px;
}

/* Replica del trigger Alessandro Giammaria: due barre assolute dentro un
   bottone 30/50 × 14px. In apertura prima si chiudono verso il centro,
   poi ruotano in X grazie al delay su transform. */
.vd-header__bar {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--vd-header-icon-ink);
  border-radius: 0;
  transform-origin: center;
  transition: top 0.5s var(--vd-header-ease) 0.5s,
              bottom 0.5s var(--vd-header-ease) 0.5s,
              transform 0.5s var(--vd-header-ease),
              background-color 0.3s var(--vd-header-ease);
  will-change: transform, top, bottom;
}

.vd-header__bar--top {
  top: 0;
}

.vd-header__bar--bottom {
  bottom: 0;
}

body.vd-drawer-open .vd-header__bar {
  background-color: var(--vd-header-icon-open);
  transition: opacity 0.5s var(--vd-header-ease),
              top 0.5s var(--vd-header-ease),
              bottom 0.5s var(--vd-header-ease),
              transform 0.5s var(--vd-header-ease) 0.5s,
              background-color 0.3s var(--vd-header-ease);
}

body.vd-drawer-shell-active .vd-header__bar {
  background-color: var(--vd-header-icon-open);
}

body.vd-drawer-open .vd-header__bar--top {
  top: 6px;
  transform: rotate(-45deg);
}

body.vd-drawer-open .vd-header__bar--bottom {
  bottom: 6px;
  transform: rotate(45deg);
}

/* Quando il drawer si apre, vd-drawer.js sposta il toggle nel <body> (per
   uscire dallo stacking context dell'header sticky) e lo "pinna" via inline
   styles con `position: fixed; top/left/width/height` misurati con
   getBoundingClientRect → coordinate esatte, identiche al pixel a quelle
   che il bottone aveva nel flusso. NIENTE coordinate calcolate via clamp/calc
   qui: erano la causa dello scatto al click (formula CSS ≠ posizione reale,
   soprattutto su viewport > 1440px col `.vd-header__inner` centrato).
   Manteniamo solo lo z-index e il pointer-events. */
body.vd-drawer-shell-active .vd-header__toggle {
  pointer-events: auto;
}

@media (pointer: fine) {
  body.vd-drawer-shell-active .vd-header__toggle:hover .vd-header__bar {
    background-color: var(--vd-header-icon-open);
  }
}

/* ═══ Skip link (a11y) ═══ */

.skip-link.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link.screen-reader-text:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  margin: 0;
  padding: 10px 16px;
  clip: auto;
  overflow: visible;
  background: #ff810a;
  color: #ffffff;
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 4px;
  z-index: 100001;
}

/* ═══ Reduced motion ═══ */

@media (prefers-reduced-motion: reduce) {
  .vd-header__bar,
  .vd-header__toggle {
    transition-duration: 0.01ms;
    transition-delay: 0s;
  }

  body.vd-drawer-open .vd-header__bar {
    transition-duration: 0.01ms;
    transition-delay: 0s;
  }
}
