/* ============================================================
   FLAPP site header — one header for every public page.
   Markup: apps/web/src/utils/siteNav.ts · behaviour: /site-nav.js
   Colours come from the cms-theme.css tokens every page loads, with
   dark fallbacks. Pages differ in their own CSS resets, so every rule
   here sets what it needs instead of trusting the page.
   ============================================================ */

:root { --site-nav-h: 68px; }

/* cms-theme.css sets html, body { height: 100% }. Body is the sticky header's containing
   block, so at that height the header would scroll away after one screen. */
body { height: auto; }

html[lang="ar"] .site-nav [data-en],
html[lang="en"] .site-nav [data-ar] { display: none !important; }

.site-nav {
  --sn-bg: var(--bg, 222 50% 4%);
  --sn-text: var(--text, 50 11% 97%);
  --sn-muted: var(--text-muted, 30 9% 83%);
  --sn-line: var(--border, 220 15% 22%);
  --sn-accent: var(--accent, 4 70% 39%);
  --sn-glow: var(--accent-glow, 4 80% 50%);
  --sn-font: var(--font-display, 'Cairo', 'Inter', system-ui, sans-serif);
  position: sticky;
  top: 0;
  z-index: 90;
  height: 68px;
  color: hsl(var(--sn-text));
  font-family: var(--sn-font);
  text-align: start;
}
html[lang="en"] .site-nav { --sn-font: 'Inter', var(--font-display, 'Cairo', system-ui, sans-serif); }

/* Glass on a pseudo-element: a backdrop-filter on the header itself would trap the
   position:fixed mobile menu inside the 68px bar. */
.site-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: hsl(var(--sn-bg) / .76);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border-bottom: 1px solid hsl(var(--sn-line) / .7);
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
}
/* The damped-red signal line appears once the page scrolls. */
.site-nav::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(var(--sn-accent) / .85) 50%, transparent);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.site-nav.is-scrolled::before { box-shadow: 0 14px 34px -22px rgba(0, 0, 0, .7); }
.site-nav.is-scrolled::after { opacity: 1; }

.site-nav[data-variant="overlay"] { position: fixed; inset: 0 0 auto 0; }
.site-nav[data-variant="overlay"]:not(.is-scrolled):not(.is-open)::before {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom-color: transparent;
}

.sn-bar {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1240px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
}
/* Resets carry no specificity (:where), so every single-class rule below wins over them. */
:where(.site-nav) a { color: inherit; text-decoration: none; }
:where(.site-nav) button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }
:where(.site-nav) :where(ul, p) { list-style: none; margin: 0; padding: 0; }
.site-nav :focus-visible { outline: 2px solid hsl(var(--sn-glow)); outline-offset: 2px; }

