/**
 * Birra Nobile — navbar Astra ispirata ai nodi Figma 33:2913 (desktop)
 * e 291:2122 (mobile).
 * Il CSS mantiene markup, menu, Search, Account e widget gestiti da Astra.
 */

#masthead {
  --bn-nav-bg: rgba(30, 30, 30, 0.7);
  --bn-nav-text: #fff;
  --bn-nav-active: #b8a914;
  --bn-nav-radius: 10px;
  --bn-nav-height: 122px;
  --bn-nav-panel-gap: 30px;
  --bn-nav-actions-width: 280px;
  /*
   * ICONE PERSONALIZZABILI
   * Sostituire soltanto l'URL tra parentesi con quello di un proprio SVG.
   * Le icone vengono usate come mask e assumono automaticamente il colore CSS.
   */
  --bn-avatar-icon: url("https://birranobile.it/wp-content/uploads/2026/08/profile-birranobile.svg");
  --bn-cart-icon: url("https://birranobile.it/wp-content/uploads/2026/08/cart-birranobile.svg");
  position: relative;
  z-index: 1000;
  width: 100%;
  background: transparent;
}

#masthead,
#masthead * {
  box-sizing: border-box;
}

/*
 * Solo le pagine che iniziano con una Cover usano la navbar sovrapposta.
 * Shop, prodotto, carrello e checkout mantengono invece l'header nel flusso.
 */
body.home #masthead,
body.page-id-243 #masthead,
body.page-id-295 #masthead {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

/* Estende automaticamente il comportamento alle future pagine con hero. */
@supports selector(body:has(.entry-content)) {
  body.page:not(.woocommerce-page):has(.entry-content > .wp-block-cover:first-child) #masthead {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
  }
}

body.admin-bar.home #masthead,
body.admin-bar.page-id-243 #masthead,
body.admin-bar.page-id-295 #masthead {
  top: 32px;
}

@supports selector(body:has(.entry-content)) {
  body.admin-bar.page:not(.woocommerce-page):has(.entry-content > .wp-block-cover:first-child) #masthead {
    top: 32px;
  }
}

