/* =============================================================================
   MOURN — NAVBAR (global component, single source of truth)
   Mobile-first. Desktop bar and mobile hamburger pattern share one markup
   tree (resources/views/components/navbar.php); this stylesheet switches
   presentation at the desktop breakpoint rather than duplicating markup.
   Desktop breakpoint: 1024px — below it (mobile + tablet) gets the
   intentionally-designed mobile pattern, not a shrunk desktop bar.
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--color-canvas);
  border-bottom: var(--border-hairline);
}

.navbar__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  gap: var(--space-sm);
}

/* --- Mobile: hamburger | centered logo | cart --- */

.navbar__hamburger {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.navbar__hamburger-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}

.navbar__hamburger-bars span {
  display: block;
  height: 2px;
  background-color: var(--color-ink);
}

.navbar__logo {
  justify-self: center;
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-title);
  text-decoration: none;
  color: var(--color-ink);
}

.navbar__links {
  display: none;
}

.navbar__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.navbar__cart {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  min-height: 44px;
  text-decoration: none;
  color: var(--color-ink);
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-title);
}

.navbar__cart-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-xxs);
  border-radius: var(--radius-lg);
  background-color: var(--color-ink);
  color: var(--color-surface);
  font-size: 0.75rem;
  font-weight: var(--font-weight-bold);
}

/* Account dropdown button/panel: desktop-only (mobile uses the drawer) */
.navbar__account {
  position: relative;
  display: none;
}

.navbar__account-toggle {
  min-height: 44px;
  padding: 0 var(--space-xs);
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-title);
  color: var(--color-ink);
}

.navbar__account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-xs));
  min-width: 180px;
  background-color: var(--color-surface);
  border: var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) 0;
  display: none;
  flex-direction: column;
}

.navbar__account-menu[data-open="true"] {
  display: flex;
}

.navbar__account-menu a,
.navbar__account-menu-logout {
  display: block;
  width: 100%;
  padding: var(--space-xs) var(--space-md);
  text-align: left;
  text-decoration: none;
  color: var(--color-ink);
  font-size: var(--font-size-body);
}

.navbar__account-menu a:hover,
.navbar__account-menu a:focus-visible,
.navbar__account-menu-logout:hover,
.navbar__account-menu-logout:focus-visible {
  background-color: var(--color-neutral-100);
}

/* Active link — inverted block, per DESIGN.md nav-link-active.
   Compound selector (not just .navbar__link--active) so this reliably beats
   the desktop .navbar__link base rule below regardless of source order —
   both are otherwise equal-specificity single-class selectors. */
.navbar__link.navbar__link--active,
.navbar__cart.navbar__link--active {
  background-color: var(--color-ink);
  color: var(--color-surface);
  border-radius: var(--radius-sm);
}

/* --- Mobile drawer + backdrop --- */

.navbar__backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.navbar__backdrop[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.navbar__drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(85vw, 320px);
  background-color: var(--color-surface);
  border-right: var(--border-hairline);
  z-index: 100;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-md);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.navbar__drawer[data-open="true"] {
  transform: translateX(0);
}

.navbar__drawer nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.navbar__drawer-link {
  display: block;
  padding: var(--space-sm) var(--space-xs);
  min-height: 44px;
  text-decoration: none;
  color: var(--color-ink);
  font-size: var(--font-size-heading);
  line-height: 1.2;
}

.navbar__drawer-link--active {
  background-color: var(--color-ink);
  color: var(--color-surface);
  border-radius: var(--radius-sm);
  padding-inline: var(--space-sm);
}

.navbar__drawer-account {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
}

.navbar__drawer-heading {
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-title);
  margin-bottom: var(--space-xs);
}

.navbar__drawer-link--button {
  width: 100%;
  text-align: left;
}


/* --- Desktop (>=1024px): full bar, no hamburger/drawer --- */
@media (min-width: 1024px) {
  .navbar__bar {
    grid-template-columns: auto 1fr auto;
  }

  .navbar__hamburger,
  .navbar__drawer,
  .navbar__backdrop {
    display: none;
  }

  .navbar__logo {
    justify-self: start;
  }

  .navbar__links {
    display: flex;
    justify-self: center;
    gap: var(--space-md);
  }

  .navbar__link {
    padding: var(--space-xs) var(--space-sm);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--color-ink);
    font-size: var(--font-size-body);
    border-radius: var(--radius-sm);
  }

  .navbar__account {
    display: block;
  }
}