/* Brand */
.sn-brand { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sn-logo { width: 32px; height: 32px; color: hsl(var(--sn-text)); filter: drop-shadow(0 4px 12px hsl(var(--sn-accent) / .35)); }
.sn-word { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: 21px; line-height: 1; letter-spacing: 1.5px; }
.sn-word-ar {
  font-size: 25px;
  letter-spacing: 0;
  background: linear-gradient(180deg, hsl(var(--sn-text)) 0%, hsl(var(--sn-muted)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Tabs */
.sn-menu { flex: 1; min-width: 0; display: flex; justify-content: center; }
.sn-nav { position: static; }
.sn-list { display: flex; align-items: center; gap: 2px; }
.sn-item { position: relative; }
.sn-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  color: hsl(var(--sn-muted));
  transition: color .2s ease, background .2s ease;
}
.sn-tab:hover,
.sn-item.is-open > .sn-tab { color: hsl(var(--sn-text)); background: hsl(var(--sn-text) / .08); }
.sn-tab[aria-current="page"],
.sn-item.is-current > .sn-tab { color: hsl(var(--sn-text)); }
.sn-tab[aria-current="page"]::after,
.sn-item.is-current > .sn-tab::after {
  content: "";
  position: absolute;
  inset-inline: 14px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: hsl(var(--sn-accent));
  box-shadow: 0 0 12px hsl(var(--sn-glow) / .75);
}
.sn-caret { width: 14px; height: 14px; opacity: .7; transition: transform .2s ease; }
.sn-item.is-open .sn-caret { transform: rotate(180deg); }

/* Dropdown panels */
.sn-panel {
  position: absolute;
  top: calc(100% + 10px);
  z-index: 2;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 20px;
  background: hsl(var(--sn-bg) / .97);
  border: 1px solid hsl(var(--sn-line) / .9);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .65), inset 0 1px 0 hsl(var(--sn-text) / .05);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
/* Bridges the gap between tab and panel so the hover survives the trip. */
.sn-panel::before { content: ""; position: absolute; inset-inline: 0; top: -14px; height: 14px; }
.sn-item.is-open > .sn-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}
.site-nav:not(.js) .sn-item--menu:hover > .sn-panel,
.site-nav:not(.js) .sn-item--menu:focus-within > .sn-panel { opacity: 1; visibility: visible; transform: none; }

/* Products: a wide panel centred under the whole bar. */
.sn-item--mega { position: static; }
.sn-panel--mega {
  top: calc(100% - 2px);
  left: 50%;
  width: min(960px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  transform: translate(-50%, 6px);
}
.sn-item.is-open > .sn-panel--mega,
.site-nav:not(.js) .sn-item--mega:hover > .sn-panel--mega,
.site-nav:not(.js) .sn-item--mega:focus-within > .sn-panel--mega { transform: translate(-50%, 0); }
.sn-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.sn-product {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  transition: background .18s ease;
}
.sn-product:hover,
.sn-product[aria-current="page"] { background: hsl(var(--sn-text) / .07); }
.sn-product-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: hsl(var(--sn-text));
  background: linear-gradient(145deg, hsl(var(--sn-accent) / .42), hsl(var(--sn-accent) / .08));
  border: 1px solid hsl(var(--sn-accent) / .5);
  box-shadow: 0 10px 22px -12px hsl(var(--sn-glow) / .8);
  transition: transform .2s ease;
}
.sn-product:hover .sn-product-icon { transform: translateY(-2px) rotate(-4deg); }
.sn-ico { width: 22px; height: 22px; }
.sn-product-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sn-product strong { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 14.5px; letter-spacing: .02em; }
.sn-product-line { font-size: 12.5px; line-height: 1.55; color: hsl(var(--sn-muted)); }
/* "Another industry?": the featured, full-width tile after the editions. Its title is
   Arabic too, so it takes the header font with no letter-spacing. */
.sn-product--custom {
  grid-column: 1 / -1;
  align-items: center;
  margin-top: 4px;
  background: linear-gradient(115deg, hsl(var(--sn-accent) / .26), hsl(var(--sn-accent) / .06) 70%);
  border: 1px solid hsl(var(--sn-accent) / .6);
  box-shadow: 0 18px 40px -26px hsl(var(--sn-glow) / .9);
}
.sn-product--custom:hover,
.sn-product--custom[aria-current="page"] { background: linear-gradient(115deg, hsl(var(--sn-accent) / .34), hsl(var(--sn-accent) / .1) 70%); }
.sn-product--custom .sn-product-icon {
  color: #fff;
  background: linear-gradient(180deg, hsl(var(--sn-glow)), hsl(var(--sn-accent)));
  border-color: transparent;
}
.sn-product-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sn-product--custom strong { font-family: var(--sn-font); letter-spacing: 0; }
.sn-badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.6;
  color: #fff;
  background: hsl(var(--sn-accent));
}
.sn-aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 100% 0%, hsl(var(--sn-accent) / .32), transparent 60%),
    hsl(var(--sn-text) / .04);
  border: 1px solid hsl(var(--sn-line) / .8);
}
.sn-aside-title { font-weight: 800; font-size: 15px; }
.sn-aside-text { font-size: 12.5px; line-height: 1.75; color: hsl(var(--sn-muted)); }
.sn-aside-link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: hsl(var(--sn-text));
}
.sn-aside-link:hover { color: hsl(var(--sn-glow)); }
.sn-arrow { width: 16px; height: 16px; transition: transform .2s ease; }
html[dir="rtl"] .sn-arrow { transform: scaleX(-1); }
.sn-aside-link:hover .sn-arrow { transform: translateX(3px); }
html[dir="rtl"] .sn-aside-link:hover .sn-arrow { transform: scaleX(-1) translateX(3px); }

