/* Header — invisible on the hero itself, only appearing once the user has
   fully scrolled past the hero's opening moment (logo grow-in, welcome text,
   coffee line) into the story beyond it — not on the first scroll tick.
   The bar/logo/hamburger fade in as a group via .is-scrolled; the nav links
   and language switch are controlled separately (below) so a menu opened
   just before scrolling back up into the hero stays reachable — without the
   bar, logo or hamburger reappearing — instead of snapping shut. */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Above .nav-backdrop (150) so the open menu's own close button stays
     bright and clickable instead of sitting dimmed under the backdrop. */
  z-index: 160;
  padding: 12px 0;
  background-color: transparent;
  pointer-events: none;
  transition: background-color 0.3s ease;
}

.site-header.is-scrolled {
  background-color: rgba(45, 45, 45, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-brand,
.main-nav,
.nav-toggle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.site-header.is-scrolled .header-brand,
.site-header.is-scrolled .main-nav,
.site-header.is-scrolled .nav-toggle {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile's sidebar (see the max-width: 768px block further down) has to be
   reachable the instant the page opens, not just once .is-scrolled kicks
   in — a visitor scrolling the hero shouldn't have the menu unreachable
   the whole time. .main-nav.is-open is two classes (0,2,0) vs. the plain
   .main-nav above (0,1,0), so this naturally wins without !important. */
.main-nav.is-open {
  opacity: 1;
  pointer-events: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.header-logo-mark {
  display: block;
  width: 62px;
  aspect-ratio: 782.01 / 397.2;
  -webkit-mask-image: url('../../assets/icons/tdx-logo.svg');
  mask-image: url('../../assets/icons/tdx-logo.svg');
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  background-color: var(--color-text);
}

/* Desktop: always laid out as a plain inline row, no hamburger involved —
   .header-brand/.main-nav above handle its fade-in on scroll, this just
   handles the link row itself. Below 768px (see that media query further
   down) this same element instead becomes a slide-in sidebar, toggled by
   .nav-toggle, which is display: none up here on desktop. */
.main-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(245, 241, 234, 0.3);
  background: none;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.nav-toggle:hover {
  border-color: var(--color-teal);
}

.nav-toggle-bar {
  width: 15px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--color-text);
}

.main-nav a {
  display: inline-block;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.92;
  transition: transform 0.2s ease;
}

/* Deliberately size-only — no color/opacity shift on hover, same treatment
   as .lang-switch:hover below. */
.main-nav a:hover {
  transform: scale(1.08);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 17px;
  color: var(--color-text);
  border: 1px solid rgba(245, 241, 234, 0.3);
  font-family: var(--font-en);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.3s ease;
}

.site-header.is-scrolled .lang-switch {
  opacity: 1;
  pointer-events: auto;
}

.lang-switch:hover {
  transform: scale(1.08);
}

@media (max-width: 768px) {
  /* The plain inline row (fine on desktop) read as too cramped right next
     to the logo on a phone — back to a hamburger that opens a slide-in
     sidebar instead. inset-inline-end (not right/left, and not a
     transform) so the slide direction is automatically correct for both
     the Arabic (RTL) and English (LTR) pages with no [dir] override
     needed: animating a logical inset property already respects direction
     on its own. */
  .nav-toggle {
    display: flex;
    /* Above the slide-in panel (.main-nav, 200, same stacking context) — the
       panel is full height and used to cover this button, leaving no visible
       way to close the menu. */
    position: relative;
    z-index: 210;
  }

  .nav-toggle-bar {
    transition: transform 0.28s ease, opacity 0.2s ease;
  }

  .nav-toggle.is-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .nav-toggle.is-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.is-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }

  .main-nav {
    position: fixed;
    top: 0;
    inset-inline-end: -85vw;
    z-index: 200;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 28px;
    width: min(300px, 85vw);
    height: 100vh;
    height: 100dvh;
    padding: 32px;
    background: rgba(20, 18, 16, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    white-space: normal;
    transition: inset-inline-end 0.35s ease;
  }

  .main-nav.is-open {
    inset-inline-end: 0;
  }

  .main-nav a {
    font-size: 18px;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
  }

  .nav-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }
}
