/* ===========================================================
   Turba — Header global (hamburguesa + logo + menú)
   =========================================================== */

/* -----------------------------------------------------------
   1. Colores condicionales: Home (claro) vs resto (oscuro)
   ----------------------------------------------------------- */

/* ===== HEADER CLARO (solo Home, sobre vídeo oscuro) ===== */
body.home-header-light .site-header,
body.home-header-light .site-header .menu a,
body.home-header-light .site-header .menu-item a,
body.home-header-light .site-header .main-navigation a {
  color: #f9f3e7 !important;
}

body.home-header-light .site-header .menu a:hover,
body.home-header-light .site-header .menu-item a:hover,
body.home-header-light .site-header .menu .current-menu-item > a,
body.home-header-light .site-header .menu .current_page_item > a,
body.home-header-light .site-header .main-navigation a:hover,
body.home-header-light .site-header .main-navigation .current-menu-item > a {
  color: #73edff !important;
}

/* Submenús (Home) */
body.home-header-light .site-header .sub-menu a {
  color: #f9f3e7 !important;
  background-color: #373737;
}

body.home-header-light .site-header .sub-menu a:hover {
  color: #73edff !important;
}

/* Hamburguesa (Home) */
body.home-header-light .site-header .menu-toggle,
body.home-header-light .site-header .menu-toggle span,
body.home-header-light .site-header .menu-toggle::before,
body.home-header-light .site-header .menu-toggle::after {
  background: #ffffff !important;
  color: #ffffff !important;
  fill: #ffffff !important;
}

/* Hamburguesa clara mobile(Home) */
body.home-header-light .site-header .hamburger {
  color: #f9f3e7;
}

/* Logo (Home → color original) */
body.home-header-light .site-branding .custom-logo {
  filter: none;
  transition: filter 0.3s ease;
}

body.home-header-light .desktop-menu .sub-menu {
  background-color: #373737;
}
body.home-header-light .desktop-menu .sub-menu li {
  height: 50px;
}
/* ===== HEADER OSCURO (resto del sitio) ===== */
body.header-dark .site-header,
body.header-dark .site-header .menu a,
body.header-dark .site-header .menu-item a,
body.header-dark .site-header .main-navigation a {
  color: #111 !important;
  font-weight: 500;
}

/* Submenús (Resto) */
.desktop-menu .sub-menu {
  background-color: #f9f3e7;
}

/* Hover negro + negrita */
body.header-dark .site-header .menu a:hover,
body.header-dark .site-header .menu-item a:hover,
body.header-dark .site-header .menu .current-menu-item > a,
body.header-dark .site-header .menu .current_page_item > a,
body.header-dark .site-header .main-navigation a:hover,
body.header-dark .site-header .main-navigation .current-menu-item > a {
  color: #000 !important;
  font-weight: 700;
}

/* Hamburguesa (resto del sitio) */
body.header-dark .site-header .menu-toggle,
body.header-dark .site-header .menu-toggle span,
body.header-dark .site-header .menu-toggle::before,
body.header-dark .site-header .menu-toggle::after {
  background: #111 !important;
  color: #111 !important;
  fill: #111 !important;
}

/* Logo */
body.header-dark .site-branding .custom-logo {
  filter: brightness(0) invert(0);
  transition: filter 0.3s ease;
}

/* -----------------------------------------------------------
   2. Estructura general del header
   ----------------------------------------------------------- */
.container.header-bar {
  background-color: transparent;
  z-index: 1000;
}

.site-header {
  border: 0;
}

.header-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 2rem;
  background: transparent;
  z-index: 1000;
  top: 20px;
}

/* Logo */
.site-branding {
  margin: 0 25px;
  text-align: left;
  flex-shrink: 0;
  width: 266px;
  height: 44px;
}
.site-branding .custom-logo {
  max-height: 42px;
  height: auto;
}

/* Menú principal */
.main-navigation {
  margin-left: auto;
}
.menu {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}
.menu a {
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  font-size: 1rem;
  position: relative;
  transition:
    color 0.3s ease,
    font-weight 0.3s ease;
}

/* -----------------------------------------------------------
   3. Subrayado animado y activo
   ----------------------------------------------------------- */

/* Subrayado base */
.menu a::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 0;
  height: 2px;
  transition: width 0.3s ease;
}

