/* =========================================================================
   Menú responsive — millora UI/UX + integració visual BSA  (2026-08)

   - Mòbil/tauleta (<=991px): panell off-canvas lateral amb capçalera de marca
     (blau BSA), ítems refinats, accent taronja actiu i submenús en accordió.
   - Escriptori (>=992px): desplegable per hover amb detecció de col·lisió.
   - El panell se situa PER SOBRE de la barra sticky (.upper-text té z-index
     999991) perquè, en obrir el menú amb la pàgina desplaçada, no s'hi coli
     el text fix "Treballa amb nosaltres".

   Carregat DESPRÉS de main.css i del bloc inline de meta.blade.php.
   Breakpoint únic compartit amb menu-responsive.js: 992px.
   ========================================================================= */

:root {
  --bsa-blue: #0062a2;
  --bsa-blue-dark: #004f83;
  --bsa-orange: #f28c00;
  --bsa-ink: #2b2b2b;
  --bsa-muted: #5a6673;
  --bsa-line: #e9edf1;
  --bsa-sub-bg: #f5f8fa;
  --bsa-hover-bg: #f3f7fa;
}

/* --- Elements que només existeixen a mòbil: amagats a escriptori --- */
.navigation .nav-header .submenu-toggle,
.navigation .nav-header .nav-panel-head,
.navigation .nav-close {
  display: none;
}

.nav-overlay {
  display: none;
}

/* --- Placeholder que evita el salt quan la barra passa a position:fixed --- */
.nav-sticky-placeholder {
  display: none;
}
.nav-sticky-placeholder.is-active {
  display: block;
}

/* =========================================================================
   ESCRIPTORI (>=992px) — col·lisió de submenús
   ========================================================================= */
@media (min-width: 992px) {
  .navigation .nav-header > ul > li > ul.submenu.submenu-align-right {
    left: auto;
    right: 0;
  }
  .navigation .nav-header > ul > li > ul.submenu.submenu-columns {
    width: 560px;
    -webkit-columns: 2;
    -moz-columns: 2;
    columns: 2;
    -webkit-column-gap: 0;
    -moz-column-gap: 0;
    column-gap: 0;
  }
  .navigation .nav-header > ul > li > ul.submenu.submenu-columns > li {
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
  }
  .navigation .nav-header > ul > li > ul.submenu.submenu-columns.submenu-align-right {
    left: auto;
    right: 0;
  }
}

/* =========================================================================
   MÒBIL / TAULETA (<=991px) — panell off-canvas lateral
   ========================================================================= */
