/* ───────────────────────────────────────────────────────────────────────────
   Sysonaut site header — the single shared top bar used on every page except
   the editor. Rendered as React (<SiteHeader>) on /pricing & /dashboard and
   injected as the same markup by shared-layout.js on the static landing/presales
   pages. Hover mega-menus are CSS-only (no JS), so both contexts behave alike.

   Theme: dark is signalled by `.dark` on <html> (the app's Carbon convention;
   shared-layout.js also adds/removes `.dark` on the static pages). Light is the
   base; `.dark` overrides. Class-prefixed `.sy-hdr*` so it never collides with
   the landing page's own `nav {}` rules. Carbon flavour: IBM Plex, blue-60
   accent, square corners, layer panels, subtle hairline borders.
   ─────────────────────────────────────────────────────────────────────────── */

.sy-hdr {
  --sy-bg: #ffffff;
  --sy-fg: #0a0a0a;
  --sy-fg2: #666666;
  --sy-accent: #0f62fe;
  --sy-accent-hover: #0353e9;
  --sy-border: #e5e5e5;
  --sy-layer: #ffffff;
  --sy-layer-2: #f4f4f4;
  --sy-shadow: rgba(0, 0, 0, 0.12);
  /* Carbon header height — also drives the shared grid switcher button size
     (switcher-menu.css reads var(--nr-header-h)), so the icon fills the bar. */
  --nr-header-h: 48px;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  z-index: 1000;
  /* Transparent at the top of the page so the header sits directly on the page
     background; the opaque bar fades in once the page is scrolled (and is always
     shown on docs/checkout surfaces). See .sy-hdr--scrolled / .sy-hdr--docs. */
  background: transparent;
  /* No divider until the page is scrolled. */
  border-bottom: 1px solid transparent;
  transition:
    background-color 150ms ease,
    border-color 150ms ease;
  font-family:
    'IBM Plex Sans',
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--sy-fg);
}

.sy-hdr--scrolled {
  background-color: var(--sy-bg);
  border-bottom-color: var(--sy-border);
}

/* Docs surfaces always show the header divider + bar (frames the docs layout). */
.sy-hdr--docs {
  background-color: var(--sy-bg);
  border-bottom-color: var(--sy-border);
}

.dark .sy-hdr {
  --sy-bg: #0a0a0a;
  --sy-fg: #ededed;
  --sy-fg2: #a1a1a1;
  --sy-border: #1e1e1e;
  --sy-layer: #161616;
  --sy-layer-2: #262626;
  --sy-shadow: rgba(0, 0, 0, 0.5);
}

.sy-hdr-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
}

/* ── Brand ──────────────────────────────────────────────────────────────── */
/* Nasalization — the Sysonaut wordmark display face (self-hosted, licensed .otf
   in public/fonts/). Used only for the top-bar brand name, always uppercase. */
@font-face {
  font-family: 'Nasalization';
  src:
    url('/fonts/nasalization.woff2') format('woff2'),
    url('/fonts/nasalization.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.sy-hdr-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--sy-fg);
  margin-right: 16px;
}
.sy-hdr-logo {
  font-family: 'Material Symbols Outlined';
  font-size: 26px;
  line-height: 1;
  color: var(--sy-fg);
}
.sy-hdr-brandname {
  /* Outlined vector wordmark (SysonautWordmark) — height-sized, colour via
     currentColor from .sy-hdr-brand. No webfont dependency, so no FOUT flicker. */
  height: 15px;
  width: auto;
  display: block;
}

/* ── Menu ───────────────────────────────────────────────────────────────── */
.sy-hdr-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.sy-hdr-item {
  position: relative;
  display: flex;
  align-items: center;
  height: 48px;
}
.sy-hdr-trigger,
.sy-hdr-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  padding: 0 12px;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.875rem;
  color: var(--sy-fg2);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms;
}
.sy-hdr-trigger:hover,
.sy-hdr-link:hover,
.sy-hdr-item:hover .sy-hdr-trigger {
  color: var(--sy-fg);
}
.sy-hdr-caret {
  width: 14px;
  height: 14px;
  fill: currentColor;
  transition: transform 150ms;
}
.sy-hdr-item:hover .sy-hdr-caret {
  transform: rotate(180deg);
}