/* Desktop: pannello principale + pannello azioni separato. */
@media (min-width: 922px) {
  #masthead #ast-desktop-header,
  #masthead #ast-desktop-header .ast-main-header-wrap,
  #masthead #ast-desktop-header .ast-primary-header-bar {
    min-height: var(--bn-nav-height);
    border: 0;
    background: transparent;
  }

  #masthead #ast-desktop-header .site-primary-header-wrap {
    width: min(1200px, calc(100% - 48px));
    max-width: 1200px;
    min-height: var(--bn-nav-height);
    margin-inline: auto;
    padding: 0;
  }

  #masthead #ast-desktop-header .ast-builder-grid-row {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 0;
    width: 100%;
    min-height: var(--bn-nav-height);
  }

  #masthead #ast-desktop-header .ast-builder-grid-row::before,
  #masthead #ast-desktop-header .ast-builder-grid-row::after {
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    border-radius: var(--bn-nav-radius);
    background: var(--bn-nav-bg);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    content: "";
  }

  #masthead #ast-desktop-header .ast-builder-grid-row::before {
    left: 0;
    right: calc(var(--bn-nav-actions-width) + var(--bn-nav-panel-gap));
  }

  #masthead #ast-desktop-header .ast-builder-grid-row::after {
    right: 0;
    width: var(--bn-nav-actions-width);
  }

  #masthead #ast-desktop-header .site-header-primary-section-left,
  #masthead #ast-desktop-header .site-header-primary-section-right {
    position: relative;
    min-width: 0;
    min-height: var(--bn-nav-height);
    background: transparent;
  }

  #masthead #ast-desktop-header .site-header-primary-section-left {
    width: 104px;
    padding: 26px 0 26px 40px;
    align-items: center;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--bn-nav-actions-width);
    grid-template-rows: var(--bn-nav-height);
    column-gap: var(--bn-nav-panel-gap);
    padding: 0;
    align-items: center;
  }

  #masthead #ast-desktop-header .site-branding,
  #masthead #ast-desktop-header .ast-site-identity,
  #masthead #ast-desktop-header .site-logo-img,
  #masthead #ast-desktop-header .custom-logo-link {
    display: block;
    width: 64px;
    height: 70px;
    margin: 0;
    padding: 0;
  }

  #masthead #ast-desktop-header .custom-logo {
    display: block;
    width: 64px;
    height: 70px;
    max-width: none;
    object-fit: contain;
  }

  #masthead #ast-desktop-header .ast-builder-menu-1 {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    min-width: 0;
    margin: 0 40px 0 0;
  }

  #masthead #ast-desktop-header .main-header-bar-navigation,
  #masthead #ast-desktop-header .site-navigation,
  #masthead #ast-desktop-header .main-navigation,
  #masthead #ast-desktop-header .main-header-menu {
    width: auto;
    min-height: 0;
  }

  #masthead #ast-desktop-header .main-header-menu {
    display: flex;
    height: auto;
    align-items: center;
    gap: 30px;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item {
    flex: 0 0 auto;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item > .menu-link {
    position: relative;
    display: flex;
    height: auto;
    min-height: 42px;
    padding: 10px 0;
    align-items: center;
    background: transparent;
    color: var(--bn-nav-text);
    font-family: "Avenir Next", Avenir, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: normal;
    text-transform: none;
    transition: color 180ms ease;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item > .menu-link::after {
    position: absolute;
    right: 0;
    bottom: 5px;
    left: 0;
    height: 1px;
    background: currentColor;
    content: "";
    opacity: 0;
    transform: scaleX(0.4);
    transform-origin: center;
    transition: opacity 180ms ease, transform 180ms ease;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item:hover > .menu-link,
  #masthead #ast-desktop-header .main-header-menu > .menu-item > .menu-link:focus-visible {
    color: var(--bn-nav-active);
    outline: none;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item:hover > .menu-link::after,
  #masthead #ast-desktop-header .main-header-menu > .menu-item > .menu-link:focus-visible::after {
    opacity: 0.7;
    transform: scaleX(1);
  }

  #masthead #ast-desktop-header .main-header-menu > .current-menu-item > .menu-link,
  #masthead #ast-desktop-header .main-header-menu > .current_page_item > .menu-link,
  #masthead #ast-desktop-header .main-header-menu > .current-menu-ancestor > .menu-link {
    color: var(--bn-nav-active);
    font-weight: 700;
  }

  /* Search, Account, Carrello e gli altri elementi aggiunti dall'Header Builder. */
  #masthead #ast-desktop-header .site-header-primary-section-right > .ast-builder-layout-element:not(.ast-builder-menu-1),
  #masthead #ast-desktop-header .site-header-primary-section-right > .header-widget-area {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right > .ast-builder-layout-element[data-section*="search"] {
    justify-self: start;
    margin-left: 40px;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right > .ast-builder-layout-element[data-section*="account"] {
    justify-self: center;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right > .header-widget-area {
    justify-self: end;
    margin-right: 40px;
  }

  #masthead #ast-desktop-header .ast-header-search,
  #masthead #ast-desktop-header .ast-header-account,
  #masthead #ast-desktop-header .ast-builder-layout-element[data-section*="search"],
  #masthead #ast-desktop-header .ast-builder-layout-element[data-section*="account"] {
    display: grid;
    width: 42px;
    height: 42px;
    min-width: 42px;
    margin: 0;
    padding: 0;
    place-items: center;
    border-radius: 8px;
    color: #fff;
  }

  #masthead #ast-desktop-header .ast-header-search svg,
  #masthead #ast-desktop-header .ast-header-account svg,
  #masthead #ast-desktop-header .ast-builder-layout-element[data-section*="search"] svg,
  #masthead #ast-desktop-header .ast-builder-layout-element[data-section*="account"] svg {
    width: 24px;
    height: 24px;
    color: currentColor;
    fill: none;
    stroke: currentColor;
  }

  #masthead #ast-desktop-header .header-widget-area,
  #masthead #ast-desktop-header .header-widget-area > .widget,
  #masthead #ast-desktop-header .header-widget-area > .widget > p {
    margin: 0;
    padding: 0;
  }

  #masthead #ast-desktop-header .header-widget-area > .widget > p:empty {
    display: none;
  }
}

