/* Load after the shared navigation styles. Keep dialogs above this menu. */
body.obx-nav-open {
  overflow: hidden;
  overscroll-behavior: none;
}

/* The menu must escape the page's floating Post button stacking context. */
body.obx-nav-open .nav {
  z-index: 9990;
}

.nav-menu {
  --nav-menu-limit: calc(100vh - 100px);
  --nav-menu-ink: #20262b;
  --nav-menu-muted: #5d6770;
  --nav-menu-line: #dde2e5;
  --nav-menu-grouped: #f3f4f5;
  --nav-menu-focus: #175fc3;
  position: fixed;
  inset: 80px 16px auto auto;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100% - 32px));
  min-width: 0;
  max-width: none;
  height: auto;
  max-height: var(--nav-menu-limit);
  margin: 0;
  padding: 0;
  overflow: visible;
  color: var(--nav-menu-ink);
  background: transparent;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
}

@supports (height: 100dvh) {
  .nav-menu { --nav-menu-limit: calc(100dvh - 100px); }
}

.nav-menu.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9997;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgb(20 25 29 / 32%);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms;
}

.nav-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nav-menu[hidden],
.nav-menu [hidden],
.nav-backdrop[hidden] {
  display: none !important;
}

.nav-menu,
.nav-menu *,
.nav-menu *::before,
.nav-menu *::after,
.nav-backdrop {
  box-sizing: border-box;
  letter-spacing: 0;
  animation: none !important;
}

/* Neutralize the shared glass effects without changing the nav trigger. */
.nav-menu :is(.nav-link-card, .nav-menu-user-link, .nav-menu-close, .nav-menu-actions .btn),
.nav-menu :is(.nav-link-card, .nav-menu-user-link, .nav-menu-close, .nav-menu-actions .btn):is(:hover, :focus, :active) {
  transform: none;
  transform-style: flat;
  backface-visibility: visible;
  filter: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  will-change: auto;
  text-shadow: none;
}

.nav-menu :is(.nav-link-card, .nav-menu-user-link, .nav-menu-close, .btn)::before,
.nav-menu :is(.nav-link-card, .nav-menu-user-link, .nav-menu-close, .btn)::after,
.nav-menu .nav-menu-user-copy span::before {
  display: none;
  content: none;
}

.nav-menu .nav-menu-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: var(--nav-menu-limit);
  padding: 0;
  overflow: hidden;
  background: var(--nav-menu-grouped);
  border: 1px solid var(--nav-menu-line);
  border-radius: inherit;
  box-shadow: 0 16px 48px rgb(20 25 29 / 18%), 0 2px 8px rgb(20 25 29 / 8%);
}

.nav-menu .nav-menu-inner {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: inherit;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.nav-menu .nav-menu-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--nav-menu-line);
}

