/* FitFuel Nutrition — shared auth-aware nav (single source of truth)
Load with /js/nav.js on any page:
  <link rel="stylesheet" href="/css/nav.css" />
  <div id="nav-placeholder"></div>
  <script src="/js/nav.js" defer></script>
nav.js injects markup using exactly the classes below — keep them in sync.
*/

/* Unwrap the injection point so .nav's parent is effectively <body> —
   otherwise the placeholder is exactly nav-height tall and gives
   position: sticky zero range to travel (nav would scroll away). */
#nav-placeholder {
  display: contents;
}

/* ── Shell ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid rgba(229, 231, 235, 0.6);
  transition:
    background 0.3s var(--ease-base, ease),
    box-shadow 0.3s var(--ease-base, ease);
}
.nav.scrolled {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
}
.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* One visible keyboard ring for every nav control */
.nav :focus-visible {
  outline: 2px solid var(--green-500, #008c46);
  outline-offset: 3px;
}

/* ── Brand ─────────────────────────────────────────────────────────── */
.nav-brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--green-800, #166534);
  letter-spacing: -0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
}
/* The Fit|Fuel accent colour and gap are defined once, as
   .wordmark-accent in /css/main.css. Every page that loads this nav also
   loads main.css — do not re-declare the accent here. */

/* Entity attribution. It is UI text, not part of the mark, so it opts
   out of the display face the brand inherits and sits a shade larger
   than fine print. */
.nav-sub {
  font-family: var(--font, "Inter", sans-serif);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--gray-500, #6b7280);
  letter-spacing: 0.01em;
  margin-left: 10px;
  white-space: nowrap;
}

/* ── Links ─────────────────────────────────────────────────────────── */
.nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
}
.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600, #4b5563);
  text-decoration: none;
  position: relative;
  white-space: nowrap;
  transition: color 0.15s var(--ease-base, ease);
}
.nav-link::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--green-500, #008c46);
  border-radius: 1px;
  transition: width 0.3s var(--ease-base, ease);
}
.nav-link:hover {
  color: var(--green-800, #166534);
}
.nav-link:hover::after {
  width: 100%;
}
/* Current page: show the underline persistently, not just on hover */
.nav-link[aria-current="page"] {
  color: var(--green-800, #166534);
}
.nav-link[aria-current="page"]::after {
  width: 100%;
}

/* ── Pills ────────────────────────────────────────────────────────────
   Order Now, Login and the account chip are one control with three
   fills. The box is declared once — padding, border, radius, weight,
   line-height and transition all shared — so they cannot drift apart.
   Only colour is per-control. */
.nav-cta,
.nav-account-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* A <button> otherwise inherits the UA's ButtonFace grey; the account
     chip rendered as a grey lozenge until this was declared. */
  background: transparent;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.6;
  padding: 9px 20px;
  border-radius: var(--radius-full, 9999px);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.2s var(--ease-base, ease),
    border-color 0.2s var(--ease-base, ease),
    color 0.2s var(--ease-base, ease);
}

/* Primary — the one filled control in the bar, and now the only call to
   action in the header when signed out. No glow, no lift. */
.nav-cta {
  gap: 10px;
  background: var(--green-500, #008c46);
  color: #fff;
}
.nav-cta svg {
  flex-shrink: 0;
}
.nav-cta:hover {
  background: var(--green-600, #00833f);
}

/* Account chip — orange outline, the lower-emphasis slot opposite the
   filled CTA. Not grey: the greeting used to inherit --gray-500 and read
   as a grey lozenge with one orange word in it. */
.nav-account-trigger {
  border-color: var(--orange-600, #d96217);
  color: var(--orange-700, #b84e0f);
}
.nav-account-trigger:hover,
.nav-account-trigger[aria-expanded="true"] {
  background: var(--orange-50, #fef3ec);
  border-color: var(--orange-700, #b84e0f);
}

/* Identity chip — same box and colour as Login; only the label and the
   chevron differ. */
.nav-account-trigger {
  gap: 6px;
}
.nav-account-name {
  color: inherit;
  font-weight: 700;
}

/* ── Auth area (right side) ────────────────────────────────────────── */
/* Action group: account entry + CTA, tightened like a button pair
   (Carbon: one high-emphasis + one lower-emphasis control). */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* The auth slot is the last item in the bar — the right edge — and only
   holds anything when signed in. Signed out it is empty, so the CTA simply
   takes the corner. */
.nav-auth {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  order: 2;
}
/* Collapses the flex gap so an empty slot leaves no dead space */
.nav-auth:empty {
  display: none;
}

/* ── Account menu (disclosure) ─────────────────────────────────────── */
.nav-account {
  position: relative;
}
.nav-account-chevron {
  transition: transform 0.2s var(--ease-base, ease);
}
.nav-account-trigger[aria-expanded="true"] .nav-account-chevron {
  transform: rotate(180deg);
}
.nav-account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius-md, 10px);
  box-shadow: var(--shadow-md, 0 4px 20px rgba(0, 0, 0, 0.08));
  padding: 6px;
  animation: nav-menu-in 0.15s var(--ease-out, ease);
}
/* The author `display: flex` above would otherwise defeat [hidden] */
.nav-account-menu[hidden] {
  display: none;
}
@keyframes nav-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.nav-account-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm, 8px);
  background: none;
  color: var(--gray-700, #374151);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s var(--ease-base, ease),
    color 0.15s var(--ease-base, ease);
}
/* Menu items share the orange account identity — a green hover under an
   orange chip reads as a mistake. */
.nav-account-item:hover {
  background: var(--orange-50, #fef3ec);
  color: var(--orange-700, #b84e0f);
}
.nav-account-item[aria-current="page"] {
  background: var(--orange-50, #fef3ec);
  color: var(--orange-700, #b84e0f);
  font-weight: 600;
}
.nav-account-sep {
  height: 1px;
  border: 0;
  background: var(--gray-200, #e5e7eb);
  margin: 5px 4px;
}
.nav-account-logout:hover {
  background: var(--gray-50, #f9fafb);
  color: var(--red-600, #dc2626);
}
/* ── Burger (mobile only) ──────────────────────────────────────────── */
.nav-burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
}
.nav-burger span {
  width: 22px;
  height: 2px;
  background: var(--green-800, #166534);
  border-radius: 2px;
  transition: all 0.25s var(--ease-base, ease);
}

/* ── Tighten before the burger kicks in ────────────────────────────── */
@media (max-width: 1024px) {
  /* The attribution is the first thing to go when the bar gets tight. */
  .nav-sub {
    display: none;
  }
  .nav-links {
    gap: 24px;
  }
}

/* ── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .nav-burger {
    display: flex;
  }
  .nav-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 8px 0 4px;
    order: 3;
    border-top: 1px solid rgba(229, 231, 235, 0.6);
  }
  .nav-links.open {
    display: flex;
    animation: nav-drop 0.22s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  }
  @keyframes nav-drop {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  /* Action group: full-width buttons, primary (Order Now) on top —
     Carbon's vertical-stack rule. */
  .nav-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .nav-auth {
    width: 100%;
    justify-content: flex-start;
  }
  /* In the column the panel flows inline instead of floating — no hover
     on touch, and nothing can overflow the viewport. */
  .nav-account {
    width: 100%;
  }
  .nav-account-menu {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 6px;
    box-shadow: none;
    animation: none;
  }
  /* Full-width button; the shared box already centres its content. */
  .nav-cta {
    width: 100%;
  }
}
