/**
 * header.css
 * Sticky site header, primary navigation (desktop + mobile drawer), and
 * the floating WhatsApp / back-to-top action buttons.
 */

/* IMPORTANT: `.site-header` itself must NOT carry `backdrop-filter` (or
   `filter`/`transform`/`will-change`) directly — any of those properties
   make the element establish a new containing block for `position: fixed`
   descendants, which would trap `.main-nav`'s full-viewport mobile drawer
   inside this ~76px-tall bar instead of the real viewport. The frosted-glass
   effect is applied on a `::before` pseudo-element instead, which keeps
   `.site-header` "clean" for its fixed-position children.

   Using `position: fixed` here (not `sticky`) is deliberate: `sticky`
   relies on the nearest scrolling ancestor, and `overflow-x: hidden` on
   `html`/`body` (needed to guarantee zero horizontal scroll) forces their
   computed `overflow-y` to `auto`, which silently breaks `sticky` in most
   browsers. `fixed` anchors directly to the viewport regardless, so the
   header stays pinned reliably. Because a fixed element is removed from
   normal flow, `body` gets `padding-top: var(--header-height)` (see
   base.css) so page content isn't hidden underneath it. */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow var(--duration-base) var(--ease-out);
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: var(--space-sm);
  min-width: 0;
}

/* --- Brand -------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-md);
  color: var(--color-ink-900);
  flex-shrink: 0;
  min-width: 0;
}

.brand__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--gradient-accent);
  color: var(--color-white);
  flex-shrink: 0;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* Desktop CTA in the header bar is hidden until there is guaranteed room
   for it (see the 1180px breakpoint below) — on mobile/tablet the same
   call-to-action lives inside the drawer instead (.main-nav__cta). */
.site-header__actions .btn--primary.btn--sm {
  display: none;
}

/* --- Mobile nav toggle (hamburger) ---------------------------------------- */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  color: var(--color-ink-800);
  flex-shrink: 0;
}

.nav-toggle:hover {
  background: var(--color-surface-alt);
}

.nav-toggle__icon--close {
  display: none;
}

.nav-toggle[aria-expanded='true'] .nav-toggle__icon--open {
  display: none;
}

.nav-toggle[aria-expanded='true'] .nav-toggle__icon--close {
  display: inline-flex;
}

/* --- Mobile-first default: off-canvas drawer ------------------------------
   This is the baseline behaviour for every screen narrower than the
   1180px desktop breakpoint below. Defined with explicit longhand
   top/left/right/bottom (not the `inset` shorthand) and a hard `width`
   so it can never contribute to page-level horizontal overflow. */
.main-nav {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 100%;
  max-width: 100%;
  background: var(--color-white);
  padding: var(--space-lg) var(--container-pad) var(--space-xl);
  transform: translateY(-12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out),
    visibility 0s linear var(--duration-base);
}

.main-nav.is-open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.main-nav__list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3xs);
}

.main-nav__link {
  display: block;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--color-ink-700);
}

.main-nav__link:hover,
.main-nav__link:focus-visible {
  background: var(--color-surface-alt);
  color: var(--color-ink-900);
}

.main-nav__cta {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.main-nav__cta .btn {
  width: 100%;
}

/* --- Desktop: inline nav ----------------------------------------------------
   Switched on only from a generously wide breakpoint so the logo, all 5
   nav links, and the CTA button always have comfortable room and never
   compete for space, wrap, or overlap. */
@media (min-width: 1180px) {
  .main-nav {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: auto;
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
    width: auto;
    max-width: none;
    background: transparent;
    padding: 0;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    overflow: visible;
    transition: none;
  }

  .main-nav__list {
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: nowrap;
  }

  .main-nav__link {
    position: relative;
    display: inline-block;
    padding: var(--space-2xs) 0;
    border-radius: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-ink-600);
    white-space: nowrap;
  }

  .main-nav__link:hover,
  .main-nav__link:focus-visible {
    background: none;
    color: var(--color-ink-900);
  }

  .main-nav__link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    background: var(--color-accent-600);
    transition: width var(--duration-base) var(--ease-out);
  }

  .main-nav__link:hover::after {
    width: 100%;
  }

  .main-nav__cta {
    display: none;
  }

  .site-header__actions .btn--primary.btn--sm {
    display: inline-flex;
  }

  .nav-toggle {
    display: none;
  }
}

/* --- Floating actions (WhatsApp + back to top) ---------------------------- */
.floating-actions {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2xs);
}

.floating-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    opacity var(--duration-base) var(--ease-out);
}

.floating-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.floating-btn--primary {
  background: #1fb855;
  color: var(--color-white);
  padding: var(--space-sm) var(--space-md);
  font-weight: 700;
  font-size: var(--fs-sm);
}

.floating-btn--secondary {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  color: var(--color-ink-700);
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.floating-btn--secondary.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 480px) {
  .floating-btn__label {
    display: none;
  }
  .floating-btn--primary {
    width: 48px;
    height: 48px;
    padding: 0;
    justify-content: center;
  }
}
