/* =========================================================================
   COMPONENT: HEADER
   Descripció: Capçalera fixa. Logo, navigació, telèfon, CTA i drawer mòbil.
   Elements:   .header__inner, .header__logo, .header__nav, .header__nav-link,
               .header__actions, .header__phone, .header__cta,
               .header__burger, .header__drawer, .header__overlay
   Modificadors: .header--transparent (sobre hero), .header--shrunk (on scroll),
                 .header--landing (landings psico/fisio)
   ========================================================================= */

/* --- Base --- */
.header {
   position: fixed;
   top: 0;
   left: 0;
   width: 100%;
   z-index: 1000;
   height: var(--header-height-desktop);
   background-color: var(--color-white);
   border-bottom: 1px solid rgba(0, 0, 0, 0.06);
   transition: height 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.header__inner {
   max-width: 1200px;
   margin: 0 auto;
   padding: 0 2rem;
   height: 100%;
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 2rem;
}

/* --- Logo --- */
.header__logo {
   display: flex;
   align-items: center;
   text-decoration: none;
   flex-shrink: 0;
}

.header__logo img {
   height: 40px;
   width: auto;
   transition: height 0.3s ease;
}

/* --- Nav principal --- */
.header__nav {
   flex: 1 1 auto;
   min-width: 0;
}

.header__nav-list {
   list-style: none;
   padding: 0;
   margin: 0;
   display: flex;
   justify-content: center;
   gap: clamp(1rem, 1.4vw, 2rem);
}

.header__nav-link {
   font-family: var(--font-body);
   font-size: 0.85rem;
   font-weight: 500;
   letter-spacing: 0.5px;
   text-transform: uppercase;
   color: var(--color-black-soft);
   text-decoration: none;
   position: relative;
   padding-bottom: 4px;
   transition: color 0.2s ease;
   white-space: nowrap;
}

.header__nav-link::after {
   content: '';
   position: absolute;
   bottom: 0;
   left: 0;
   width: 0;
   height: 2px;
   background-color: var(--color-accent);
   transition: width 0.25s ease;
}

.header__nav-link:hover::after,
.header__nav-link--active::after {
   width: 100%;
}

.header__nav-link:hover,
.header__nav-link--active {
   color: var(--color-accent);
}

/* --- Actions --- */
.header__actions {
   display: flex;
   align-items: center;
   gap: clamp(0.75rem, 1vw, 1.5rem);
   flex-shrink: 0;
}

.header__cta {
   white-space: nowrap;
}

.header__phone {
   display: flex;
   align-items: center;
   gap: 0.4rem;
   text-decoration: none;
   color: var(--color-grey-muted);
   font-size: 0.85rem;
   font-weight: 500;
   white-space: nowrap;
   transition: color 0.2s ease;
}

.header__phone:hover {
   color: var(--color-accent);
}

/* --- Estado --transparent (sobre hero) --- */
.header--transparent {
   background-color: transparent;
   border-bottom-color: transparent;
   box-shadow: none;
}

.header--transparent .header__logo img {
   filter: brightness(0) invert(1);
   transition: filter 0.3s ease;
}

.header--transparent .header__nav-link {
   color: var(--color-white);
}

.header--transparent .header__nav-link:hover,
.header--transparent .header__nav-link--active {
   color: var(--color-white);
   opacity: 0.85;
}

.header--transparent .header__phone {
   color: rgba(255, 255, 255, 0.85);
}

.header--transparent .header__phone:hover {
   color: var(--color-white);
}

.header--transparent .header__burger span {
   background-color: var(--color-white);
}

.header--solid {
   background-color: var(--color-white);
   border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* --- Estado --shrunk (on scroll) --- */
.header--shrunk {
   height: var(--header-height-shrunk);
   box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.header--shrunk .header__logo img {
   height: 32px;
}

/* --- Hamburguesa (mòbil) --- */
.header__burger {
   display: none;
   flex-direction: column;
   justify-content: center;
   gap: 5px;
   width: 36px;
   height: 36px;
   background: none;
   border: none;
   cursor: pointer;
   padding: 4px;
   flex-shrink: 0;
}

.header__burger span {
   display: block;
   width: 100%;
   height: 2px;
   background-color: var(--color-black-soft);
   border-radius: 2px;
   transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
   transform-origin: center;
}

/* Animació X quan obert */
.header__burger[aria-expanded="true"] span:nth-child(1) {
   transform: translateY(7px) rotate(45deg);
}

.header__burger[aria-expanded="true"] span:nth-child(2) {
   opacity: 0;
   transform: scaleX(0);
}

.header__burger[aria-expanded="true"] span:nth-child(3) {
   transform: translateY(-7px) rotate(-45deg);
}

/* --- Drawer mòbil --- */
.header__drawer {
   position: fixed;
   top: 0;
   right: -100%;
   width: min(320px, 85vw);
   height: 100dvh;
   background-color: var(--color-white);
   z-index: 1100;
   display: flex;
   flex-direction: column;
   transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
   box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
   overflow-y: auto;
}

.header__drawer--open {
   right: 0;
}

.header__drawer-inner {
   padding: 6rem 2rem 2rem;
   display: flex;
   flex-direction: column;
   gap: 3rem;
   flex: 1;
}

.header__drawer-list {
   list-style: none;
   padding: 0;
   margin: 0;
   display: flex;
   flex-direction: column;
   gap: 0;
}

.header__drawer-link {
   display: block;
   padding: 1rem 0;
   font-size: 1.1rem;
   font-weight: 500;
   color: var(--color-black-soft);
   text-decoration: none;
   border-bottom: 1px solid rgba(0, 0, 0, 0.07);
   transition: color 0.2s ease;
}

.header__drawer-link:hover,
.header__drawer-link--active {
   color: var(--color-accent);
}

.header__drawer-actions {
   display: flex;
   flex-direction: column;
   gap: 1rem;
   margin-top: auto;
}

.header__drawer-phone {
   display: block;
   text-align: center;
   color: var(--color-grey-muted);
   text-decoration: none;
   font-size: 0.95rem;
   padding: 0.75rem;
   border: 1px solid rgba(0, 0, 0, 0.1);
   border-radius: 8px;
   transition: color 0.2s ease;
}

.header__drawer-phone:hover {
   color: var(--color-accent);
}

/* --- Overlay fosc rere el drawer --- */
.header__overlay {
   position: fixed;
   inset: 0;
   background: rgba(0, 0, 0, 0.5);
   z-index: 1050;
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.35s ease;
}

.header__overlay--visible {
   opacity: 1;
   pointer-events: all;
}

@media (max-width: 1360px) {
   .header__inner {
      padding: 0 1rem;
      gap: 1rem;
   }

   .header__nav-link {
      font-size: 0.8rem;
      letter-spacing: 0.3px;
   }

   .header__phone {
      display: none;
   }

   .header__cta {
      font-size: 0.8rem;
      padding: 0.7rem 1rem;
   }
}

@media (max-width: 1120px) {
   .header__nav-list {
      gap: 0.8rem;
   }
}

/* --- Responsive: ocultar nav en mòbil --- */
@media (max-width: 768px) {
   .header {
      height: var(--header-height-mobile);
   }

   .header--shrunk {
      height: var(--header-height-mobile-shrunk);
   }

   .header__nav,
   .header__phone {
      display: none;
   }

   .header__burger {
      display: flex;
      margin-left: auto;
   }

   .header__cta {
      display: none;
      /* El CTA del header s'amaga: el del drawer és suficient */
   }
}

@media (max-width: 480px) {
   .header__inner {
      padding: 0 1rem;
   }
}

/* --- Landing: ajustos desktop per evitar overflow del header --- */
.header--landing .header__inner {
   max-width: 1360px;
   padding: 0 1rem;
   gap: 0.9rem;
}

.header--landing .header__nav-list {
   gap: 0.65rem;
}

.header--landing .header__nav-link {
   font-size: 0.78rem;
   letter-spacing: 0.2px;
}

.header--landing .header__actions {
   gap: 0.75rem;
}

.header--landing .header__phone {
   font-size: 0.8rem;
}

.header--landing .header__cta {
   font-size: 0.8rem;
   padding: 0.7rem 1rem;
}

@media (max-width: 1320px) {
   .header--landing .header__phone {
      display: none;
   }
}