/* Site navigation
 * ============================================================================
 * One definition for the bar that sits on top of every page. Before this, the
 * same ~40 lines were pasted into 21 templates.
 *
 * This is a consolidation, not a redesign. An audit on 2026-09-08 compared
 * every copy: .nav-logo, .nav-logo img, .nav-dropdown.open, .hamburger-btn span
 * and .nav-dropdown a:hover were byte-identical in all 21, and the rest agreed
 * 13-or-14 to 1. The majority body is what is written here, so converting a
 * page changes nothing about how it looks. The exceptions are named at the foot
 * of this file.
 *
 * Load order: linked right after <title>, so it lands BEFORE each page's own
 * <style>. A page that still needs to differ can simply keep its own rule and
 * it will win, which is how .nav-wrap's background survives per page.
 */

/* The full-bleed bar behind the centred nav. Its background is the one rule
 * that genuinely varies: 13 pages paint the green gradient, while the six
 * pages that already sit on their own gradient (index, retiring, account,
 * privacy, terms, home) darken it with a translucent black instead. Those
 * pages keep their local rule and override the default below.
 *
 * Deliberately no z-index here. gc-wallet stacks its bar at 2100 so the nav
 * stays clickable above the unlock dialog, but that value belongs to that page
 * alone: modal overlays elsewhere sit at 1000, and a shared 2100 would draw the
 * nav on top of every one of them. gcwallet.css keeps its own rule. */
.nav-wrap {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  padding: 0 20px;
}

nav {
  max-width: var(--column);
  margin: 0 auto;
  padding: 14px var(--gutter-x);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo img { width: 32px; height: 32px; }
.nav-logo span {
  color: var(--nav-fg);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 18px;
}

/* Hamburger + dropdown (authenticated pages) */
.nav-menu-wrap { position: relative; }

.hamburger-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}
.hamburger-btn span { display: block; width: 22px; height: 2px; background: var(--nav-fg); border-radius: 2px; }
.hamburger-btn:focus-visible { outline: 2px solid var(--nav-fg); outline-offset: 2px; }

.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 8px;
  min-width: 200px;
  z-index: 1000;
}
.nav-dropdown.open { display: block; }

.nav-dropdown a {
  display: block;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
@media (hover: hover) {
  .nav-dropdown a:hover { background: var(--nav-item-hover); }
}
.nav-dropdown a.active { background: var(--nav-item-active); color: var(--green-text); }

/* Who is signed in, and on what plan. Was on the dashboard only; it belongs
 * wherever the menu is, since the menu is the same menu. Values are the
 * dashboard's own, kept exactly, so this reads there as it always has. */
.nav-dropdown-user {
  padding: 10px 16px 8px;
  font-size: 12px;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--row-line);
  margin-bottom: 4px;
}
/* Was an inline style="margin-left:4px" on the dashboard's span. */
.nav-dropdown-user span { margin-left: 4px; }

/* Plain link row, used where there is no menu to open: signed-out visitors,
 * and the "Back" link on the policy pages. */
.nav-links { display: flex; gap: 10px; align-items: center; }
.nav-links a {
  color: var(--nav-fg);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-weight: 500;
}
@media (hover: hover) {
  .nav-links a:hover { background: rgba(255, 255, 255, 0.25); }
}
.nav-links a.active { background: rgba(255, 255, 255, 0.3); }

/* An admin's four everyday links, on the bar rather than under the hamburger,
 * because that menu holds a dozen tools and these are the ones used constantly.
 *
 * Below 900px the bar cannot hold the logo, four pills and the button, so the
 * row hides and the same four appear in the dropdown instead. Both copies exist
 * in the markup and exactly one is display:none, which removes it from the
 * accessibility tree as well as the layout -- neither a sighted user nor a
 * screen reader is ever offered the pair. Nobody else has either class, so a
 * subscriber's menu is untouched by all of this. */
/* margin-left:auto takes all the free space before the row, which beats the
 * nav's space-between and leaves the links and the button together on the
 * right, with the wordmark alone on the left. */
.nav-links-admin { display: flex; flex-wrap: wrap; margin-left: auto; margin-right: 12px; }
.nav-dropdown-compact { display: none; }

@media (max-width: 900px) {
  .nav-links-admin { display: none; }
  .nav-dropdown-compact { display: block; }
}

/* Deliberate normalisations, recorded so they are not mistaken for drift later:
 *   analytics  had a lighter dropdown (8px radius, weaker shadow), an unstyled
 *              hamburger and unweighted menu links. It now matches the other 13.
 *   account    set .nav-logo span to 15px against 18px everywhere else, and
 *              rendered a stale inline link row instead of the menu.
 */


/* ============================================================================
 * The bar in dark mode
 * ============================================================================
 * iOS has no coloured chrome. A navigation bar is the background colour with a
 * hairline under it, and the tint colour is spent on the things you can press,
 * not on the bar itself. Left as a gradient, Brick Domain's sage bar is the
 * brightest object on a black page and the first thing the eye lands on, which
 * is backwards: it is furniture, not content.
 *
 * So the bar becomes the page, the wordmark becomes the label colour, and the
 * green survives where it belongs, on the active item.
 *
 * Both blocks below are the same rules under the two dark selectors, for the
 * reason given in base.css: a media query cannot be merged with an attribute
 * selector, and a value defined under only one of them would apply in only one
 * of the two ways a page can be dark.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav-wrap {
    background: var(--page-bg);
    border-bottom: 0.5px solid var(--line);
  }
  :root:not([data-theme="light"]) .hamburger-btn { background: var(--surface-sunk); }
  :root:not([data-theme="light"]) .nav-links a { background: transparent; }
  @media (hover: hover) {
    :root:not([data-theme="light"]) .nav-links a:hover { background: var(--surface-sunk); }
  }
:root:not([data-theme="light"]) .nav-links a.active { background: var(--surface-sunk); }
}

:root[data-theme="dark"] .nav-wrap {
  background: var(--page-bg);
  border-bottom: 0.5px solid var(--line);
}
:root[data-theme="dark"] .hamburger-btn { background: var(--surface-sunk); }
:root[data-theme="dark"] .nav-links a { background: transparent; }
@media (hover: hover) {
  :root[data-theme="dark"] .nav-links a:hover { background: var(--surface-sunk); }
}
:root[data-theme="dark"] .nav-links a.active { background: var(--surface-sunk); }