/* ── Hover popup (CSS-only) ─────────────────────────────────────────────── */
.sy-hdr-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0;
  padding: 8px;
  min-width: 280px;
  background: var(--sy-layer);
  border: 1px solid var(--sy-border);
  box-shadow: 0 12px 32px var(--sy-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 140ms;
  pointer-events: none;
}
.sy-hdr-item:hover .sy-hdr-popup,
.sy-hdr-item:focus-within .sy-hdr-popup {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
/* Right after a client-side navigation (class set by SiteHeader on pathname
   change), force every nav popup shut even if the cursor still sits over the
   item or its link kept focus — overrides the :hover / :focus-within rule above.
   The class is removed as soon as the pointer leaves the header or interacts
   again, so normal hover behaviour resumes. */
.sy-hdr--nav .sy-hdr-popup {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.sy-hdr-popup--wide {
  min-width: 340px;
}

.sy-hdr-pop-heading {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sy-fg2);
  opacity: 0.7;
  padding: 8px 12px 4px;
}
.sy-hdr-pop-link {
  display: flex;
  flex-direction: row;
  /* Center the icon across both text lines (title + description). */
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--sy-fg);
  transition: background 120ms;
}
.sy-hdr-pop-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  /* Square, almost-transparent backing; monochrome glyph follows the text. */
  background: rgba(141, 141, 141, 0.14);
  color: inherit;
  transition:
    background 120ms,
    color 120ms;
}
.sy-hdr-pop-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* Hover INVERTS the mono style — the square fills with the fg colour and the
   glyph turns the bg colour (white-on-black in dark, black-on-white in light).
   The muted description line switches to the fg colour too. No row highlight. */
.sy-hdr-pop-link:hover .sy-hdr-pop-icon {
  background: var(--sy-fg);
  color: var(--sy-bg);
}
.sy-hdr-pop-link:hover .sy-hdr-pop-desc {
  color: var(--sy-fg);
}
.sy-hdr-pop-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sy-hdr-pop-title {
  font-size: 0.875rem;
  font-weight: 500;
}
.sy-hdr-pop-desc {
  font-size: 0.78rem;
  color: var(--sy-fg2);
  line-height: 1.4;
}

/* ── Right side ─────────────────────────────────────────────────────────── */
.sy-hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
/* Auth controls: both are always in the DOM; the `sy-authed` class on <html>
   (set pre-paint by AUTH_INIT from the session cookie) decides which shows, so the
   correct one paints on the first frame with no flash. Default = logged-out view:
   Login shown, Dashboard + grid switcher hidden. */
.sy-hdr-workspaces,
.sy-hdr-switcher {
  display: none;
}
html.sy-authed .sy-hdr-login {
  display: none;
}
html.sy-authed .sy-hdr-workspaces {
  display: inline-flex;
}
html.sy-authed .sy-hdr-switcher {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  /* Reserve the grid button's exact footprint (it is built imperatively after
     hydration). Without this the empty 0-width slot lets the Dashboard button sit
     too far right, then jump left when the button drops in — a visible wobble.
     Matches .nr-header-switcher__btn's `width: var(--nr-header-h, 40px)`. */
  width: var(--nr-header-h, 40px);
}
/* Static placeholder grid icon: server-rendered, so the button shows on the first
   paint (like Dashboard). Overlays the reserved slot; the interactive switcher is
   built on mount into the sibling .sy-hdr-switcher-mount, and once present the
   :has() rule drops this. Colour tracks the real button (.nr-header-switcher__btn:
   #c6c6c6 dark; --sy-fg in light via the W2-2 override below). */
.sy-hdr-grid-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c6c6c6;
  pointer-events: none;
}
html:not(.dark) .sy-hdr .sy-hdr-grid-fallback {
  color: var(--sy-fg);
}
.sy-hdr-switcher:has(.nr-header-switcher) .sy-hdr-grid-fallback {
  display: none;
}
.sy-hdr-switcher-mount {
  display: flex;
  align-items: center;
  margin-left: auto;
}
/* Grid switcher flush in the top-right corner (Carbon header action). The button
   keeps its intrinsic 48×48 square size (switcher-menu.css: width/height =
   var(--nr-header-h)), so it fills the bar height. Pull it past the inner's 24px
   right padding so its right edge sits flush at the viewport edge — no space
   above or beside it. (Do NOT override the button height to 100% here: that
   replaces the definite 48px with a percentage that has no definite parent to
   resolve against, collapsing the button to its content height.) */
