/* =============================================================================
   NAV.CSS  —  The shared top-nav chrome (site nav, brand, dropdowns, avatar)
   -----------------------------------------------------------------------------
   The nav markup lives in ONE place (planning/templates/base.html) and is
   inherited by BOTH shells — the public shell (base.html → layout.css +
   home.css) and the app shell (base_tools.html → app.css). Its CSS used to be
   duplicated in layout.css and app.css, and the two copies drifted: the app.css
   copy was missing --right / -divider / -section-label / -item--btn / -arrow /
   .is-active / .is-current, so on every base_tools page the account menu opened
   centred (overflowing the viewport edge) with the view-as picker and Log out
   rendering as raw browser buttons.

   One markup → one stylesheet. base.html loads this file OUTSIDE the
   {% block base_styles %} override (the same trick chat.css / view_as.css use)
   so a child template that replaces base_styles can never strip the nav's CSS
   again. Do not re-add .site-nav / .nav-* rules to layout.css or app.css.

   @layer components (not layout) so it resolves identically in both shells —
   app.css is @layer components, and a layout-layer rule would silently lose.
   ============================================================================= */

@layer components {

.site-nav {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(244, 244, 241, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-rule);
  box-shadow: none;
}

.site-nav-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.site-brand {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--c-ink);
  white-space: nowrap;
}

.site-brand-logo {
  height: 24px !important;
  width: auto !important;
  max-height: 24px;
  display: block;
  flex-shrink: 0;
}

.site-brand-subtitle {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--c-ink);
}

.site-nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.site-nav .btn {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  /* Explicit, because the two shells' base .btn disagree: layout.css sets an
     uppercase 0.20em marketing button, app.css a sentence-case one. The nav
     inherited whichever shell it landed in, so the same header read UPPERCASE
     on public pages and sentence case in the app. This rule's own 13px/500/0
     tracking is a sentence-case spec — state it once, for both. */
  text-transform: none;
  color: var(--c-muted);
  background: transparent;
  border: 1px solid var(--c-rule);
  border-radius: 0;
  box-shadow: none;
  padding: 5px 12px;
  height: auto;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.site-nav .btn:hover {
  background: rgba(26, 26, 26, 0.04);
  border-color: var(--c-ink);
  color: var(--c-ink);
  box-shadow: none;
  transform: none;
  text-decoration: none;
}
.site-nav .btn--active {
  border-color: var(--c-ink);
  color: var(--c-ink);
  background: transparent;
}

/* ── Hamburger (mobile) ── */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--c-rule);
  color: var(--c-ink);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.nav-hamburger:hover { background: rgba(14, 20, 27, 0.05); }

/* Top nav overlay (click-outside to close on mobile) */
.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 997;
}
.nav-overlay.is-open { display: block; }

@media (max-width: 768px) {
  /* Bottom tab bar handles all mobile navigation — hide top hamburger/dropdown */
  .nav-hamburger { display: none !important; }
  .site-nav-links { display: none !important; }

  .site-nav-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }

  .site-nav { position: sticky; }
}

/* Hamburger → X morphing lines */
.nav-hamburger .bar-top,
.nav-hamburger .bar-mid,
.nav-hamburger .bar-bot {
  transition: transform 0.2s ease, opacity 0.15s ease;
  transform-origin: center;
}
.nav-hamburger[aria-expanded="true"] .bar-top {
  transform: translateY(6px) rotate(45deg);
}
.nav-hamburger[aria-expanded="true"] .bar-mid {
  opacity: 0;
  transform: scaleX(0);
}
.nav-hamburger[aria-expanded="true"] .bar-bot {
  transform: translateY(-6px) rotate(-45deg);
}