/* Carrello del plugin Packaging: stessa geometria del componente Bag Figma. */
#masthead .bn-packaging-cart-trigger {
  display: inline-flex;
  min-width: 0;
  width: auto;
  height: 42px;
  min-height: 42px;
  margin: 0;
  padding: 0 9px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  box-shadow: none;
}

#masthead .bn-packaging-cart-trigger:hover,
#masthead .bn-packaging-cart-trigger:focus-visible {
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

#masthead .bn-packaging-cart-trigger svg {
  display: none;
}

#masthead .bn-packaging-cart-trigger::before {
  display: block;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  background: currentColor;
  content: "";
  -webkit-mask: var(--bn-cart-icon) center / contain no-repeat;
  mask: var(--bn-cart-icon) center / contain no-repeat;
}

#masthead .bn-packaging-cart-trigger__label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#masthead .bn-packaging-cart-trigger__count {
  position: static;
  display: grid;
  width: 24px;
  min-width: 24px;
  height: 24px;
  margin: 0;
  padding: 1px 6px;
  place-items: center;
  border: 0;
  border-radius: 100px;
  background: #fff;
  color: #1e1e1e;
  font-family: Futura, "Avenir Next", sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

/*
 * Icona account lineare: sostituisce visivamente il pittogramma pieno di Astra
 * mantenendo invariati link, area cliccabile e testo accessibile.
 */
#masthead .ast-header-account-link.ast-header-account-type-icon {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: #fff;
}

#masthead .ast-header-account-link.ast-header-account-type-icon > .ahfb-svg-iconset {
  display: none;
}

#masthead .ast-header-account-link.ast-header-account-type-icon::before {
  display: block;
  width: 24px;
  height: 24px;
  background: currentColor;
  content: "";
  -webkit-mask: var(--bn-avatar-icon) center / contain no-repeat;
  mask: var(--bn-avatar-icon) center / contain no-repeat;
}

/* Dropdown desktop coerenti con il pannello principale. */
#masthead #ast-desktop-header .main-header-menu .sub-menu {
  margin-top: 8px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(30, 30, 30, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

#masthead #ast-desktop-header .main-header-menu .sub-menu .menu-link {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #fff;
  font-family: "Avenir Next", Avenir, sans-serif;
  font-size: 14px;
}

#masthead #ast-desktop-header .main-header-menu .sub-menu .menu-link:hover,
#masthead #ast-desktop-header .main-header-menu .sub-menu .menu-link:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bn-nav-active);
}

/* Desktop intermedio: conserva i due pannelli senza comprimere il menu. */
@media (min-width: 922px) and (max-width: 1120px) {
  #masthead {
    --bn-nav-panel-gap: 20px;
    --bn-nav-actions-width: 220px;
  }

  #masthead #ast-desktop-header .site-primary-header-wrap {
    width: calc(100% - 32px);
  }

  #masthead #ast-desktop-header .ast-builder-grid-row {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  #masthead #ast-desktop-header .site-header-primary-section-left {
    width: 88px;
    padding-left: 24px;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right {
    padding: 0;
  }

  #masthead #ast-desktop-header .ast-builder-menu-1 {
    margin-right: 24px;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right > .ast-builder-layout-element[data-section*="search"] {
    margin-left: 24px;
  }

  #masthead #ast-desktop-header .site-header-primary-section-right > .header-widget-area {
    margin-right: 24px;
  }

  #masthead #ast-desktop-header .main-header-menu {
    gap: 18px;
  }

  #masthead #ast-desktop-header .main-header-menu > .menu-item > .menu-link {
    font-size: 14px;
  }
}

/*
 * Mobile/tablet — nodo Figma 291:2122.
 * Due pannelli glass simmetrici: logo + menu a sinistra, azioni a destra.
 */
