/* =========================================================================
   Site header — final layer (loaded after style.css on every public page).

   Desktop:  [ Work · Team · Pricing ]      [ LOGO ]      [ ع · ☾ | BOOK ]
   Mobile:   [ ☰ ]                          [ LOGO ]                 [ ☾ ]
   Arabic mirrors the whole bar (navigation on the right), as RTL readers expect.
   The language/theme controls are injected by language.js into .header-actions.
   ========================================================================= */

body:not(.admin-page):not(.admin-body) .site-header {
  --hdr-h: 84px;
  --hdr-pad: clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 24px;
  min-height: var(--hdr-h);
  padding: 0 var(--hdr-pad);
  direction: ltr;
  background: color-mix(in srgb, var(--mono-dark) 88%, transparent);
  border-bottom: 1px solid var(--mono-line);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
          backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: none;
}
html[dir="rtl"] body:not(.admin-page):not(.admin-body) .site-header { direction: rtl; }
body:not(.admin-page):not(.admin-body) .site-header::after { display: none; }

/* ---------- Center: logo ---------- */
body:not(.admin-page):not(.admin-body) .site-header > .brand {
  position: static;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  transform: none;
  margin: 0;
}
body:not(.admin-page):not(.admin-body) .site-header > .brand .brand-logo { width: clamp(118px, 11vw, 150px); margin: 0; }

/* ---------- Start side: navigation ---------- */
body:not(.admin-page):not(.admin-body) .site-header > .main-nav {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.4vw, 36px);
  margin: 0;
  direction: inherit;
}
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a {
  position: relative;
  padding: 8px 0;
  color: var(--mono-text);
  font: 500 11px/1 var(--editorial-sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .72;
  transition: opacity .25s ease;
}
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .45s cubic-bezier(.16, 1, .3, 1);
}
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a:hover,
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a[aria-current="page"] { opacity: 1; color: var(--mono-text); }
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a:hover::after,
body:not(.admin-page):not(.admin-body) .site-header > .main-nav a[aria-current="page"]::after { transform: scaleX(1); }

/* ---------- End side: language · theme | Book ---------- */
body:not(.admin-page):not(.admin-body) .site-header > .header-actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
  direction: inherit;
}
body:not(.admin-page):not(.admin-body) .site-header .header-actions #siteDesktopControls.desktop-controls-bar {
  position: static;
  inset: auto;
  transform: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding-inline-end: 18px;
  border-inline-end: 1px solid var(--mono-line);
  direction: inherit;
  order: 0; /* style.css pushes it to the end with order: 3 */
}

/* Language: plain text, same voice as the navigation */
body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle.language-switcher {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 8px;
  color: var(--mono-text);
  font: 600 13px/1 var(--editorial-arabic-sans);
  opacity: .8;
  cursor: pointer;
  transition: opacity .2s ease, color .2s ease;
}
body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle.language-switcher:lang(ar),
html[dir="rtl"] body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle.language-switcher {
  font: 500 11px/1 var(--editorial-sans);
  letter-spacing: .14em;
  text-transform: uppercase;
}
body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle.language-switcher:hover { opacity: 1; color: var(--accent); }

/* Theme: a quiet icon button */
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher {
  all: unset;
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--mono-text);
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease, transform .4s cubic-bezier(.16, 1, .3, 1);
}
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle .theme-switcher-icon { width: 18px; height: 18px; stroke: currentColor; }
@media (hover: hover) and (pointer: fine) {
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  transform: rotate(-18deg);
}
}