/* ── Top nav dropdown ── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Active/current section indicator on the trigger (doesn't disable clicks) */
.nav-dropdown-trigger.is-current {
  text-decoration: underline;
  text-decoration-color: var(--c-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.nav-dropdown-arrow {
  transition: transform 0.15s ease;
  flex-shrink: 0;
  opacity: 0.55;
}

.nav-dropdown.is-open .nav-dropdown-arrow {
  transform: rotate(180deg);
}

/* Desktop floating panel */
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  min-width: 176px;
  background: var(--c-white);
  border: 1px solid var(--c-rule);
  border-radius: 0;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(26, 26, 26, 0.08);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.nav-dropdown.is-open .nav-dropdown-menu {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Right-aligned variant for the avatar dropdown */
.nav-dropdown-menu--right {
  left: auto;
  right: 0;
  transform: translateY(-6px);
}
.nav-dropdown.is-open .nav-dropdown-menu--right {
  transform: translateY(0);
}

/* Divider inside dropdown */
.nav-dropdown-divider {
  height: 1px;
  background: var(--c-rule);
  margin: 4px 6px;
}

/* Section label inside dropdown — used by the "View as tier" admin picker. */
.nav-dropdown-section-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  font-weight: 600;
}

/* Button-style dropdown item (for logout form) */
.nav-dropdown-item--btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-dropdown-item {
  display: block;
  padding: 10px 14px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--c-ink);
  text-decoration: none;
  transition: background 0.1s;
  white-space: nowrap;
}

.nav-dropdown-item:hover {
  background: var(--c-stone);
  color: var(--c-ink);
  text-decoration: none;
}

.nav-dropdown-item.is-active {
  color: var(--c-ink);
  font-weight: 600;
  background: transparent;
}

/* Mobile: inline accordion instead of floating panel */
@media (max-width: 768px) {
  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-trigger {
    width: 100%;
    justify-content: space-between;
  }

  .nav-dropdown-menu {
    position: static;
    transform: none !important;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: none;
    backdrop-filter: none;
    padding: 0 0 0 14px;
    transition: opacity 0.15s ease, max-height 0.2s ease;
    pointer-events: none;
  }

  .nav-dropdown.is-open .nav-dropdown-menu {
    opacity: 1;
    max-height: 320px;
    pointer-events: auto;
  }

  .nav-dropdown-item {
    padding: 9px 12px;
    font-size: 0.84rem;
    border-left: 2px solid rgba(14, 20, 27, 0.10);
    border-radius: 0;
    margin-bottom: 1px;
  }
}

/* ── Avatar square ── */
.nav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--c-ink);
  color: var(--c-white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.nav-avatar:hover { opacity: 0.75; background: var(--c-ink); }

/* Tap targets — nav-dropdown items shown inline on mobile need ≥44px hit area
   to satisfy WCAG 2.5.5. Must stay AFTER the mobile accordion block above,
   which sets a smaller padding. */
@media (max-width: 768px) {
  .nav-dropdown-item { padding: 12px 14px; min-height: 44px; }
}

/* Account menu — current-section indicator on the avatar itself. The template
   has always emitted .nav-avatar--active; until now no rule matched it. */
.nav-avatar--active {
  box-shadow: inset 0 0 0 1px var(--c-bone);
  opacity: 1;
}

/* ── Upgrade CTA ──
   Ink-filled, per §2 (oxblood is the only signal colour — no amber CTAs).
   Previously this lived in home.css behind a wall of !important to beat a
   legacy amber rule in layout.css, which meant the app shell (no home.css)
   rendered the upgrade CTA as bare unstyled text for exactly the free-tier
   users it targets. Both copies are gone; this is the only definition. */
.site-nav .btn--upgrade {
  background: var(--c-ink);
  color: var(--c-white);
  border: 1px solid var(--c-ink);
  padding: 5px 20px;
  font-weight: 500;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.site-nav .btn--upgrade:hover {
  background: var(--c-ink);
  border-color: var(--c-ink);
  color: var(--c-white);
  opacity: 0.8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

} /* end @layer components */