/* Colores del subrayado */
body.home-header-light .menu a::before {
  background-color: #73edff; /* blau */
}
body.header-dark .menu a::before {
  background-color: #000; /* negre */
}

/* Hover */
.menu a:hover::before {
  width: 100%;
}

/* Actiu */
.menu .current-menu-item > a::before,
.menu .current_page_item > a::before,
.menu .current-menu-ancestor > a::before,
.menu .current_page_ancestor > a::before {
  width: 100%;
}

/* Enllaç actiu amb negreta */
.menu .current-menu-item > a,
.menu .current_page_item > a,
.menu .current-menu-ancestor > a,
.menu .current_page_ancestor > a {
  font-weight: 700;
}

/* -----------------------------------------------------------
   4. Hamburguesa i cerca
   ----------------------------------------------------------- */
.hamburger,
.search-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: pointer;
}
.brand {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

/* -----------------------------------------------------------
   5. Menú mòbil responsive
   ----------------------------------------------------------- */
.mobile-menu {
  border-top: 1px solid #eee;
  padding: 0.5rem 0;
  background: transparent;
}
.mobile-menu[hidden] {
  display: none;
}
@media (max-width: 1122px) {
  .header-bar {
    flex-wrap: wrap;
    padding: 12px 1rem;
    justify-content: flex-end;
  }
  .main-navigation {
    width: 100%;
    margin-left: 0;
  }
  .menu {
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
  }
}

/* -----------------------------------------------------------
   6. Submenús (transparents i estables)
   ----------------------------------------------------------- */
.site-header {
  position: relative;
  z-index: 3000;
}
.main-navigation .menu li {
  position: relative;
}

.main-navigation .menu li > .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.15s ease;
  z-index: 4000;
  min-width: 220px;
  padding: 6px 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.main-navigation .menu li:hover > .sub-menu,
.main-navigation .menu li:focus-within > .sub-menu {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.main-navigation .menu li > .sub-menu li {
  display: block;
  width: 100%;
}

.main-navigation .menu li > .sub-menu a {
  display: block;
  width: 100%;
  white-space: nowrap;
  box-sizing: border-box;
  padding: 0.45rem 1rem;
  line-height: 1.4;
  font-weight: 500;
  background: transparent;
  border: 0;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

/* Hover */
body.home-header-light .site-header .sub-menu a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #73edff !important;
}
body.header-dark .site-header .sub-menu a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #000 !important;
}

/* -----------------------------------------------------------
   7. Flecha ▾ estàtica i alineada
   ----------------------------------------------------------- */
.site-header .menu-item-has-children > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

/* Flecha senzilla */
.site-header .menu-item-has-children > a::after {
  content: "▾";
  font-size: 0.9em;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  color: currentColor;
  margin-left: 10px;
}

/* En mòbil: submenús sempre visibles */
@media (max-width: 1122px) {
  /* NOMÉS per al menú d'escriptori si mai es fa stack, no per al mòbil */
  .desktop-menu .menu li > .sub-menu {
    position: static;
    visibility: visible;
    opacity: 1;
    transform: none;
    min-width: 0;
    padding: 0;
  }
}

/* ===========================================================
   MOBILE MENU (per damunt de la base actual)
   =========================================================== */

/* Mostrar menú mòbil estil lliscant */
@media (max-width: 1122px) {
  /* Contenidor del menú mòbil */
  .mobile-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 10px);
    width: 100%;
    padding: 1.5rem 1.25rem;
    background: #f9f3e7; /* Beige Turba */
    border-top: 2px solid #73edff;
    /* box-shadow: 0 4px 14px rgba(0,0,0,0.12); */
    animation: mobileMenuFade 0.25s ease;
    z-index: 9999;
  }

  /* Animació */
  @keyframes mobileMenuFade {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Llista vertical */
  .mobile-menu .menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  /* Links */
  .mobile-menu .menu > li > a {
    display: block;
    width: 100%;
    padding: 14px 6px;
    font-size: 20px;
    font-weight: 600;
    color: #383131; /* Gris Turba */
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    transition:
      background 0.2s ease,
      padding-left 0.25s ease;
  }

  /* Hover */
  .mobile-menu .menu > li > a:hover {
    background: #73edff; /* Blau Turba */
    color: #fff;
    padding-left: 14px;
  }

  /* Últim element sense línia */
  .mobile-menu .menu > li:last-child > a {
    border-bottom: none;
  }

  /* Submenús en mòbil → visibles, però estilats */
  .mobile-menu .sub-menu {
    width: 100%;
    padding-left: 14px;
    margin-bottom: 8px;
    background: transparent !important;
  }

  .mobile-menu .sub-menu a {
    font-size: 18px;
    padding: 10px 0;
    border: none !important;
    color: #383131;
  }

  .mobile-menu .sub-menu a:hover {
    color: #73edff;
  }

  /* Hamburguesa ben alineada */
  .hamburger {
    margin-left: auto;
    z-index: 10001;
  }
}