body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle:focus-visible,
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle:focus-visible,
body:not(.admin-page):not(.admin-body) .site-header a:focus-visible,
body:not(.admin-page):not(.admin-body) .site-header .mobile-menu-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Book: the one solid element in the bar */
body:not(.admin-page):not(.admin-body) .site-header .header-actions a.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--mono-text);
  background: var(--mono-text);
  color: var(--mono-dark);
  font: 600 11px/1 var(--editorial-sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  transition: background-color .25s ease, border-color .25s ease;
}
body:not(.admin-page):not(.admin-body) .site-header .header-actions a.nav-cta:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Arabic: no tracking or uppercase */
html[dir="rtl"] body:not(.admin-page):not(.admin-body) .site-header > .main-nav a,
html[dir="rtl"] body:not(.admin-page):not(.admin-body) .site-header .header-actions a.nav-cta {
  font: 600 14px/1.2 var(--editorial-arabic-sans);
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- Tablet: tighten ---------- */
@media (min-width: 701px) and (max-width: 980px) {
  body:not(.admin-page):not(.admin-body) .site-header { column-gap: 14px; }
  body:not(.admin-page):not(.admin-body) .site-header > .main-nav { gap: 16px; }
  body:not(.admin-page):not(.admin-body) .site-header > .header-actions { gap: 10px; }
  body:not(.admin-page):not(.admin-body) .site-header .header-actions #siteDesktopControls.desktop-controls-bar { padding-inline-end: 10px; gap: 2px; }
  body:not(.admin-page):not(.admin-body) .site-header .header-actions a.nav-cta { padding: 0 12px; }
  body:not(.admin-page):not(.admin-body) .site-header > .brand .brand-logo { width: 112px; }
}

/* ---------- Mobile: ☰ · logo · theme (language lives in the menu) ---------- */
@media (max-width: 700px) {
  body:not(.admin-page):not(.admin-body) .site-header {
    --hdr-h: 68px;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    column-gap: 8px;
    padding: 0 14px;
  }
  body:not(.admin-page):not(.admin-body) .site-header > .main-nav,
  body:not(.admin-page):not(.admin-body) .site-header .header-actions a.nav-cta { display: none !important; }
  body:not(.admin-page):not(.admin-body) .site-header > .brand .brand-logo { width: min(128px, 38vw); }
  body:not(.admin-page):not(.admin-body) .site-header > .header-actions { display: contents; }
  body.has-mobile-language-menu:not(.admin-page):not(.admin-body) .site-header #siteDesktopControls.desktop-controls-bar,
  html[dir="rtl"] body.has-mobile-language-menu:not(.admin-page):not(.admin-body) .site-header #siteDesktopControls.desktop-controls-bar {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    padding: 0;
    border: 0;
  }
  body.has-mobile-language-menu:not(.admin-page):not(.admin-body) .site-header .mobile-menu-toggle,
  html[dir="rtl"] body.has-mobile-language-menu:not(.admin-page):not(.admin-body) .site-header .mobile-menu-toggle {
    all: unset;
    box-sizing: border-box;
    position: static !important;
    inset: auto !important;
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: var(--mono-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }
  body.has-mobile-language-menu:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher { width: 40px; height: 40px; margin: 0 !important; }
}

/* Touch screens: no "stuck" hover fill or focus ring after a tap. The ring is kept for keyboard users only. */
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle,
body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle,
body:not(.admin-page):not(.admin-body) .site-header .mobile-menu-toggle { -webkit-tap-highlight-color: transparent; }
body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle:focus:not(:focus-visible),
body:not(.admin-page):not(.admin-body) .site-header #siteLanguageToggle:focus:not(:focus-visible),
body:not(.admin-page):not(.admin-body) .site-header .mobile-menu-toggle:focus:not(:focus-visible) { outline: none; box-shadow: none; }
@media (hover: none), (pointer: coarse) {
  body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher,
  body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher:hover,
  body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher:focus {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--mono-text) !important;
    transform: none !important;
  }
  body:not(.admin-page):not(.admin-body) .site-header #siteThemeToggle.theme-switcher:active { opacity: .6; }
}
/* ---------- Footer (phones) ----------
   style.css reserved 84px under the links for the floating WhatsApp button, which left a
   big empty band. Keep the footer tight and just keep the links clear of the button. */
@media (max-width: 760px) {
  body:not(.admin-page):not(.admin-body) .site-footer {
    gap: 14px;
    padding: 28px 18px 30px !important;
  }
  body:not(.admin-page):not(.admin-body) .site-footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: center;
    width: 100%;
  }
  body:not(.admin-page):not(.admin-body) .site-footer { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  body:not(.admin-page):not(.admin-body) .site-footer .footer-brand { display: flex; justify-content: center; width: 100%; }
}