@media (max-width: 991px) {

  .navigation {
    position: static;
  }

  /* --- Botó hamburguesa --- */
  .navigation .nav-footer {
    display: block !important;
  }
  .navigation .nav-footer button {
    width: 52px;
    height: 47px;
    background: transparent;
    color: var(--bsa-blue);
    border: none;
    outline: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    -webkit-transition: color .2s ease;
    transition: color .2s ease;
  }
  .navigation .nav-footer button:hover {
    color: var(--bsa-orange);
  }

  /* --- Panell off-canvas (per sobre de tot: sticky, upper-text 999991) --- */
  .navigation .nav-header {
    display: block !important;
    position: fixed;
    top: 0;
    left: auto; /* anul·la el `left:0` del bloc antic @media 730px de main.css */
    right: 0;
    width: 328px;
    max-width: 86vw;
    height: 100%;
    background: #fff;
    z-index: 1000001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: -6px 0 26px rgba(0, 32, 58, 0.22);
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
    -webkit-transition: -webkit-transform .32s cubic-bezier(.22, .61, .36, 1);
    transition: transform .32s cubic-bezier(.22, .61, .36, 1);
    padding-top: 54px; /* alçada de la capçalera de marca */
    margin: 0 !important;
    font-family: "Hind", sans-serif;
  }
  .navigation .nav-header.is-open {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }

  /* --- Capçalera de marca del panell (barra blava fixa a dalt) --- */
  .navigation .nav-header .nav-panel-head {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    padding: 0 8px 0 20px;
    background: -webkit-gradient(linear, left top, right top, from(var(--bsa-blue)), to(var(--bsa-blue-dark)));
    background: linear-gradient(90deg, var(--bsa-blue) 0%, var(--bsa-blue-dark) 100%);
  }
  .navigation .nav-header .nav-panel-title {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
  }

  /* --- Botó tancar --- */
  .navigation .nav-close {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    -webkit-transition: background .2s ease, -webkit-transform .2s ease;
    transition: background .2s ease, transform .2s ease;
  }
  .navigation .nav-close:hover {
    background: rgba(255, 255, 255, .16);
    -webkit-transform: rotate(90deg);
    transform: rotate(90deg);
  }

  /* --- Overlay fosc (per sobre del sticky, per sota del panell) --- */
  .nav-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(6, 30, 52, 0.52);
    z-index: 1000000;
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity .32s ease, visibility .32s ease;
    transition: opacity .32s ease, visibility .32s ease;
  }
  .nav-overlay.is-open {
    opacity: 1;
    visibility: visible;
  }

  /* Bloqueja l'scroll del cos quan el menú és obert */
  body.nav-panel-open {
    overflow: hidden;
  }

  /* Quan la barra és sticky (position:fixed) crea un stacking context propi
     que "atrapa" el panell sota l'overlay. En obrir el menú, elevem tota la
     barra per sobre de l'overlay perquè el panell (que hi és a dins) es vegi net. */
  body.nav-panel-open .mainmenu-area {
    z-index: 1000002 !important;
  }

  /* --- Llista i ítems (guanya a les regles !important inline de protecció) --- */
  .navigation .nav-header > ul {
    margin: 0 !important;
    padding: 0 !important;
    border-top: 0;
    width: 100%;
  }
  .navigation .nav-header > ul > li {
    display: block !important;
    width: 100%;
    position: relative;
    border-bottom: 1px solid var(--bsa-line);
  }

  /* Enllaç principal amb accent lateral taronja */
  .navigation .nav-header > ul > li > a,
  .navigation .nav-header > ul > li:first-child > a {
    display: block;
    padding: 15px 58px 15px 22px !important;
    background: #fff;
    font-size: 15px;
    font-weight: 500;
    color: var(--bsa-ink);
    line-height: 1.3;
    border-left: 3px solid transparent;
    -webkit-transition: background .18s ease, color .18s ease, border-color .18s ease;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
  }
  .navigation .nav-header > ul > li > a:hover,
  .navigation .nav-header > ul > li.open > a {
    background: var(--bsa-hover-bg);
    border-left-color: var(--bsa-blue);
  }
  .navigation .nav-header > ul > li > a.active,
  .navigation .nav-header > ul > li:hover > a {
    color: var(--bsa-orange);
    border-left-color: var(--bsa-orange);
  }

  /* Ítem "Inici" (icona casa) en blau de marca */
  .navigation .nav-header > ul > li:first-child > a {
    color: var(--bsa-blue);
    font-size: 17px;
  }

  /* --- Botó chevron per desplegar (accordió) --- */
  .navigation .nav-header .submenu-toggle {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 52px;
    height: 49px; /* només la fila de l'enllaç, no tot el submenú desplegat */
    background: transparent;
    border: none;
    border-left: 1px solid var(--bsa-line);
    outline: none;
    font-size: 18px;
    color: var(--bsa-blue);
    cursor: pointer;
    -webkit-transition: color .2s ease, background .2s ease, -webkit-transform .28s ease;
    transition: color .2s ease, background .2s ease, transform .28s ease;
  }
  .navigation .nav-header > ul > li.open > .submenu-toggle {
    color: var(--bsa-orange);
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
  }

  /* --- Submenú com accordió (flueix, sense scroll intern) --- */
  .navigation .nav-header > ul > li > ul.submenu {
    position: static !important;
    display: none;
    width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
    -webkit-transform: none !important;
    transform: none !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    background: var(--bsa-sub-bg) !important;
    -webkit-transition: none !important;
    transition: none !important;
    border-top: 1px solid var(--bsa-line);
  }
  .navigation .nav-header > ul > li.open > ul.submenu {
    display: block;
  }
  .navigation .nav-header > ul > li > ul.submenu > li {
    display: block !important;
    visibility: visible !important;
    position: relative;
    border-bottom: 1px solid #eef2f5;
  }
  .navigation .nav-header > ul > li > ul.submenu > li:last-child {
    border-bottom: 0;
  }
  .navigation .nav-header > ul > li > ul.submenu > li > a {
    display: block;
    padding: 12px 20px 12px 34px !important;
    font-size: 14px;
    font-weight: 400;
    color: var(--bsa-muted);
    line-height: 1.35;
    -webkit-transition: background .16s ease, color .16s ease, padding .16s ease;
    transition: background .16s ease, color .16s ease, padding .16s ease;
  }
  .navigation .nav-header > ul > li > ul.submenu > li > a:hover {
    background: #fff;
    color: var(--bsa-orange);
    padding-left: 40px !important;
  }

  /* --- Micro-interacció: revelat esglaonat dels ítems en obrir --- */
  .navigation .nav-header.is-open > ul > li {
    opacity: 0;
    -webkit-transform: translateX(14px);
    transform: translateX(14px);
    -webkit-animation: bsaNavItemIn .34s ease forwards;
    animation: bsaNavItemIn .34s ease forwards;
  }
  .navigation .nav-header.is-open > ul > li:nth-child(1) { -webkit-animation-delay: .06s; animation-delay: .06s; }
  .navigation .nav-header.is-open > ul > li:nth-child(2) { -webkit-animation-delay: .10s; animation-delay: .10s; }
  .navigation .nav-header.is-open > ul > li:nth-child(3) { -webkit-animation-delay: .14s; animation-delay: .14s; }
  .navigation .nav-header.is-open > ul > li:nth-child(4) { -webkit-animation-delay: .18s; animation-delay: .18s; }
  .navigation .nav-header.is-open > ul > li:nth-child(5) { -webkit-animation-delay: .22s; animation-delay: .22s; }
  .navigation .nav-header.is-open > ul > li:nth-child(6) { -webkit-animation-delay: .26s; animation-delay: .26s; }
  .navigation .nav-header.is-open > ul > li:nth-child(7) { -webkit-animation-delay: .30s; animation-delay: .30s; }
  .navigation .nav-header.is-open > ul > li:nth-child(8) { -webkit-animation-delay: .34s; animation-delay: .34s; }
  .navigation .nav-header.is-open > ul > li:nth-child(9) { -webkit-animation-delay: .38s; animation-delay: .38s; }
  .navigation .nav-header.is-open > ul > li:nth-child(n+10) { -webkit-animation-delay: .42s; animation-delay: .42s; }

  @-webkit-keyframes bsaNavItemIn {
    to { opacity: 1; -webkit-transform: none; transform: none; }
  }
  @keyframes bsaNavItemIn {
    to { opacity: 1; -webkit-transform: none; transform: none; }
  }

  /* Respecta qui prefereix menys moviment */
  @media (prefers-reduced-motion: reduce) {
    .navigation .nav-header,
    .navigation .nav-header.is-open > ul > li {
      -webkit-transition: none !important;
      transition: none !important;
      -webkit-animation: none !important;
      animation: none !important;
      opacity: 1 !important;
      -webkit-transform: none !important;
      transform: none !important;
    }
  }
}
