/* ===========================
   HEADER & TOPBAR
   =========================== */

/* Icone SVG base (usate nel header/topbar) */
.nbs-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.nbs-icon--social {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}

/* Topbar (NON sticky) */

.nbs-topbar {
  background-color: #5f9ea0;
  color: #ffffff;
  font-size: 0.85rem;
}

.nbs-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
}

.nbs-topbar__left {
  display: flex;
  gap: 1.5rem;
}

.nbs-topbar__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nbs-topbar__icon svg {
  display: block;
}

.nbs-topbar__right {
  display: flex;
  gap: 0.4rem;
}

.nbs-topbar__social {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  text-decoration: none;
  color: #ffffff;
}

.nbs-topbar__social:hover,
.nbs-topbar__social:focus {
  background-color: rgba(255, 255, 255, 0.25);
}

/* Header principale - STICKY (gestito da JS via classi) */

.site-header {
  position: relative;
  z-index: 999;
}

.nbs-header-main {
  border-bottom: 1px solid var(--nbs-color-border);
  background-color: #ffffff;
  transition: box-shadow 0.2s ease;
}

/* quando diventa sticky */
.nbs-header-main--fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border-bottom: 1px solid var(--nbs-color-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* corregge l’offset se sei loggato in admin */
body.admin-bar .nbs-header-main--fixed {
  top: 32px;
}

/* evita che il contenuto salti sotto l’header fixed */
body.nbs-header-fixed-active .nbs-home-main {
  padding-top: 90px; /* adatta se l'header è più alto/basso */
}

/* layout header: logo a sinistra, menu centrato, icone a destra */
.nbs-header-main__inner {
  display: grid;
  grid-template-columns: auto 1fr auto; /* branding - menu - azioni */
  align-items: center;
  padding: 1.5rem 0;
  column-gap: 2rem;
}

/* Branding: logo + titolo + motto */

.nbs-header-main__branding {
  display: flex;
  flex-direction: column;
}

.site-logo {
  margin-bottom: 0.4rem;
}

.site-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
}

.site-title a {
  color: var(--nbs-color-text);
  text-decoration: none;
}

.site-description {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--nbs-color-text-muted);
}

/* ===========================
   NAVIGAZIONE PRINCIPALE
   (menu centrato + sottomenu)
   =========================== */

.main-navigation {
  justify-self: center;
  text-align: center;
}

/* lista principale */
.main-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--nbs-spacing-sm);
}

/* elementi primo livello */
.main-navigation li {
  position: relative;
}

/* link primo livello */
.main-navigation a {
  display: block;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.95rem;
  border: 1px solid transparent;
  color: var(--nbs-color-text);
  position: relative;
  white-space: nowrap;
}

.main-navigation a:hover,
.main-navigation a:focus,
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-parent > a,
.main-navigation .current-menu-ancestor > a {
  border-color: var(--nbs-color-border);
  background-color: var(--nbs-color-bg-alt);
}

/* caret per voci con sottomenu */
.main-navigation li.menu-item-has-children > a {
  padding-right: 1.4rem;
}

.main-navigation li.menu-item-has-children > a::after {
  content: "▾";
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  opacity: 0.7;
}

/* ===========================
   SOTTOMENU (dropdown desktop)
   =========================== */

.main-navigation ul ul {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0.6rem);
  top: 100%;
  min-width: 200px;
  background: #ffffff;
  border-radius: 14px;
  padding: 0.4rem 0;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 1000;
}

.main-navigation ul ul li {
  width: 100%;
}

/* link nel sottomenu */
.main-navigation ul ul a {
  border-radius: 0;
  border: 0;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  text-align: center;
  white-space: nowrap;
}

.main-navigation ul ul a:hover,
.main-navigation ul ul a:focus,
.main-navigation ul ul .current-menu-item > a {
  background-color: var(--nbs-color-bg-alt);
}

/* apertura dropdown su hover / focus (desktop) */
.main-navigation li.menu-item-has-children:hover > ul,
.main-navigation li.menu-item-has-children:focus-within > ul {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0.2rem);
}

