/* The DataGarden — site header (DMR-1298).

   One stylesheet for the one header: loaded by the marketing pages (with
   marketing.css) and by the app shell (with app.css / theme.css). The palette
   is declared on the header's own elements rather than :root, so the app —
   which has its own tokens — gets exactly these colours here and nowhere else. */
.site-nav, .mobile-drawer, .mobile-drawer-backdrop, .nav-account {
  --dark: #1A2632;
  --dark2: #2B3A42;
  --green: #2C6E49;
  --green-light: #3a8f61;
  --gold: #E8B84B;
  --muted: #8A9BA8;
  --white: #ffffff;
}
.site-nav a, .mobile-drawer a { color: inherit; text-decoration: none; }
.site-nav ul, .mobile-drawer ul { margin: 0; padding: 0; }

/* ───── NAV ───── */
nav.site-nav {
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
  background: rgba(26,38,50,0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(232,184,75,0.2);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.nav-logo { display: flex; align-items: center; gap: 0.75rem; }
.nav-logo-mark {
  width: 36px; height: 36px; background: var(--green);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: bold; color: var(--white);
}
.nav-logo-text {
  font-size: 1rem; font-weight: bold; color: var(--white);
  letter-spacing: 0.02em;
}
.nav-links {
  display: flex; gap: 2rem; align-items: center;
  list-style: none; margin: 0; padding: 0;
}
.nav-links > li { position: relative; }
.nav-links a, .nav-trigger {
  color: var(--muted); font-family: Calibri, sans-serif; font-size: 0.9rem;
  transition: color 0.2s; cursor: pointer; background: none; border: none;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.nav-links a:hover, .nav-trigger:hover { color: var(--white); }
.nav-links a.active { color: var(--gold); }

/* Solutions dropdown */
.nav-dropdown {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  min-width: 320px; background: var(--dark2);
  border: 1px solid rgba(232,184,75,0.2);
  border-radius: 12px; padding: 0.75rem;
  box-shadow: 0 20px 48px rgba(0,0,0,0.5);
  display: none; list-style: none;
}
.nav-links > li:hover .nav-dropdown,
.nav-links > li:focus-within .nav-dropdown,
.nav-dropdown.open { display: block; }
.nav-dropdown li { list-style: none; }
.nav-dropdown a {
  display: block; padding: 0.75rem 1rem; border-radius: 8px;
  color: var(--white); font-family: Calibri, sans-serif;
  transition: background 0.15s;
}
.nav-dropdown a:hover { background: rgba(44,110,73,0.2); color: var(--white); }
.nav-dropdown .sol-title {
  font-size: 0.92rem; font-weight: bold; color: var(--white);
  margin-bottom: 0.15rem;
}
.nav-dropdown .sol-desc {
  font-size: 0.78rem; color: var(--muted); line-height: 1.4;
}

.nav-actions { display: flex; align-items: center; gap: 0.75rem; }
.btn-login {
  color: var(--white); font-family: Calibri, sans-serif;
  font-size: 0.875rem; padding: 0.5rem 1rem;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-login:hover { border-color: var(--gold); color: var(--gold); }
.btn-subscribe {
  background: var(--green); color: var(--white);
  padding: 0.5rem 1.25rem; border-radius: 6px;
  font-family: Calibri, sans-serif; font-size: 0.875rem; font-weight: bold;
  transition: background 0.2s, transform 0.2s;
}
.btn-subscribe:hover { background: var(--green-light); transform: translateY(-1px); }

/* Working context selectors (DMR-1623) — country/project/brand, replacing the
   marketing nav inside the app (header_in_app). Reuses .nav-trigger's base
   colour/hover (declared above); this rule has to come after that one to win
   the cascade on equal specificity.

   DMR-1626: a glyph beside the value, one line — not a label above it. The
   glyph (country's flag, or a literal icon for Project/Brand) takes the
   label's old place, so it is sized and coloured like the label was rather
   than like the bold value beside it. */
.nav-context-controls { gap: 1.5rem; }
.nav-context-btn {
  flex-direction: row; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0; text-align: left;
}
.nav-context-btn-flag { font-size: 0.95rem; line-height: 1; flex-shrink: 0; }
.nav-context-btn-icon { color: var(--muted); flex-shrink: 0; }
.nav-context-btn:hover .nav-context-btn-icon { color: var(--gold); }
.nav-context-btn-value {
  font-size: 0.85rem; color: var(--white); font-weight: bold;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-context-btn:hover .nav-context-btn-value { color: var(--gold); }
/* An unset selection reads as muted, not as a bold claim about nothing. */
.nav-context-btn-value.unset { color: var(--muted); font-weight: normal; }
/* Brand alone drops its placeholder entirely when unset (DMR-1626 scope item
   4) — the button shows its icon and nothing else, rather than "Select a
   brand…" beside it. dgHeaderSetBrand() never writes placeholder text into
   this span, so an empty, hidden span is always what "unset" looks like here. */
.nav-brand-value.unset { display: none; }

/* Mobile drawer copies — full-width rows matching the drawer's own links
   rather than the desktop chip's compact width. */
.mobile-drawer-nav button.nav-context-btn {
  display: flex; width: 100%;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit;
}
.mobile-drawer-nav button.nav-context-btn:hover { background: rgba(44,110,73,0.18); }
.mobile-drawer-nav button.nav-context-btn .nav-context-btn-value {
  max-width: none; color: var(--white); font-size: 0.95rem;
}

/* "Your Dashboards" menu (DMR-1297) — the signed-in CTA is a dropdown, styled
   as the Solutions one but anchored to the right edge so it stays on screen. */
.nav-dashboards { position: relative; }
.nav-dashboards-trigger { border: none; cursor: pointer; }
.nav-dashboards .nav-dropdown {
  left: auto; right: 0; transform: none; min-width: 240px;
}
/* Click-open only (DMR-1303): a hover-open panel beside a click-open one
   is two menus showing at once. */
.nav-badge {
  display: inline-block; margin-left: 0.4rem; padding: 0.1rem 0.4rem;
  border-radius: 999px; font-size: 0.62rem; font-weight: bold;
  letter-spacing: 0.08em; text-transform: uppercase; vertical-align: middle;
  background: rgba(232,184,75,0.18); color: var(--gold);
}

/* Account menu (DMR-1303) — the same panel as Your Dashboards, right-aligned. */
.nav-account { position: relative; }
.nav-account-trigger {
  width: 38px; height: 38px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px; color: var(--white); cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.nav-account-trigger:hover,
.nav-account-trigger[aria-expanded="true"] { border-color: var(--gold); color: var(--gold); }
/* On a light bar (the My Account pages) the trigger takes the bar's ink. */
.nav-account--light .nav-account-trigger { color: #4b5563; border-color: #e5e7eb; }
.nav-account--light .nav-account-trigger:hover,
.nav-account--light .nav-account-trigger[aria-expanded="true"] { color: var(--green); border-color: var(--green); }
.nav-account .nav-dropdown {
  left: auto; right: 0; transform: none; min-width: 240px;
}
.nav-account-user {
  padding: 0.5rem 1rem 0.75rem; margin-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav-account-user .sol-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dropdown a.nav-account-item {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.92rem; font-weight: bold;
}
.nav-account-item svg { flex-shrink: 0; color: var(--muted); }
.nav-account-divider { height: 1px; margin: 0.35rem 0; background: rgba(255,255,255,0.08); }
.nav-dropdown a.nav-account-item--danger { color: #F0806F; }
.nav-account-item--danger svg { color: inherit; }
.nav-dropdown a.nav-account-item--danger:hover { background: rgba(217,79,79,0.15); color: #F0806F; }

/* The app shell (DMR-1298): sits above the map's overlays (z 10–20) and below
   the mobile sidebar slide-over (30) and the modals (50+). */
nav.site-nav--app { z-index: 25; }
.nav-context {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-left: 0.75rem; padding-left: 0.75rem;
  border-left: 1px solid rgba(255,255,255,0.2);
  font-family: Calibri, sans-serif; font-size: 0.8rem; color: var(--muted);
}
.nav-context #active-dashboard-label { color: var(--white); }
.nav-icon-btn {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-right: 0.5rem; padding: 0;
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; color: var(--white); cursor: pointer;
}
.nav-icon-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ───── MOBILE HAMBURGER + DRAWER ───── */
.nav-hamburger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 38px; height: 38px; padding: 0;
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; cursor: pointer;
}
.nav-hamburger span {
  display: block; width: 18px; height: 2px; background: var(--white);
  margin: 0 auto; transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(320px, 86vw); z-index: 110;
  background: var(--dark2); border-left: 1px solid rgba(232,184,75,0.2);
  box-shadow: -20px 0 48px rgba(0,0,0,0.5);
  transform: translateX(100%); transition: transform 0.25s ease-out;
  display: flex; flex-direction: column;
}
.mobile-drawer.open { transform: translateX(0); }

.mobile-drawer-backdrop {
  position: fixed; inset: 0; z-index: 105;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.mobile-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.mobile-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.mobile-drawer-title {
  font-family: Calibri, sans-serif; font-size: 0.75rem; font-weight: bold;
  color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase;
}
.mobile-drawer-close {
  background: transparent; border: none; color: var(--white);
  font-size: 1.8rem; line-height: 1; cursor: pointer; padding: 0 0.25rem;
}
.mobile-drawer-close:hover { color: var(--gold); }

.mobile-drawer-nav {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; padding: 0.75rem 0;
}
.mobile-nav-group-label {
  font-family: Calibri, sans-serif; font-size: 0.72rem; font-weight: bold;
  color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase;
  padding: 1rem 1.25rem 0.35rem;
}
.mobile-drawer-nav a {
  display: block; padding: 0.75rem 1.25rem;
  font-family: Calibri, sans-serif; font-size: 0.95rem; color: var(--white);
  transition: background 0.15s, color 0.15s;
}
.mobile-drawer-nav a:hover { background: rgba(44,110,73,0.18); color: var(--white); }
.mobile-drawer-nav a.active { color: var(--gold); }

.mobile-drawer-cta {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.08);
}
.mobile-drawer-cta .btn-login,
.mobile-drawer-cta .btn-subscribe {
  display: block; text-align: center; padding: 0.7rem 1rem;
}

/* Freeze body scroll while drawer open. */
body.nav-open { overflow: hidden; }

/* ───── MOBILE ───── */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-actions { display: none; }
  nav.site-nav { padding: 0 1rem; }
  .nav-hamburger { display: inline-flex; }
  .nav-context { display: none; }
}
@media (min-width: 901px) {
  /* Desktop: drawer + backdrop never render, even if class gets stuck. */
  .mobile-drawer, .mobile-drawer-backdrop { display: none !important; }
}