@media (max-width: 921px) {
  #masthead #ast-mobile-header,
  #masthead #ast-mobile-header .ast-main-header-wrap,
  #masthead #ast-mobile-header .ast-primary-header-bar {
    border: 0;
    background: transparent;
  }

  #masthead #ast-mobile-header .ast-primary-header-bar {
    padding: 20px 30px 0;
  }

  #masthead #ast-mobile-header .ast-builder-grid-row {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    min-height: 87px;
    padding: 0;
    align-items: center;
    background: transparent;
  }

  #masthead #ast-mobile-header .ast-builder-grid-row::before,
  #masthead #ast-mobile-header .ast-builder-grid-row::after {
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    width: calc((100% - 12px) / 2);
    overflow: hidden;
    border-radius: 10px;
    background: var(--bn-nav-bg);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    content: "";
  }

  #masthead #ast-mobile-header .ast-builder-grid-row::before {
    left: 0;
  }

  #masthead #ast-mobile-header .ast-builder-grid-row::after {
    right: 0;
    border-radius: 12px;
  }

  #masthead #ast-mobile-header .site-header-section {
    position: relative;
    min-width: 0;
    min-height: 87px;
    align-items: center;
    gap: 5px;
    background: transparent;
  }

  #masthead #ast-mobile-header .site-header-primary-section-left {
    grid-column: 1;
    padding: 26px 0 26px 30px;
  }

  #masthead #ast-mobile-header .site-header-primary-section-right {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: block;
    width: 100%;
    min-height: 87px;
    padding: 0;
    pointer-events: none;
  }

  #masthead #ast-mobile-header .site-branding,
  #masthead #ast-mobile-header .ast-site-identity,
  #masthead #ast-mobile-header .site-logo-img,
  #masthead #ast-mobile-header .custom-logo-link {
    display: block;
    width: 32px;
    height: 35px;
    margin: 0;
    padding: 0;
  }

  #masthead #ast-mobile-header .custom-logo {
    display: block;
    width: 32px;
    height: 35px;
    max-width: none;
    object-fit: contain;
  }

  /* Porta il trigger Astra nel pannello sinistro senza alterarne il markup. */
  #masthead #ast-mobile-header [data-section="section-header-mobile-trigger"] {
    position: absolute !important;
    top: 50%;
    right: calc((100% - 12px) / 2 - 56px);
    display: grid !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    place-items: center;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
    transform: translateY(-50%);
  }

  #masthead #ast-mobile-header [data-section="section-header-mobile-trigger"] .ast-button-wrap {
    width: 16px;
    height: 16px;
  }

  #masthead #ast-mobile-header .menu-toggle {
    display: grid !important;
    width: 16px !important;
    min-width: 16px !important;
    height: 16px !important;
    min-height: 16px !important;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
  }

  #masthead #ast-mobile-header .menu-toggle:hover,
  #masthead #ast-mobile-header .menu-toggle:focus-visible,
  #masthead #ast-mobile-header .menu-toggle[aria-expanded="true"] {
    background: transparent;
    color: #fff;
    outline: none;
  }

  #masthead #ast-mobile-header .menu-toggle svg {
    width: 16px !important;
    height: 16px !important;
    color: #fff;
    fill: currentColor;
  }

  /* Astra include hamburger e chiusura nello stesso bottone: ne mostra uno alla volta. */
  #masthead #ast-mobile-header .menu-toggle[aria-expanded="false"] .ast-menu2-svg {
    display: block !important;
  }

  #masthead #ast-mobile-header .menu-toggle[aria-expanded="false"] .ast-close-svg {
    display: none !important;
  }

  #masthead #ast-mobile-header .menu-toggle[aria-expanded="true"] .ast-menu2-svg {
    display: none !important;
  }

  #masthead #ast-mobile-header .menu-toggle[aria-expanded="true"] .ast-close-svg {
    display: block !important;
  }

  /* Search è già pronto se viene aggiunto alla riga mobile nell'Header Builder. */
  #masthead #ast-mobile-header .ast-header-search,
  #masthead #ast-mobile-header [data-section*="search"] {
    position: absolute;
    top: 50%;
    left: calc((100% + 12px) / 2 + 30px);
    display: grid;
    width: 20px;
    min-width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    place-items: center;
    color: #fff;
    pointer-events: auto;
    transform: translateY(-50%);
  }

  #masthead #ast-mobile-header .ast-header-search svg,
  #masthead #ast-mobile-header [data-section*="search"] svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
  }

  #masthead #ast-mobile-header .header-widget-area,
  #masthead #ast-mobile-header .header-widget-area > .widget,
  #masthead #ast-mobile-header .header-widget-area > .widget > p {
    margin: 0;
    padding: 0;
  }

  #masthead #ast-mobile-header .site-header-primary-section-right > .header-widget-area {
    position: absolute;
    /* Evita transform: un antenato trasformato restringe il drawer fixed a 45 px. */
    top: calc(41% - 10px);
    right: 30px;
    display: grid;
    width: auto;
    height: 20px;
    place-items: center;
    pointer-events: auto;
    transform: none;
  }

  #masthead #ast-mobile-header .bn-packaging-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(460px, 100vw);
    max-width: 100vw;
    height: 100dvh;
  }

  #masthead #ast-mobile-header .bn-packaging-drawer__backdrop {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
  }

  #masthead #ast-mobile-header .site-header-primary-section-right > .ast-header-account {
    position: absolute;
    top: 50%;
    right: 90px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    pointer-events: auto;
    transform: translateY(-50%);
  }

  #masthead #ast-mobile-header .ast-header-account-link.ast-header-account-type-icon {
    width: 20px;
    height: 20px;
  }

  #masthead #ast-mobile-header .ast-header-account-link.ast-header-account-type-icon::before {
    width: 20px;
    height: 20px;
  }

  #masthead #ast-mobile-header .header-widget-area > .widget > p:empty {
    display: none;
  }

  #masthead #ast-mobile-header .ast-mobile-header-content {
    width: calc(100% - 60px);
    margin: 12px 30px 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(30, 30, 30, 0.96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
  }

  #masthead #ast-mobile-header .main-header-menu {
    padding: 14px;
    background: transparent;
  }

  #masthead #ast-mobile-header .main-header-menu .menu-link {
    min-height: 52px;
    padding: 13px 16px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #fff;
    font-family: "Avenir Next", Avenir, sans-serif;
    font-size: 16px;
    font-weight: 400;
  }

  #masthead #ast-mobile-header .main-header-menu .menu-link:hover,
  #masthead #ast-mobile-header .main-header-menu .menu-link:focus-visible,
  #masthead #ast-mobile-header .main-header-menu .current-menu-item > .menu-link,
  #masthead #ast-mobile-header .main-header-menu .current_page_item > .menu-link {
    background: rgba(255, 255, 255, 0.07);
    color: var(--bn-nav-active);
  }

  #masthead .bn-packaging-cart-trigger {
    width: auto;
    height: 20px;
    min-height: 20px;
    padding: 0;
    gap: 5px;
  }

  #masthead #ast-mobile-header .bn-packaging-cart-trigger::before {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }

  #masthead .bn-packaging-cart-trigger__count {
    width: 20px;
    min-width: 20px;
    height: 20px;
    padding: 1px 6px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  #masthead #ast-mobile-header .ast-primary-header-bar {
    padding-inline: 30px;
  }
}

@media (max-width: 340px) {
  #masthead #ast-mobile-header .ast-primary-header-bar {
    padding-inline: 16px;
  }

  #masthead #ast-mobile-header .ast-mobile-header-content {
    width: calc(100% - 32px);
    margin-inline: 16px;
  }
}

@media (max-width: 782px) {
  body.admin-bar.home #masthead,
  body.admin-bar.page-id-243 #masthead,
  body.admin-bar.page-id-295 #masthead {
    top: 46px;
  }

  @supports selector(body:has(.entry-content)) {
    body.admin-bar.page:not(.woocommerce-page):has(.entry-content > .wp-block-cover:first-child) #masthead {
      top: 46px;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  #masthead .menu-link,
  #masthead .menu-link::after {
    transition: none !important;
  }
}
