/*
 * ============================================================================
 * NAVIGATION.CSS - UCOI/UCOIM
 * ============================================================================
 * @file: navigation.css
 * @description: Sistema di navigazione primaria mobile-first con supporto
 *               accessibilità, breadcrumb e secondary nav
 * @author: Altoprofilo Studio
 * @version: 1.9 (FIXED: hero full-height con header fixed)
 * @last-updated: 2025-10-15
 * @dependencies: base.css (variabili globali)
 * ============================================================================
 */

/* ============================================================================
   VARIABILI LOCALI
   Token di design specifici per la navigazione
   ============================================================================ */

:root {
  /* Colori navigazione - eredita da base.css */
  --nav-bg: #ffffff;
  --nav-fg: var(--primary-color, #036);
  --nav-border: rgba(3, 51, 102, .15);
  --nav-shadow: 0 20px 40px rgba(0,0,0,.12);
  --nav-bg-light: rgba(3, 51, 102, .06);
  
  /* Header heights - include breadcrumb dove presente */
  --header-height-mobile: 65px; /* ✅ Ridotto per mobile */
  --header-height-desktop: 135px; /* Header + breadcrumb */
  
  /* Breadcrumb */
  --bc-bg: var(--bg-light, #f5f9fc);
  --bc-sep: rgba(0,0,0,.45);
  --bc-text: rgba(0,0,0,.65);
  --bc-link: var(--primary-color, #036);
  --bc-link-hover: var(--primary-hover, #001a49);

  /* Secondary navigation */
  --sec-pill-bg: #fff;
  --sec-pill-text: var(--primary-color, #036);
  --sec-pill-hover: var(--bg-light, #f5f9fc);
  --sec-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ============================================================================
   ACCESSIBILITÀ
   Screen reader e utility classes per a11y
   ============================================================================ */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   COMPENSAZIONE HEADER FIXED
   Padding body per evitare che il contenuto sia nascosto sotto l'header
   ============================================================================ */

body {
  padding-top: var(--header-height-mobile);
}

@media (min-width: 992px) {
  body {
    padding-top: var(--header-height-desktop);
  }
}

/* ============================================================================
   HERO FULL-HEIGHT
   Hero che si estende fino al top (sotto header) per background completo
   ============================================================================ */

/* Hero come primo elemento del main */
body > main > section:first-child.hero,
body > main > .hero:first-child {
  margin-top: calc(var(--header-height-mobile) * -1);
  padding-top: calc(var(--header-height-mobile) + 2rem);
}

@media (min-width: 992px) {
  body > main > section:first-child.hero,
  body > main > .hero:first-child {
    margin-top: calc(var(--header-height-desktop) * -1);
    padding-top: calc(var(--header-height-desktop) + 3rem);
  }
}

/* ============================================================================
   HEADER PRINCIPALE
   Container header e logo - FIXED per visibilità costante
   ============================================================================ */

.site-header {
  position: fixed; /* ✅ CHANGED: da sticky a fixed */
  top: 0;
  left: 0;
  right: 0;
  z-index: 10500;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  min-height: var(--header-height-mobile);
}

@media (min-width: 992px) {
  .site-header {
    min-height: var(--header-height-desktop);
  }
}

.header-container {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .5rem var(--section-inline-padding, 1rem); /* ✅ Ridotto padding verticale mobile */
  position: relative;
  min-height: inherit;
}

@media (min-width: 992px) {
  .header-container {
    padding: .75rem var(--section-inline-padding, 1rem); /* Padding normale desktop */
  }
}

.logo {
  position: relative;
  z-index: 2; /* Locale: sopra elementi header */
}

.logo img {
  height: auto;
  max-width: 180px; /* ✅ Ridotto per mobile */
}

@media (min-width: 576px) {
  .logo img {
    max-width: 200px; /* Dimensione normale da tablet in su */
  }
}

@media (max-width: 360px) {
  .logo img {
    max-width: 150px; /* Ancora più piccolo per schermi tiny */
  }
}

/* ============================================================================
   TOGGLE MOBILE
   Pulsante hamburger - ABSOLUTE dentro header fixed
   ============================================================================ */

.mobile-menu-toggle {
  appearance: none;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: saturate(120%) blur(8px);
  border: 0;
  border-radius: 999px;
  padding: .3rem .4rem; /* ✅ Leggermente ridotto per mobile */
  display: none;
  flex-direction: column;
  gap: .25rem;
  align-items: center;
  justify-content: center;
  color: var(--nav-fg);
  line-height: 1;
  /* ✅ CHANGED: da fixed a absolute (relativo a header) */
  position: absolute;
  right: var(--section-inline-padding, 1rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 3; /* Locale: sopra logo */
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.mobile-menu-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* SVG Hamburger */
.mobile-menu-toggle svg {
  display: block;
  width: 24px;
  height: 24px;
}

.mobile-menu-toggle[aria-expanded="true"] {
  color: var(--accent-color, #f57c00);
}

/* Hover state (desktop/tablet) */
.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 1);
}

/* ============================================================================
   PANNELLO NAVIGAZIONE MOBILE
   Overlay full-screen per menu mobile - sotto header fixed
   ============================================================================ */

.primary-navigation {
  position: fixed;
  top: var(--header-height-mobile); /* ✅ Subito sotto l'header */
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow);
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height-mobile));
  z-index: 10400; /* ✅ Sotto header (10500) */
}

@media (min-width: 992px) {
  .primary-navigation {
    top: var(--header-height-desktop);
    max-height: calc(100vh - var(--header-height-desktop));
  }
}

.primary-navigation.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

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

@media (max-width: 991.98px) {
  .mobile-menu-toggle {
    display: inline-flex;
  }
}

/* ============================================================================
   MENU PRINCIPALE
   Lista navigazione top-level
   ============================================================================ */

.menu {
  list-style: none;
  margin: 0;
  padding: .5rem 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.menu > li {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  color: var(--nav-fg);
  text-decoration: none;
  font-weight: 500;
  padding: .75rem;
  border-radius: .5rem;
  position: relative;
}

.menu a:focus-visible,
.submenu-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.menu > li > a:hover {
  background: rgba(14,43,87,.06);
}

.menu > li > a[aria-current="page"] {
  font-weight: 600;
  background: rgba(14,43,87,.08);
}

/* ============================================================================
   SOTTOMENU
   Accordion mobile / Dropdown desktop
   ============================================================================ */

.has-submenu {
  position: relative;
}

/* ----------------------------------------------------------------------------
   Toggle chevron
   ---------------------------------------------------------------------------- */

.submenu-toggle {
  background: transparent;
  border: 0;
  padding: .5rem;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease;
  cursor: pointer;
}

.has-submenu[aria-expanded="true"] .submenu-toggle {
  transform: rotate(180deg);
}

/* ----------------------------------------------------------------------------
   Lista sottomenu
   ---------------------------------------------------------------------------- */

.submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}

.has-submenu[aria-expanded="true"] .submenu {
  max-height: 1000px;
}

.submenu li {
  border-top: 1px solid rgba(0,0,0,.06);
}

.submenu a {
  padding: .65rem .75rem .65rem 1.5rem;
  border-radius: .375rem;
  font-size: .95rem;
}

.submenu a:hover,
.submenu a:focus-visible {
  background: var(--bg-light);
  text-decoration: none;
}

.submenu a[aria-current="page"] {
  font-weight: 600;
  background: rgba(14,43,87,.12);
}

/* ============================================================================
   CTA BUTTON
   Pulsante call-to-action nel menu
   ============================================================================ */

.menu-cta {
  order: 99;
  margin-top: .5rem;
}

.nav-cta {
  border: 2px solid var(--nav-fg);
  padding: .65rem .9rem;
  border-radius: 999px;
  font-weight: 600;
  text-align: center;
}

.menu-cta .nav-cta:hover,
.menu-cta .nav-cta:focus-visible {
  background: var(--nav-fg);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

/* ============================================================================
   LAYOUT DESKTOP
   Navigazione orizzontale per schermi ≥992px
   ============================================================================ */

@media (min-width: 992px) {
  .header-container {
    grid-template-columns: auto 1fr;
  }

  .mobile-menu-toggle {
    display: none;
  }

  .primary-navigation {
    position: static;
    inset: auto;
    box-shadow: none;
    border-top: 0;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    overflow: visible;
    max-height: none;
    z-index: auto;
  }

  .menu {
    flex-direction: row;
    align-items: center;
    gap: .25rem;
    padding: 0;
  }

  .menu > li {
    flex-direction: row;
    position: relative;
  }

  .menu > li > a {
    padding: .75rem .9rem;
  }

  /* --------------------------------------------------------------------------
     Underline animata hover
     ------------------------------------------------------------------------ */

  .menu > li > a::after {
    content: "";
    display: block;
    height: 2px;
    background-color: var(--nav-fg);
    position: absolute;
    left: .75rem;
    right: .75rem;
    bottom: .5rem;
    transform: scaleX(0);
    transition: transform .3s ease;
  }

  .menu > li > a:hover::after {
    transform: scaleX(1);
  }

  .menu > li > a[aria-current="page"]::after {
    transform: scaleX(1);
  }

  .menu > li > a.nav-cta::after {
    display: none;
  }

  /* --------------------------------------------------------------------------
     CTA posizionamento
     ------------------------------------------------------------------------ */

  .menu-cta {
    margin-left: auto;
    order: 0;
    margin-top: 0;
  }

  .nav-cta {
    padding: .55rem 1rem;
  }

  /* --------------------------------------------------------------------------
     Dropdown sottomenu
     ------------------------------------------------------------------------ */

  .submenu {
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: .5rem;
    box-shadow: var(--nav-shadow);
    padding: .5rem;
    min-width: 240px;
    margin-top: 10px;
    max-height: none;
    overflow: visible;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 10501;
  }

  .has-submenu:hover .submenu,
  .has-submenu[aria-expanded="true"] .submenu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  /* Bridge invisibile per evitare chiusura dropdown */
  .has-submenu::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 14px;
  }

  .submenu li {
    border-top: 0;
  }

  .submenu a {
    padding: .5rem .65rem;
    font-size: 1rem;
  }

  .has-submenu > a {
    padding-right: .25rem;
  }

  .has-submenu > .submenu-toggle {
    padding-left: .25rem;
  }

  .has-submenu[aria-expanded="true"] .submenu-toggle {
    transform: none;
  }
}

/* ============================================================================
   BREADCRUMB
   Navigazione breadcrumb per percorso pagina
   ============================================================================ */

.breadcrumb-container {
  padding: .5rem 0;
  background-color: var(--bc-bg);
  border-bottom: 1px solid rgba(0,0,0,.06);
  font-size: .875rem;
  width: 100%;
}

.breadcrumb,
.breadcrumbs,
.breadcrumb-container ol,
.breadcrumb-container ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0 1rem;
}

.breadcrumb li,
.breadcrumbs li,
.breadcrumb-container ol>li,
.breadcrumb-container ul>li {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: var(--bc-text);
}

.breadcrumb li:not(:last-child)::after,
.breadcrumbs li:not(:last-child)::after,
.breadcrumb-container ol>li:not(:last-child)::after,
.breadcrumb-container ul>li:not(:last-child)::after {
  content: "›";
  margin: 0 .5rem;
  color: var(--bc-sep);
}

.breadcrumb a,
.breadcrumbs a,
.breadcrumb-container a {
  color: var(--bc-link);
  text-decoration: none;
  transition: color .2s ease, text-decoration .2s;
}

.breadcrumb a:hover,
.breadcrumbs a:hover,
.breadcrumb-container a:hover {
  color: var(--bc-link-hover);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"],
.breadcrumbs [aria-current="page"],
.breadcrumb-container [aria-current="page"] {
  color: var(--bc-text);
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 768px) {
  .breadcrumb-container {
    padding: .35rem 0;
    font-size: .8rem;
  }
}

/* ============================================================================
   NAVIGAZIONE SECONDARIA
   Quick nav / Pill navigation per sottosezioni
   ============================================================================ */

.quick-nav,
.secondary-nav {
  margin: -1.5rem auto 2rem;
  position: relative;
  z-index: 10;
}

.quick-nav-container,
.secondary-nav-container {
  background-color: var(--sec-pill-bg);
  border-radius: 8px;
  box-shadow: var(--sec-shadow);
  padding: .5rem;
}

.quick-nav-list,
.secondary-nav-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: .5rem;
  gap: .5rem .75rem;
}

/* ----------------------------------------------------------------------------
   Pills / Badge items
   ---------------------------------------------------------------------------- */

.quick-nav-item,
.secondary-nav-item,
.quick-nav-list a,
.secondary-nav-list a {
  border-radius: 30px;
  color: var(--sec-pill-text);
  display: inline-block;
  font-size: .9rem;
  font-weight: 600;
  padding: .5rem 1.25rem;
  text-decoration: none;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
  border: 1px solid rgba(0,0,0,.06);
  background: #fff;
}

.quick-nav-item:hover,
.secondary-nav-item:hover,
.quick-nav-list a:hover,
.secondary-nav-list a:hover {
  background-color: var(--sec-pill-hover);
  transform: translateY(-1px);
}

/* Identificatori brand UCOI/UCOIM */
.ucoi-item {
  border-left: 3px solid var(--primary-color, #036);
}

.ucoim-item {
  border-left: 3px solid var(--secondary-color, #005bac);
}

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

@media (max-width: 768px) {
  .quick-nav-list,
  .secondary-nav-list {
    flex-direction: column;
  }

  .quick-nav-item,
  .secondary-nav-item,
  .quick-nav-list a,
  .secondary-nav-list a {
    text-align: center;
    width: 100%;
  }
}

/* ==========================================================================
   MENU DESKTOP – centrato + CTA a destra (override finale)
   Nota: mantiene il markup attuale (CTA dentro <li class="menu-cta">)
   ========================================================================== */
@media (min-width: 992px){
  /* Il nav diventa il contesto per la CTA in posizione assoluta */
  .site-header .primary-navigation{ position: relative; }

  /* Centra gli item del menu e riserva spazio a destra per la CTA */
  .site-header .primary-navigation .menu{
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    padding-right: 10rem;
    margin: 0;
  }

  /* "Sfiliamo" la CTA a destra fuori dal flusso, centrata verticalmente */
  .site-header .primary-navigation .menu-cta{
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin: 0 !important;
    list-style: none;
  }

  .site-header .primary-navigation .menu-cta .nav-cta{
    display: inline-block;
    white-space: nowrap;
  }
}

/* Tablet (opzionale): riduci lo spazio della CTA se serve */
@media (min-width: 768px) and (max-width: 991.98px){
  .site-header .primary-navigation .menu{ padding-right: 8rem; }
}