/* The footer already has a WhatsApp link, so the floating button steps aside while it is on screen
   (instead of reserving empty space under the links). */
.floating-whatsapp { transition: opacity .3s ease, transform .3s ease, visibility .3s; }
body.footer-in-view .floating-whatsapp { opacity: 0; visibility: hidden; transform: translateY(12px) scale(.9); pointer-events: none; }
/* ---------- Mobile menu drawer (editorial) ----------
   Big serif links with small index numbers, the language as a quiet text switch,
   Book as the one solid button, and social links at the bottom. */
@media (max-width: 700px) {
  body.has-mobile-language-menu .mobile-menu-backdrop { background: rgba(12, 10, 8, .45) !important; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  body.has-mobile-language-menu #mobileMenuDrawer.mobile-menu-drawer {
    width: min(88vw, 400px) !important;
    padding: 18px 26px calc(26px + env(safe-area-inset-bottom)) !important;
    background: var(--mono-dark) !important;
    border-inline-end: 1px solid var(--mono-line) !important;
    border-inline-start: 0 !important;
    box-shadow: 30px 0 80px rgba(0, 0, 0, .25) !important;
    transition: transform .55s cubic-bezier(.16, 1, .3, 1), visibility .55s !important;
  }
  /* Arabic: the menu button sits on the right, so the drawer slides in from the right edge. */
  html[dir="rtl"] body.has-mobile-language-menu #mobileMenuDrawer.mobile-menu-drawer {
    left: auto !important;
    right: 0 !important;
    transform: translateX(105%) !important;
    border-inline-end: 1px solid var(--mono-line) !important;
    border-inline-start: 0 !important;
    box-shadow: -30px 0 80px rgba(0, 0, 0, .25) !important;
  }
  html[dir="rtl"] body.has-mobile-language-menu #mobileMenuDrawer.mobile-menu-drawer.is-open { transform: translateX(0) !important; }
  #mobileMenuDrawer .mobile-menu-head { order: 0; min-height: 50px; padding: 0 0 18px !important; border-bottom: 1px solid var(--mono-line) !important; }
  #mobileMenuDrawer #mobileMenuTitle { color: var(--mono-muted); font: 500 11px/1 "JetBrains Mono", monospace !important; letter-spacing: .2em; text-transform: uppercase; }
  html[dir="rtl"] #mobileMenuDrawer #mobileMenuTitle { font: 600 14px/1 var(--editorial-arabic-sans) !important; letter-spacing: 0; }
  #mobileMenuDrawer .mobile-menu-close {
    all: unset; box-sizing: border-box; display: grid; place-items: center; width: 40px; height: 40px;
    color: var(--mono-text); font-size: 28px; line-height: 1; cursor: pointer; transition: transform .4s cubic-bezier(.16, 1, .3, 1);
    -webkit-tap-highlight-color: transparent;
  }
  #mobileMenuDrawer .mobile-menu-close:active { transform: rotate(90deg); }

  #mobileMenuDrawer .mobile-menu-links { order: 1; flex: 1 1 auto; gap: 0 !important; padding-top: 14px !important; counter-reset: menu; }
  #mobileMenuDrawer .mobile-menu-links a {
    position: relative;
    display: flex !important;
    align-items: baseline;
    gap: 16px;
    padding: 14px 0 !important;
    color: var(--mono-text) !important;
    font: 500 38px/1.05 var(--editorial-serif) !important;
    letter-spacing: -.02em !important;
    text-transform: none !important;
    border-bottom: 0 !important;
    -webkit-tap-highlight-color: transparent;
  }
  #mobileMenuDrawer .mobile-menu-links a:not(.mobile-menu-book)::before {
    counter-increment: menu;
    content: "0" counter(menu);
    min-width: 22px;
    color: var(--accent);
    font: 500 11px/1 "JetBrains Mono", monospace;
    letter-spacing: .04em;
    transform: translateY(-14px);
  }
  #mobileMenuDrawer .mobile-menu-links a[aria-current="page"] { color: var(--accent) !important; font-style: italic !important; }
  #mobileMenuDrawer .mobile-menu-links a:active { opacity: .6; }
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-links a { font: 600 30px/1.4 var(--editorial-arabic-display) !important; letter-spacing: 0 !important; text-align: right; }
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-links a[aria-current="page"] { font-style: normal !important; }

  /* Book: solid button at the bottom of the list */
  #mobileMenuDrawer .mobile-menu-links a.mobile-menu-book {
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding: 0 8px 0 22px !important;
    min-height: 56px;
    background: var(--mono-text);
    color: var(--mono-dark) !important;
    font: 600 12px/1 var(--editorial-sans) !important;
    letter-spacing: .14em !important;
    text-transform: uppercase !important;
  }
  #mobileMenuDrawer .mobile-menu-links a.mobile-menu-book::after {
    content: "↗"; display: grid; place-items: center; width: 40px; height: 40px; background: var(--accent); color: #fff; font-size: 16px;
  }
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-links a.mobile-menu-book { padding: 0 22px 0 8px !important; font: 600 15px/1 var(--editorial-arabic-sans) !important; letter-spacing: 0 !important; }
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-links a.mobile-menu-book::after { content: "↖"; }

  /* Language: a quiet text switch under the button */
  #mobileMenuDrawer #siteLanguageToggle.language-switcher {
    all: unset !important;
    order: 2 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    min-height: 48px !important;
    margin-top: 10px !important;
    border: 1px solid var(--mono-line) !important;
    color: var(--mono-text) !important;
    font: 600 14px/1 var(--editorial-arabic-sans) !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
  }
  #mobileMenuDrawer #siteLanguageToggle.language-switcher::before { content: "🌐"; font-size: 14px; filter: grayscale(1); opacity: .7; }
  html[dir="rtl"] #mobileMenuDrawer #siteLanguageToggle.language-switcher { font: 500 12px/1 var(--editorial-sans) !important; letter-spacing: .14em !important; text-transform: uppercase !important; }
  #mobileMenuDrawer #siteLanguageToggle.language-switcher:active { opacity: .6; }

  #mobileMenuDrawer .mobile-menu-foot { order: 3; display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--mono-line); }
  #mobileMenuDrawer .mobile-menu-foot a { color: var(--mono-muted); font: 500 11px/1 "JetBrains Mono", monospace; letter-spacing: .14em; text-transform: uppercase; }

  /* Links glide in when the drawer opens */
  #mobileMenuDrawer .mobile-menu-links a,
  #mobileMenuDrawer #siteLanguageToggle,
  #mobileMenuDrawer .mobile-menu-foot { opacity: 0; transform: translateX(-18px); transition: opacity .5s ease, transform .6s cubic-bezier(.16, 1, .3, 1); }
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-links a,
  html[dir="rtl"] #mobileMenuDrawer #siteLanguageToggle,
  html[dir="rtl"] #mobileMenuDrawer .mobile-menu-foot { transform: translateX(18px); }
  #mobileMenuDrawer.is-open .mobile-menu-links a,
  #mobileMenuDrawer.is-open #siteLanguageToggle,
  #mobileMenuDrawer.is-open .mobile-menu-foot { opacity: 1; transform: none !important; }
  #mobileMenuDrawer.is-open .mobile-menu-links a:nth-child(1) { transition-delay: .08s; }
  #mobileMenuDrawer.is-open .mobile-menu-links a:nth-child(2) { transition-delay: .13s; }
  #mobileMenuDrawer.is-open .mobile-menu-links a:nth-child(3) { transition-delay: .18s; }
  #mobileMenuDrawer.is-open .mobile-menu-links a:nth-child(4) { transition-delay: .23s; }
  #mobileMenuDrawer.is-open .mobile-menu-links a:nth-child(5) { transition-delay: .28s; }
  #mobileMenuDrawer.is-open #siteLanguageToggle { transition-delay: .32s; }
  #mobileMenuDrawer.is-open .mobile-menu-foot { transition-delay: .36s; }
}
@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  #mobileMenuDrawer .mobile-menu-links a, #mobileMenuDrawer #siteLanguageToggle, #mobileMenuDrawer .mobile-menu-foot { opacity: 1; transform: none; transition: none; }
}