.sy-hdr-switcher {
  align-self: stretch;
  margin-right: -24px;
}
/* On the marketing pages the header has no bottom divider, so the open grid
   popup needs its own top border to separate it from the bar (scoped to .sy-hdr;
   the editor / dashboard headers already have a divider). But the border must NOT
   run under the grid button itself — the popup connects seamlessly to the icon
   there. So draw it as a partial line that stops short of the button column
   (the rightmost --nr-header-h px), instead of a full-width border-top. */
.sy-hdr .nr-switcher-panel--open::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: var(--nr-header-h, 48px);
  height: 1px;
  background: #393939;
}

/* ── Grid menu: light on the marketing pages in LIGHT mode (W2-2) ──────────────
   The shared switcher (switcher-menu.css) is hard-dark — correct on the editor,
   the dashboard, and marketing-in-dark. On the marketing pages in light mode it
   should go light instead. Scoped to .sy-hdr + html:not(.dark) so it never
   touches the other surfaces (and covers both the React and static pages, where
   light mode may carry no class at all). Colours come from the .sy-* tokens. */
html:not(.dark) .sy-hdr .nr-header-switcher__btn {
  color: var(--sy-fg);
}
html:not(.dark) .sy-hdr .nr-header-switcher__btn:hover {
  background: var(--sy-layer-2);
  color: var(--sy-fg);
}
html:not(.dark) .sy-hdr .nr-header-switcher:has(.nr-switcher-panel--open) .nr-header-switcher__btn {
  background: var(--sy-bg);
  color: var(--sy-fg);
  box-shadow: -1px 0 0 var(--sy-border);
}
html:not(.dark) .sy-hdr .nr-switcher-panel {
  background: var(--sy-bg);
}
html:not(.dark) .sy-hdr .nr-switcher-panel--open {
  border-left-color: var(--sy-border);
  border-bottom-color: var(--sy-border);
}
html:not(.dark) .sy-hdr .nr-switcher-panel--open::before {
  background: var(--sy-border);
}
html:not(.dark) .sy-hdr .nr-switcher-divider {
  color: var(--sy-fg2);
  border-bottom-color: var(--sy-border);
}
html:not(.dark) .sy-hdr .nr-switcher-link {
  /* Main entries are dark grey (not pure black) in light mode. */
  color: #525252;
}
html:not(.dark) .sy-hdr .nr-switcher-link:hover {
  background: var(--sy-layer-2);
  color: var(--sy-fg);
}
html:not(.dark) .sy-hdr .nr-switcher-appearance-label {
  color: #525252;
}
html:not(.dark) .sy-hdr .nr-switcher-seg {
  background: var(--sy-layer-2);
}
html:not(.dark) .sy-hdr .nr-switcher-seg-btn {
  color: var(--sy-fg2);
}
html:not(.dark) .sy-hdr .nr-switcher-seg-btn:hover {
  color: var(--sy-fg);
}
html:not(.dark) .sy-hdr .nr-switcher-seg-btn--active {
  background: var(--sy-bg);
  color: var(--sy-fg);
  box-shadow: 0 0 0 1px var(--sy-border);
}
.sy-hdr-theme {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  /* Subtle fill, no border. */
  background: var(--sy-layer-2);
  border: none;
  color: var(--sy-fg2);
  cursor: pointer;
  transition:
    color 120ms,
    background 120ms;
}
.sy-hdr-theme:hover {
  color: var(--sy-fg);
  background: var(--sy-border);
}
.sy-hdr-theme svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* Show the icon for the action the click performs: moon in light (→ dark),
   sun in dark (→ light). */
.sy-hdr-theme .ico-sun {
  display: none;
}
.dark .sy-hdr-theme .ico-sun {
  display: block;
}
.dark .sy-hdr-theme .ico-moon {
  display: none;
}