/* eventuale terzo livello: apri di lato */
.main-navigation ul ul ul {
  top: 0;
  left: 100%;
  transform: translate(0.4rem, 0);
}

/* ===========================
   TOGGLE MENU (mobile)
   =========================== */

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--nbs-color-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 0.6rem;
}

.menu-toggle .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* piccola icona burger nel bottone testuale */
.nbs-menu-toggle__icon {
  display: block;
  width: 18px;
  height: 2px;
  background-color: var(--nbs-color-text);
  position: relative;
  border-radius: 10px;
}

.nbs-menu-toggle__icon::before,
.nbs-menu-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background-color: var(--nbs-color-text);
  border-radius: 10px;
}

.nbs-menu-toggle__icon::before {
  top: -5px;
}

.nbs-menu-toggle__icon::after {
  top: 5px;
}

/* Icone azioni a destra */

.nbs-header-main__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
}

.nbs-header-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nbs-header-icon svg {
  width: 20px;
  height: 20px;
}

/* Bottone menu quadrato colorato */

.nbs-header-icon--menu {
  background-color: #5f9ea0;
  width: 42px;
  height: 42px;
  border-radius: 2px;
}

.nbs-header-burger,
.nbs-header-burger::before,
.nbs-header-burger::after {
  display: block;
  width: 20px;
  height: 2px;
  background-color: #ffffff;
  content: "";
  border-radius: 10px;
}

.nbs-header-burger::before,
.nbs-header-burger::after {
  position: relative;
}

.nbs-header-burger::before {
  top: -6px;
}

.nbs-header-burger::after {
  top: 6px;
}

/* ===========================
   RESPONSIVE HEADER / MENU
   =========================== */

@media (max-width: 960px) {

  .nbs-topbar__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .nbs-header-main__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    row-gap: 1rem;
  }

  /* menu sotto il branding, a tutta larghezza */
  .main-navigation {
    grid-column: 1 / -1;
    order: 3;
    justify-self: stretch;
    text-align: left;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .main-navigation ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .main-navigation li {
    width: 100%;
  }

  .main-navigation a {
    width: 100%;
    text-align: left;
  }

  /* sottomenu in mobile: niente overlay, tutto in flusso */
  .main-navigation ul ul {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    box-shadow: none;
    padding: 0.15rem 0 0.15rem 1rem;
    background: transparent;
    min-width: 0;
  }

  .main-navigation ul ul a {
    font-size: 0.9rem;
    padding: 0.35rem 0;
  }

  /* opzionale: niente caret in mobile (c’è già indentazione) */
  .main-navigation li.menu-item-has-children > a::after {
    content: "";
    font-size:1.5rem;
  }
}

/* ===========================
   DARK MODE - HEADER SPECIFICO
   =========================== */

html[data-theme="dark"] .nbs-topbar {
  background-color: #020617;
  color: #e5e7eb;
}

html[data-theme="dark"] .nbs-header-main {
  background-color: #020617;
  border-bottom-color: #111827;
  color: #f9fafb;
}

html[data-theme="dark"] .nbs-header-main__branding,
html[data-theme="dark"] .main-navigation,
html[data-theme="dark"] .main-navigation a {
  color: #f9fafb;
}

html[data-theme="dark"] .main-navigation a:hover,
html[data-theme="dark"] .main-navigation a:focus,
html[data-theme="dark"] .main-navigation .current-menu-item > a,
html[data-theme="dark"] .main-navigation .current-menu-parent > a,
html[data-theme="dark"] .main-navigation .current-menu-ancestor > a {
  background-color: #111827;
  border-color: #111827;
}

/* dropdown in dark */
html[data-theme="dark"] .main-navigation ul ul {
  background: #020617;
  border: 1px solid #1f2937;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
}

html[data-theme="dark"] .main-navigation ul ul a {
  color: #f9fafb;
}

html[data-theme="dark"] .main-navigation ul ul a:hover,
html[data-theme="dark"] .main-navigation ul ul a:focus {
  background-color: #111827;
}

/* icone header + social */
html[data-theme="dark"] .nbs-header-icon,
html[data-theme="dark"] .nbs-topbar__social {
  color: #f9fafb;
}