/* ==========================================================================
   Ensoul Nav v5.0.1 – Cavallerizza
   Header fixed + sticky on scroll-up, mix-blend-mode difference,
   contenuto sotto la barra
   ========================================================================== */

:root {
  --ensoul-modal-bg: #3B4A8C;
  --ensoul-color-border: rgba(255,255,255,0.15);
  --ensoul-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --ensoul-z-modal: 9999;
  --ensoul-z-header: 1000;
  --ensoul-header-h: 80px;
}

/* ==================================================================
   HEADER: fixed, full width, transparent, content goes underneath
   mix-blend-mode: difference on the header itself so logo+hamburger
   blend against page content (not against header's own bg)
   ================================================================== */
header.wp-block-template-part {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  max-width: 100vw !important;
  z-index: var(--ensoul-z-header);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent !important;
  box-sizing: border-box;
  pointer-events: none;
}

header.wp-block-template-part.header--hidden {
  transform: translateY(-100%);
}

/* ==================================================================
   HIDE original WP navigation + original WP logo
   ================================================================== */
header.wp-block-template-part .wp-block-navigation,
header.wp-block-template-part .wp-block-navigation *,
header.wp-block-template-part .wp-block-navigation__responsive-container,
header.wp-block-template-part .wp-block-navigation__responsive-container *,
header.wp-block-template-part .wp-block-site-logo,
header.wp-block-template-part .custom-logo-link,
header.wp-block-template-part .custom-logo {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  clip: rect(0,0,0,0) !important;
}

/* ==================================================================
   CUSTOM LOGO – fixed, independent stacking context
   difference only on dark backgrounds (toggled via JS)
   ================================================================== */
.ensoul-nav-custom-logo-link {
  position: fixed;
  top: 30px;
  left: clamp(30px, 5vw, 80px);
  z-index: calc(var(--ensoul-z-header) + 1);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.3s ease;
}

/* When logo is over a dark section, invert it */
.ensoul-nav-custom-logo-link.ensoul-logo--invert {
  filter: brightness(0) invert(1);
}

.ensoul-nav-custom-logo {
  display: block;
  width: 200px;
  height: auto;
}

/* Hide logo when header is hidden */
body.ensoul-header-hidden .ensoul-nav-custom-logo-link {
  transform: translateY(-200%);
}

/* ==================================================================
   HAMBURGER – fixed, independent stacking context, difference
   ================================================================== */
.ensoul-hamburger {
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  position: fixed !important;
  top: 42px;
  right: clamp(30px, 5vw, 80px);
  z-index: calc(var(--ensoul-z-header) + 1);
  mix-blend-mode: difference;
  color: #ffffff !important;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide hamburger when header is hidden */
body.ensoul-header-hidden .ensoul-hamburger {
  transform: translateY(calc(-100% - 50px));
}

.ensoul-hamburger__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--ensoul-transition), opacity var(--ensoul-transition);
  transform-origin: center;
}

.ensoul-hamburger[aria-expanded="true"] .ensoul-hamburger__bar:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}
.ensoul-hamburger[aria-expanded="true"] .ensoul-hamburger__bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.ensoul-hamburger[aria-expanded="true"] .ensoul-hamburger__bar:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

body.ensoul-nav-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

/* ==================================================================
   OVERLAY
   ================================================================== */
.ensoul-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--ensoul-z-modal) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ensoul-transition), visibility var(--ensoul-transition);
}
.ensoul-nav-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* ==================================================================
   MODALE
   ================================================================== */
.ensoul-nav-modal {
  position: fixed;
  z-index: var(--ensoul-z-modal);
  background: var(--ensoul-modal-bg);
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--ensoul-header-h);
  padding-bottom: 3rem;
  transform: translateY(-100%);
  transition: transform var(--ensoul-transition);
  display: flex;
  align-items: center;
  scrollbar-width: none;
  box-sizing: border-box;
}
.ensoul-nav-modal::-webkit-scrollbar {
  display: none;
}

/* Background image (set via inline --ensoul-modal-bg-image) */
.ensoul-nav-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--ensoul-modal-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.ensoul-nav-modal__inner {
  position: relative;
  z-index: 1;
}

.ensoul-nav-modal.is-open {
  transform: translateY(0);
}

.ensoul-nav-close { display: none; }
.ensoul-nav-modal__site-title { display: none; }

/* Inner: layout con label MENU a sinistra e voci centrate */
.ensoul-nav-modal__inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem clamp(30px, 5vw, 80px) 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 6rem);
}

/* ==================================================================
   LABEL "MENU" – lato sinistro, verticale
   ================================================================== */