.sy-hdr-account {
  font-size: 0.875rem;
  color: var(--sy-fg2);
  text-decoration: none;
  padding: 8px 12px;
  transition: color 120ms;
}
.sy-hdr-account:hover {
  color: var(--sy-fg);
}
.sy-hdr-cta {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--sy-accent);
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms;
}
.sy-hdr-cta:hover {
  background: var(--sy-accent-hover);
}

/* Logged-in: a Carbon primary "Dashboard" button + the editor's grid icon.
   32px tall (Carbon sm) so it sits comfortably inside the 48px header bar.
   Hidden by default; `html.sy-authed` (set pre-paint) reveals it — see the auth
   controls block under .sy-hdr-right. */
.sy-hdr-workspaces {
  display: none;
  align-items: center;
  justify-content: center;
  height: 32px;
  /* Carbon button type/shape, but sized to its content (not the full
     wide-right-padding Carbon block). Square, regular weight, 0.16px tracking.
     Blue = #0f62fe (Carbon button-primary, via --sy-accent). */
  padding: 0 14px;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.28572;
  letter-spacing: 0.16px;
  color: #fff;
  background: var(--sy-accent);
  border: none;
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
  transition: background 70ms cubic-bezier(0, 0, 0.38, 0.9);
}
.sy-hdr-workspaces:hover {
  color: #fff;
  background: var(--sy-accent-hover);
}
.sy-hdr-grid {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--sy-layer-2);
  border: none;
  color: var(--sy-fg2);
  text-decoration: none;
  cursor: pointer;
  transition:
    color 120ms,
    background 120ms;
}
.sy-hdr-grid:hover {
  color: var(--sy-fg);
  background: var(--sy-border);
}
.sy-hdr-grid svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Logged-out: a single primary "Login / Signup" button. 32px tall (Carbon sm),
   matching the logged-in Dashboard button. Pulled toward the edge so it doesn't
   leave the inner's full 24px gutter on its right. */
.sy-hdr-login {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  margin-right: -8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--sy-accent);
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms;
}
.sy-hdr-login:hover {
  background: var(--sy-accent-hover);
}

/* ── Mobile hamburger + drop-down nav ──────────────────────────────────────
   Above 900px the desktop `.sy-hdr-nav` is shown and these are hidden. At/below
   900px the nav is hidden (below) and the hamburger reveals a stacked panel so
   Pricing / Resources / … stay reachable on phones. */
.sy-hdr-burger {
  display: none; /* shown only ≤900px (media query below) */
  align-items: center;
  justify-content: center;
  width: var(--nr-header-h); /* 48px — matches the right grid button */
  padding: 0;
  border: 0;
  border-radius: 0; /* hover fill is square (angular), never rounded */
  background: transparent; /* no persistent background — only on hover */
  color: var(--sy-fg);
  cursor: pointer;
}
.sy-hdr-burger:hover {
  background: var(--sy-layer-2);
}
.sy-hdr-burger svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.sy-hdr-mobile {
  display: none; /* opened via [data-open], only ≤900px */
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: var(--sy-bg);
  border-bottom: 1px solid var(--sy-border);
  box-shadow: 0 8px 24px var(--sy-shadow);
}
.sy-hdr-mlink {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--sy-fg);
  font-size: 15px;
  text-decoration: none;
}
.sy-hdr-mlink:hover {
  background: var(--sy-layer-2);
}
.sy-hdr-mhead {
  padding: 12px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sy-fg2);
}

@media (max-width: 900px) {
  .sy-hdr-nav,
  .sy-hdr-account,
  .sy-hdr-ea,
  .sy-hdr-logo {
    /* Hidden on mobile: the Early Access badge (so it can't crowd the bar) and
       the logo symbol (the hamburger takes its top-left spot). The brand name
       text stays. The `.sy-hdr-ea` span sets no `display` inline, so this wins. */
    display: none;
  }
  .sy-hdr-burger {
    display: inline-flex;
    align-self: stretch; /* fill the 48px bar height */
    /* Flush into the top-left corner (cancel the inner's 24px left padding),
       mirroring the grid switcher's flush-right corner. Removes the left gap. */
    margin-left: -24px;
    margin-right: 4px;
  }
  .sy-hdr-mobile[data-open] {
    display: flex;
  }
}
