/* Phone menu (epic 556, issue 561): at 860px and below a bottom bar, and the menu (the sidebar) as a full-height dialog. */
.pbar, .pbar-close { display: none; }
:root { --pbar-h: calc(57px + env(safe-area-inset-bottom, 0px)); }
html.nav-lock, html.nav-lock body { overflow: hidden; }

@media (max-width: 860px) {
  .pbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--pbar-h); box-sizing: border-box;
    z-index: 40; background: var(--surface); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .pbar a, .pbar button {
    min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    padding: 2px; overflow: hidden; border: 0; background: none; font: inherit; font-size: var(--text-xs); font-weight: 600; line-height: 1.2;
    color: var(--ink-2); text-decoration: none; text-align: center; cursor: pointer;
  }
  .pbar .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .pbar a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
  .pbar button[aria-expanded="true"] { color: var(--accent); }
  /* Space for the bar: the end of a page, the order entry action bar and a message stay above it. */
  .main-col { padding-bottom: var(--pbar-h); }
  html { scroll-padding-bottom: var(--pbar-h); }
  .summary { bottom: var(--pbar-h); }
  .toast { bottom: calc(var(--pbar-h) + var(--space-sm)); }

  /* Closed menu: the header keeps the brand and the user block. The menu, the theme and the rest wait in the dialog. */
  .app:not(.nav-open) .sidebar > :not(.brand):not(.who) { display: none; }
  .app.nav-open .sidebar {
    position: fixed; inset: 0; z-index: 50; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: var(--space-md);
    padding: var(--space-md) var(--space-md) env(safe-area-inset-bottom, 0px); background: var(--paper-2);
    animation: navp-in 0.18s var(--ease-out, ease-out);
  }
  .app.nav-open .sidebar > * { order: 0; }
  .app.nav-open .sidebar .who { margin-left: 0; }
  .app.nav-open .sidebar .brand { padding-right: 52px; min-height: 44px; align-content: center; }
  .pbar-close {
    position: absolute; top: var(--space-sm); right: var(--space-sm); min-width: 44px; display: grid; place-items: center;
    border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer;
  }
  .sidebar .nav a, .sidebar .nav-gh, .sidebar .pbar-close { min-height: 44px; }
  .app.nav-open .sidebar .who :is(a, button, summary) { min-height: 44px; }
  /* The finder: the list is placed against the field inside the dialog; field and rows are 44px. */
  .app.nav-open .nav-finder { position: relative; }
  .nf-input, .nf-list li[role="option"] { min-height: 44px; box-sizing: border-box; }
  /* The pins: rows of 44px with a 44px pin button. */
  .nav-pin { width: 44px; height: 44px; inset-inline-end: 0; }
  .nav-row > a, .quick a { min-height: 44px; padding-inline-end: 52px; box-sizing: border-box; }
  .pbar button { position: relative; }
  .pbar-count {
    position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box;
    border-radius: 9px; background: var(--accent); color: var(--surface); font-size: 11px; line-height: 18px; text-align: center;
  }
  .sidebar .nav a, .sidebar .nav-gh { font-size: var(--text-md); }
}
@keyframes navp-in { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  .sidebar { animation: none; }
}