/* Company: a short list under its tab. */
.sn-panel--list { inset-inline-start: 0; width: 290px; display: flex; flex-direction: column; gap: 2px; }
.sn-link { display: flex; flex-direction: column; gap: 3px; padding: 11px 12px; border-radius: 12px; transition: background .18s ease; }
.sn-link:hover,
.sn-link[aria-current="page"] { background: hsl(var(--sn-text) / .07); }
.sn-link strong { font-size: 14px; font-weight: 700; }
.sn-link-hint { font-size: 12.5px; color: hsl(var(--sn-muted)); }

/* Actions */
.sn-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sn-theme { display: inline-flex; align-items: center; }
.sn-lang {
  height: 34px;
  min-width: 42px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid hsl(var(--sn-line));
  background: hsl(var(--sn-text) / .04);
  color: hsl(var(--sn-muted));
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  transition: color .2s ease, border-color .2s ease;
}
.sn-lang:hover { color: hsl(var(--sn-text)); border-color: hsl(var(--sn-accent)); }
.sn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(180deg, hsl(var(--sn-glow)) 0%, hsl(var(--sn-accent)) 100%);
  box-shadow: 0 10px 26px -12px hsl(var(--sn-glow) / .9), inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .2s ease, box-shadow .2s ease;
}
.sn-cta:hover { transform: translateY(-1px); box-shadow: 0 16px 34px -12px hsl(var(--sn-glow) / .95), inset 0 1px 0 rgba(255, 255, 255, .25); }

.sn-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid hsl(var(--sn-line));
  background: hsl(var(--sn-text) / .05);
}
.sn-burger span,
.sn-burger span::before,
.sn-burger span::after {
  display: block;
  width: 18px;
  height: 1.6px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .25s ease, top .25s ease, background .2s ease;
}
.sn-burger span { position: relative; }
.sn-burger span::before,
.sn-burger span::after { content: ""; position: absolute; left: 0; }
.sn-burger span::before { top: -6px; }
.sn-burger span::after { top: 6px; }
.site-nav.is-open .sn-burger span { background: transparent; }
.site-nav.is-open .sn-burger span::before { top: 0; transform: rotate(45deg); }
.site-nav.is-open .sn-burger span::after { top: 0; transform: rotate(-45deg); }

.sn-menu-foot { display: none; }

/* ------------------------------------------------------------
   Phones and tablets: tabs move into a full-height drawer.
   ------------------------------------------------------------ */
@media (max-width: 1080px) {
  .sn-burger { display: inline-flex; }
  .sn-actions > .sn-cta,
  .sn-actions > .sn-theme { display: none; }
  .sn-brand { margin-inline-end: auto; }
  .sn-menu {
    position: fixed;
    inset: 68px 0 0 0;
    z-index: 89;
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px 32px;
    background: hsl(var(--sn-bg) / .98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
  }
  .site-nav.is-open .sn-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .sn-list { flex-direction: column; align-items: stretch; gap: 2px; }
  .sn-item, .sn-item--mega { position: relative; }
  .sn-tab {
    width: 100%;
    height: 54px;
    justify-content: space-between;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 17px;
    color: hsl(var(--sn-text));
  }
  .sn-tab[aria-current="page"]::after,
  .sn-item.is-current > .sn-tab::after { inset-inline-start: 0; inset-inline-end: auto; top: 16px; bottom: 16px; width: 3px; height: auto; }
  .sn-panel,
  .sn-panel--mega,
  .sn-panel--list {
    position: static;
    width: auto;
    display: none;
    padding: 2px 0 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }
  .sn-panel::before { display: none; }
  .sn-item.is-open > .sn-panel { display: flex; flex-direction: column; gap: 6px; }
  .sn-item.is-open > .sn-panel--mega,
  .site-nav:not(.js) .sn-item--mega:focus-within > .sn-panel--mega { transform: none; }
  .sn-products { grid-template-columns: 1fr; }
  .sn-menu-foot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-top: 16px;
    padding-top: 18px;
    border-top: 1px solid hsl(var(--sn-line));
  }
  .sn-menu-foot .sn-theme { justify-content: center; }
  .sn-menu-foot .sn-cta { height: 50px; font-size: 16px; }
  html.sn-lock, html.sn-lock body { overflow: hidden; }
}

@media (max-width: 420px) {
  .sn-bar { padding: 0 14px; gap: 10px; }
  .sn-word { font-size: 19px; }
  .sn-word-ar { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav *, .site-nav::before, .site-nav::after { transition: none !important; }
}

@media print {
  .site-nav { display: none; }
}