.ensoul-nav-label {
  font-family: "New Title", "NewTitle", sans-serif;
  font-weight: 200;
  font-size: clamp(3rem, 6vw, 5rem);
  text-transform: uppercase;
  color: #ffffff;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  letter-spacing: 0.05em;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}

/* ==================================================================
   CLOSE BUTTON (X) – top right
   ================================================================== */
.ensoul-nav-close-btn {
  position: fixed;
  top: 2rem;
  right: 2.5rem;
  z-index: calc(var(--ensoul-z-modal) + 10);
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: none;
}
body.ensoul-nav-open .ensoul-nav-close-btn {
  display: block;
}
.ensoul-nav-close-btn::before,
.ensoul-nav-close-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
}
.ensoul-nav-close-btn::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.ensoul-nav-close-btn::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
.ensoul-nav-close-btn:hover::before,
.ensoul-nav-close-btn:hover::after {
  background: rgba(255,255,255,0.7);
}

/* ==================================================================
   STAGGER
   ================================================================== */
.ensoul-nav-list--root > .ensoul-nav-item {
  opacity: 0;
  transform: translateY(15px);
}
.ensoul-nav-modal.is-open .ensoul-nav-list--root > .ensoul-nav-item {
  animation: ensoul-stagger-in 0.4s ease forwards;
  animation-delay: calc(0.06s * var(--stagger-i, 0));
}
@keyframes ensoul-stagger-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ==================================================================
   LISTE, LINK, TOGGLE
   ================================================================== */
.ensoul-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Voci root: New Title, grandi, uppercase */
.ensoul-nav-list--root > .ensoul-nav-item > .ensoul-nav-link,
.ensoul-nav-list--root > .ensoul-nav-item > .ensoul-nav-toggle {
  font-family: "New Title", "NewTitle", sans-serif;
  font-weight: 500;
  font-size: clamp(1.8rem, 3.5vw, 5rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.ensoul-nav-link,
.ensoul-nav-toggle {
  text-decoration: none;
  color: #ffffff;
  font-family: "Host Grotesk", "HostGrotesk", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ensoul-nav-link:hover,
.ensoul-nav-link:focus-visible,
.ensoul-nav-toggle:hover,
.ensoul-nav-toggle:focus-visible {
  color: rgba(255,255,255,0.7);
}

/* Sottovoci: Host Grotesk, piu piccole */
.ensoul-nav-list--sub .ensoul-nav-link {
  font-family: "Host Grotesk", "HostGrotesk", sans-serif;
  color: rgba(255,255,255,0.8);
  font-size: clamp(0.95rem, 1.2vw, 1.1rem);
  font-weight: 400;
}

.ensoul-nav-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-weight: 700;
  text-align: left;
}

/* Nascondo il triangolo — le sottovoci appaiono sotto con accordion */
.ensoul-nav-toggle::after {
  display: none;
}

.ensoul-nav-toggle__icon { display: none !important; }

.ensoul-nav-list--root > .ensoul-nav-item {
  padding: 0.4rem 0;
}

/* ==================================================================
   SOTTOVOCI – accordion (sotto la voce padre, sia desktop che mobile)
   ================================================================== */
.ensoul-nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.ensoul-nav-list--sub {
  padding: 0.3rem 0 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ensoul-nav-list--sub .ensoul-nav-link {
  padding: 0.25rem 0;
}

/* ==================================================================
   DESKTOP (>= 768px)
   ================================================================== */
@media (min-width: 768px) {
  .ensoul-nav-list--root {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
}

/* ==================================================================
   MOBILE (< 768px)
   ================================================================== */
@media (max-width: 767px) {
  /* Logo: 50% smaller and aligned with body text via theme variable */
  .ensoul-nav-custom-logo {
    width: 100px;
  }
  .ensoul-nav-custom-logo-link {
    left: 23px;
    top: 20px;
  }
  .ensoul-hamburger {
    top: 26px;
    right: var(--spacing-content-padding-left, 30px);
  }

  .ensoul-nav-modal {
    transform: translateX(-100%);
  }
  .ensoul-nav-modal.is-open {
    transform: translateX(0);
  }

  .ensoul-nav-modal__inner {
    padding: 1.5rem 20px 2rem;
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* MENU label: orizzontale su mobile */
  .ensoul-nav-label {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .ensoul-nav-list--root {
    display: flex;
    flex-direction: column;
  }

  .ensoul-nav-item {
    border-bottom: 1px solid var(--ensoul-color-border);
  }
  .ensoul-nav-list--sub .ensoul-nav-item {
    border-bottom: none;
  }

  .ensoul-nav-toggle,
  .ensoul-nav-list--root > .ensoul-nav-item > .ensoul-nav-link {
    padding: 0.8rem 0;
  }
}

/* ==================================================================
   Accessibilita
   ================================================================== */
.ensoul-hamburger:focus,
.ensoul-hamburger:focus-visible {
  outline: none;
  box-shadow: none;
  border: none;
}

.ensoul-nav-toggle:focus-visible,
.ensoul-nav-link:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-radius: 3px;
}

.ensoul-nav-close-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
  border-radius: 3px;
}