/* ========== MOBILE MENU: SUBMENÚS COLLAPSATS ========== */
@media (max-width: 1122px) {
  /* important: amaguem per defecte els submenús del nav mòbil */
  .mobile-menu .menu-item-has-children > .sub-menu {
    display: none !important;
  }

  /* quan el <li> té .is-open, es mostra */
  .mobile-menu .menu-item-has-children.is-open > .sub-menu {
    display: block !important;
    margin-left: 40px;
    width: auto;
  }
}

/* ========== MOBILE MENU: COLORS PER CONTEXT ========== */
@media (max-width: 1122px) {
  /* Home: fons clar, text fosc */
  body.home-header-light .mobile-menu {
    background: black;
    border-top: 2px solid #73edff;
    border-bottom: 2px solid #73edff;
  }

  body.home-header-light .mobile-menu .menu > li > a {
    color: #111;
  }

  body.home-header-light .mobile-menu .sub-menu a {
    color: #383131;
  }

  /* Resta del lloc: fons fosc, text clar */
  body.header-dark .mobile-menu {
    border-top: 2px solid black;
    border-bottom: 2px solid black;
  }

  body.header-dark .mobile-menu .menu > li > a {
    color: #f9f3e7;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }

  body.header-dark .mobile-menu .menu > li > a:hover {
    background: #73edff;
    color: #111;
  }

  body.header-dark .mobile-menu .sub-menu a {
    color: #f9f3e7;
  }

  body.header-dark .mobile-menu .sub-menu a:hover {
    color: #73edff;
  }
}

/* ===========================================================
   FIX — Estils hover MOBILE MENU
   =========================================================== */
@media (max-width: 1122px) {
  /* Hover per als enllaços principals del menú mòbil */
  .mobile-menu .menu > li > a:hover {
    color: #73edff !important;
    background: transparent;
    padding-left: 6px;
  }
  /* Subratllat animat per al menú mòbil */
  .mobile-menu .menu > li > a {
    position: relative;
  }
  .mobile-menu .menu > li > a::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: #73edff;
    transition: width 0.3s ease;
  }
  .mobile-menu .menu > li > a:hover::before {
    width: 100%;
  }
  /* Hover per als submenús */
  .mobile-menu .sub-menu a:hover {
    color: #73edff !important;
  }
  /* Context Home */
  body.home-header-light .mobile-menu .menu > li > a:hover {
    color: #73edff !important;
  }
  body.home-header-light .mobile-menu .sub-menu a {
    color: #f9f3e7 !important;
    background-color: transparent !important;
  }
  body.home-header-light .mobile-menu .sub-menu a:hover {
    color: #73edff !important;
  }
}

/* ===========================================================
   SOMBRAS MENÚ MOBILE CLARO
   =========================================================== */
@media (max-width: 1122px) {
  .mobile-menu {
    box-shadow:
      0px -6px 12px rgba(0, 0, 0, 0.08),
      /* sombra arriba suave */ 0px 12px 28px rgba(0, 0, 0, 0.15); /* sombra abajo más profunda */

    border-top: 0 !important;
    border-bottom: 0 !important;

    /* Para separar un poco más del contenido */
    position: absolute;
    z-index: 9999;
  }
}

/* ===========================================================
   RESPONSIVE MOBILE LOGO
   =========================================================== */
@media (max-width: 400px) {
  .site-branding {
    margin: inherit;
    text-align: left;
    flex-shrink: 0;
    width: 200px;
    height: 44px;
  }
}

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

@media (min-width: 1122px) and (max-width: 1200px) {
  .site-branding {
    margin: inherit !important;
  }
}