.nav-menu .nav-menu-toolbar h2 {
  min-width: 0;
  margin: 0;
  padding: 0;
  color: var(--nav-menu-ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.nav-menu .nav-menu-close {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  color: #39434c;
  background: #f0f2f3;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.nav-menu .nav-menu-close svg {
  display: block;
  width: 22px;
  height: 22px;
  flex: none;
  pointer-events: none;
}

.nav-menu .nav-menu-scroll {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #aeb7bd var(--nav-menu-grouped);
  scroll-padding-block: 16px;
  -webkit-overflow-scrolling: touch;
}

.nav-menu .nav-menu-section-label {
  margin: 0 0 10px;
  padding: 0;
  color: var(--nav-menu-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-transform: none;
}

.nav-menu .nav-links-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.nav-menu .nav-link-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  min-height: 148px;
  height: auto;
  margin: 0;
  padding: 14px;
  overflow: visible;
  color: var(--nav-menu-ink);
  background: #fff;
  border: 1px solid var(--nav-menu-line);
  border-radius: 8px;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

/* Shared by the menu and home sidebar; all artwork stays inside a stable square. */
.obx-feature-icon {
  display: inline-flex;
  flex: 0 0 var(--obx-feature-icon-size, 54px);
  align-items: center;
  justify-content: center;
  width: var(--obx-feature-icon-size, 54px);
  height: var(--obx-feature-icon-size, 54px);
  margin: 0;
  padding: 0;
  overflow: visible;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 3px 7px rgb(31 42 55 / 14%);
  line-height: 0;
  vertical-align: middle;
  pointer-events: none;
}

.obx-feature-icon .obx-feature-icon-svg {
  display: block;
  flex: none;
  width: 100%;
  height: 100%;
  max-width: none;
  overflow: visible;
}

.obx-feature-icon .obx-feature-icon-glyph {
  transform-box: view-box;
  transform-origin: 32px 34px;
  filter: drop-shadow(0 2px 1.5px rgb(20 40 63 / 20%));
}

.obx-feature-icon .obx-feature-icon-sparkle {
  transform-box: fill-box;
  transform-origin: center;
  opacity: .94;
}

@keyframes obxFeatureBob {
  0%, 100% { transform: translateY(1px) scale(.98); }
  50% { transform: translateY(-1.5px) scale(1.035); }
}

@keyframes obxFeatureSparkle {
  0%, 100% { transform: rotate(-8deg) scale(.88); opacity: .76; }
  50% { transform: rotate(10deg) scale(1.1); opacity: 1; }
}

/* These are the only exceptions to the legacy menu-animation reset above. */
@media (prefers-reduced-motion: no-preference) {
  .nav-menu.show:not([hidden]) .obx-feature-icon .obx-feature-icon-glyph,
  :where(aside, .obx-home-sidebar) a:is(:hover, :focus-visible) .obx-feature-icon .obx-feature-icon-glyph {
    animation: obxFeatureBob 3.2s ease-in-out infinite !important;
  }

  .nav-menu.show:not([hidden]) .obx-feature-icon .obx-feature-icon-sparkle,
  :where(aside, .obx-home-sidebar) a:is(:hover, :focus-visible) .obx-feature-icon .obx-feature-icon-sparkle {
    animation: obxFeatureSparkle 3.2s ease-in-out infinite !important;
  }
}

.nav-menu :is(.nav-link-copy, .nav-menu-user-copy) {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.nav-menu :is(.nav-link-copy, .nav-menu-user-copy) strong {
  display: block;
  margin: 0;
  color: var(--nav-menu-ink);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.3;
}

.nav-menu .nav-link-copy small,
.nav-menu .nav-menu-user-copy span {
  display: block;
  width: auto;
  margin: 0;
  padding: 0;
  color: var(--nav-menu-muted);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-transform: none;
}

.nav-menu .nav-link-card[aria-current="page"] {
  border-color: #527cad;
  background: #f7faff;
}

.nav-menu .nav-menu-head {
  margin: 16px 0 0;
  padding: 0;
}

.nav-menu .nav-menu-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 76px;
  margin: 0;
  padding: 14px;
  overflow: visible;
  color: var(--nav-menu-ink);
  background: #fff;
  border: 1px solid var(--nav-menu-line);
  border-radius: 8px;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.nav-menu .nav-menu-avatar {
  display: inline-flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  color: #245ca4;
  background: #e4eefc;
  border: 1px solid var(--nav-menu-line);
  border-radius: 50%;
  box-shadow: none;
}

.nav-menu .nav-menu-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-menu .nav-menu-avatar svg { width: 24px; height: 24px; }
.nav-menu .nav-menu-user-copy { flex: 1 1 auto; }
.nav-menu .nav-menu-user > svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--nav-menu-muted); }

.nav-menu .nav-menu-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--nav-menu-line);
}

.nav-menu .nav-menu-actions .btn {
  display: inline-flex;
  flex: 1 1 120px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-width: 0;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 11px 12px;
  color: var(--nav-menu-ink);
  background: #fff;
  border: 1px solid #cfd6db;
  border-radius: 8px;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-transform: none;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  appearance: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.nav-menu .nav-menu-actions .btn.primary { color: #fff; background: #2263b4; border-color: #2263b4; }
.nav-menu .nav-menu-actions .btn.danger { color: #a13540; background: #fff; border-color: #dfc5c9; }
.nav-menu .nav-menu-actions .btn svg { flex: 0 0 18px; width: 18px; height: 18px; }

.nav-menu .nav-menu-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 16px 0 0;
  padding: 0;
  color: var(--nav-menu-muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.nav-menu .nav-menu-footer a { color: inherit; text-underline-offset: 3px; }

@media (hover: hover) {
  .nav-menu :is(.nav-link-card, .nav-menu-user-link):hover { background: #fafcfd; border-color: #aebbc5; }
  .nav-menu .nav-menu-close:hover { background: #e4e8eb; border-color: #b7c1c8; }
  .nav-menu .nav-menu-actions .btn:hover { background: #edf1f4; border-color: #aebbc5; }
  .nav-menu .nav-menu-actions .btn.primary:hover { background: #194f93; border-color: #194f93; }
  .nav-menu .nav-menu-actions .btn.danger:hover { background: #fff0f1; border-color: #ca9ba2; }
  .nav-menu .nav-menu-footer a:hover { text-decoration: underline; }
}

.nav-menu :is(a, button, [tabindex]):focus-visible {
  outline: 3px solid var(--nav-menu-focus);
  outline-offset: 3px;
}

.nav-menu .nav-menu-scroll:focus-visible { outline-offset: -4px; }
.nav-backdrop:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }

@media (max-width: 640px), (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  .nav-menu {
    --nav-menu-limit: min(88vh, calc(100vh - env(safe-area-inset-top, 0px) - 80px));
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    border-radius: 12px 12px 0 0;
    transform: translateY(16px);
  }

  .nav-menu.show { transform: none; }
  .nav-menu .nav-menu-shell { border-bottom: 0; }
  .nav-menu .nav-menu-toolbar { padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); }
  .nav-menu .nav-menu-scroll {
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }
  .nav-menu .nav-links-grid { gap: 10px; }
  .nav-menu .nav-link-card { padding: 12px; }

  @supports (height: 100dvh) {
    .nav-menu { --nav-menu-limit: min(88dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 80px)); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-menu,
  .nav-menu *,
  .nav-backdrop,
  .obx-feature-icon,
  .obx-feature-icon * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .nav-menu { transform: none; }
}
