/* ===========================================
   Navigation (design §C.3, §C.4)
   The nav column from 1024px and the drawer below it. Location is neutral:
   the active item is a 2px --color-text-emphasis bar plus aria-current, never
   the accent. The Inbox badge is the shell's one solid accent (needs-you).
   =========================================== */

.nav {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--color-background);
}

.nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  min-height: var(--header-height);
  padding: 0 var(--spacing-sm) 0 var(--spacing-lg);
}

.nav__logo {
  min-width: 0;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-tight);
}

.nav__logo-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  color: var(--color-text-emphasis);
  text-decoration: none;
}

.nav__logo-link:hover {
  color: var(--color-text-emphasis);
  text-decoration: none;
}

/* ===========================================
   Menu and sections
   =========================================== */

.nav__menu {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
}

.nav__section + .nav__section {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border-subtle);
}

/* ===========================================
   Items
   =========================================== */

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  min-height: var(--touch-target);
  padding: 0 var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.nav__item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.nav__item--active,
.nav__item[aria-current="page"] {
  background: var(--color-surface-active);
  color: var(--color-text-emphasis);
  font-weight: var(--font-semibold);
  box-shadow: inset 2px 0 0 var(--color-text-emphasis);
}

.nav__item--active:hover,
.nav__item[aria-current="page"]:hover {
  background: var(--color-surface-active);
  color: var(--color-text-emphasis);
}

.nav__label {
  flex: 1;
  min-width: 0;
}

.nav__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}

/* ===========================================
   Footer: theme switch and user menu
   =========================================== */

.nav__footer {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-background);
}

.nav__footer .theme-switch {
  width: 100%;
}

.nav__footer .theme-switch__option {
  flex: 1;
  justify-content: center;
}

/* ===========================================
   User menu
   =========================================== */

.nav__user-menu {
  position: relative;
}

.nav__user-trigger {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  min-height: var(--touch-target);
  padding: 0 var(--spacing-sm);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.nav__user-trigger:hover {
  background: var(--color-surface-hover);
}

.nav__user-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav__user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-raised);
}

.nav__user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav__user-avatar span {
  color: var(--color-text-emphasis);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.nav__user-info {
  flex: 1;
  min-width: 0;
}

.nav__user-name {
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__user-email {
  overflow: hidden;
  color: var(--color-text);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__user-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  stroke: var(--color-text-muted);
  stroke-width: 2;
  fill: none;
}

.nav__user-trigger[aria-expanded="true"] .nav__user-chevron {
  transform: rotate(180deg);
}

/* Opens upward from the nav footer, at every width. No transform: the menu
   never moves under the pointer (settled_click). */
.nav__user-dropdown {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  z-index: var(--z-dropdown);
  margin-bottom: var(--spacing-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    visibility 0s linear var(--duration-fast);
}

.nav__user-dropdown--open {
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    visibility 0s;
}

.nav__user-dropdown-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border-subtle);
}

.nav__user-dropdown-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav__user-dropdown-email {
  overflow-wrap: anywhere;
  color: var(--color-text-emphasis);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.nav__user-dropdown-account {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.nav__user-dropdown-menu {
  padding: var(--spacing-xs);
}

.nav__user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  min-height: var(--touch-target);
  padding: 0 var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.nav__user-dropdown-item:hover,
.nav__user-dropdown-item:focus {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.nav__user-dropdown-item--danger,
.nav__user-dropdown-item--danger:hover,
.nav__user-dropdown-item--danger:focus {
  color: var(--color-danger);
}

.nav__user-dropdown-item--danger:hover,
.nav__user-dropdown-item--danger:focus {
  background: var(--color-danger-surface);
}

.nav__user-dropdown-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}

.nav__user-dropdown-divider {
  height: 1px;
  margin: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-border-subtle);
}

/* Account switching inside the menu (moved from authorization.css) */
.nav__user-dropdown-label {
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-xs);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.nav__user-dropdown-button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}

/* ===========================================
   Needs-you count on the Inbox item (and the phone top bar): the one solid
   accent badge (design §A.1, §D.6). Moved from control_plane_inbox.css.
   =========================================== */

.nav__badge {
  flex-shrink: 0;
  min-width: 1.25rem;
  margin-left: auto;
  padding: 0 var(--spacing-xs);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1.25rem;
  text-align: center;
}

/* ===========================================
   Forced colours: box-shadow is dropped, so the selection bar becomes a real
   border in Highlight (app_shell_spec checks its width).
   =========================================== */

@media (forced-colors: active) {
  .nav__item {
    border-inline-start: 2px solid transparent;
  }

  .nav__item--active,
  .nav__item[aria-current="page"] {
    border-inline-start: 2px solid Highlight;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav__item,
  .nav__user-trigger,
  .nav__user-dropdown,
  .nav__user-dropdown-item {
    transition: none;
  }
}
