/* BottomNav — phone primary navigation (MOBILE_PLAN.md §2.3).
 *
 * Fixed bottom bar, 5 equal items (Dashboard, Watchlist, Signals, Compare,
 * More). Hidden on desktop (≥ 768 px) — the TopBar's full nav takes over.
 * Every colour, type size, spacing, radius and motion value comes from
 * tokens.css; no literals here.
 */

/* Hidden by default; the shell mounts the bar on the page even on desktop
   so the slot exists, then we reveal it only on phones. `display:none` at
   the lg token keeps it out of layout AND out of the accessibility tree. */
.bottomnav { display: none; }

/* Phone: visible, fixed at the bottom, full width, safe-area aware. */
@media (max-width: 767.98px) {
  .bottomnav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    justify-items: center;
    position: fixed;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    box-sizing: border-box;
    bottom: 0;
    z-index: var(--z-nav);
    min-height: var(--bottom-nav-h);
    padding-bottom: var(--safe-bottom);
    padding-inline: max(var(--space-1), var(--safe-left)) max(var(--space-1), var(--safe-right));
    background: var(--panel);
    border-top: 1px solid var(--panel-border);
    overflow: hidden;
  }
}

/* §2.3: hide while a field is focused on a phone and the on-screen keyboard
   is up (`data-keyboard="open"` comes from lib/viewport.js keyboardInset(),
   i.e. --keyboard-inset > 0), so the keyboard never pushes the bar up over
   the field. A focused field alone (a hardware keyboard) keeps the bar. */
@media (max-width: 767.98px) {
  :root:has(:is(input, select, textarea):focus) .bottomnav[data-keyboard="open"] {
    display: none;
  }
}

/* Each item: column of icon + label. The whole cell is the tap target. */
.bn-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: var(--bottom-nav-h);
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.bn-link:hover { color: var(--ink); text-decoration: none; }

.bn-link svg { display: block; width: 22px; height: 22px; flex: none; min-width: 0; }

.bn-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Active route: the same accent treatment as the TopBar nav. */
.bn-link[aria-current="page"] {
  color: var(--accent);
}

.bn-link[aria-current="page"] svg {
  /* the dot of the More icon stays full when active, like the TopBar */
}

/* Reduced motion: the bar itself doesn't animate, but the safe-area padding
   uses the same prefers-reduced-motion courtesy. */
@media (prefers-reduced-motion: reduce) {
  .bottomnav { transition: none; }
}