/* appNav.css — ListTrash application navigation.
 *
 * Replaces the old Bootstrap navbar with two responsive layouts driven by one
 * markup template (src/js/nav/appNav.js):
 *   • Mobile  (<992px): slim brand strip on top + a persistent bottom TAB BAR
 *                       (Home / Inbox / Programs / Account) with live badges.
 *   • Desktop (≥992px): a single slim TOP BAR — brand + inline nav items with
 *                       badges + an account dropdown.
 *
 * Design: a quiet utility bar, not a marketing hero. One accent, one signature
 * (the "lit" active tab: accent pill behind the glyph + a 2px accent top-rule).
 * All colors are pulled from tokens already in the app so it harmonizes with
 * the grey launcher chrome AND the navy scratch-sheet world (themed in
 * scratchSheet.css, scoped to #scratch-sheet-app #navbar / .lt-tabbar).
 *
 * Served from public/css (NOT webpack-bundled); cache-busted via updateVersion.js.
 */

:root {
  --lt-nav-height: 48px;        /* top bar */
  --lt-tabbar-height: 50px;     /* bottom tab bar */
  /* A full modern-iPhone inset is ~34px, which leaves a conspicuous empty
   * shelf below this compact bar in viewport-fit=cover layouts. The home
   * indicator itself only needs the lower portion kept clear, so reserve a
   * capped inset while retaining dedicated gesture clearance. */
  --lt-tabbar-safe-space: min(env(safe-area-inset-bottom, 0px), 16px);
  /* 0 on desktop; real height (incl. safe-area) under 992px — set below. */
  --lt-bottom-nav-height: 0px;

  /* Light (launcher / desktop) palette — reuses existing app chrome colors. */
  --lt-nav-surface: #ffffff;
  --lt-nav-border: #e4e8ee;
  --lt-nav-ink: #1a2230;
  --lt-nav-muted: #6a7383;
  --lt-nav-accent: #337ab7;          /* the app's existing blue */
  --lt-nav-accent-soft: rgba(51, 122, 183, 0.12);
  --lt-nav-badge-bg: #dc3545;        /* the app's existing badge red */
  --lt-nav-badge-fg: #ffffff;
  --lt-nav-press: rgba(26, 34, 48, 0.06);
}

/* ─────────────────────────────────────────────────────────────────────────
 * Content clearance for the fixed bottom bar.
 * The value is 0 by default; the media query below turns it on under 992px.
 * ──────────────────────────────────────────────────────────────────────── */
#launcher-screen,
#scratch-sheet-app {
  padding-bottom: var(--lt-bottom-nav-height, 0px);
}

/* ═════════════════════════════════════════════════════════════════════════
 * TOP BAR  (#navbar) — brand strip everywhere; full nav on desktop.
 * ═════════════════════════════════════════════════════════════════════════ */
.lt-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--lt-nav-height);
  padding: 0 clamp(12px, 4vw, 20px);
  background: var(--lt-nav-surface);
  border-bottom: 1px solid var(--lt-nav-border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

/* Brand: logo + optional scratch-sheet date, click → home. */
.lt-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: none;
  padding: 6px 4px;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
}
.lt-brand:hover { background: var(--lt-nav-press); }
.lt-brand:active { transform: scale(0.98); }
.lt-brand .navbar-logo {
  height: 26px;
  width: auto;
  flex: 0 0 auto;
  display: block;
}
.lt-brand .navbar-date {
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.15;
  font-weight: 600;
  color: var(--lt-nav-muted);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
}

/* Desktop-only inline nav + account cluster live on the right. */
.lt-topbar-nav {
  margin-left: auto;
  display: none;                /* shown at ≥992px */
  align-items: center;
  gap: 4px;
}

/* Inline desktop nav item (Home / Inbox / Programs). */
.lt-topitem {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 9px;
  color: var(--lt-nav-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.lt-topitem .material-symbols-outlined { font-size: 22px; }
.lt-topitem:hover { background: var(--lt-nav-press); color: var(--lt-nav-ink); }
.lt-topitem:active { transform: scale(0.97); }
.lt-topitem.active {
  color: var(--lt-nav-accent);
  background: var(--lt-nav-accent-soft);
  font-weight: 600;
}

/* Account trigger (desktop dropdown button) reuses .lt-topitem, plus name/email. */
.lt-account-trigger { padding-left: 10px; }
.lt-account-trigger::after { display: none; }   /* kill Bootstrap caret */
.lt-account-id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  max-width: 150px;
  text-align: left;
}
.lt-account-id .user-display-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lt-nav-ink);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lt-account-id .user-email {
  font-size: 0.72rem;
  color: var(--lt-nav-muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═════════════════════════════════════════════════════════════════════════
 * BADGES  (.lt-nav-badge) — CSS owns ALL layout; JS only toggles display.
 * Two placements: a pill riding a tab/top-bar glyph, and an inline pill.
 * ═════════════════════════════════════════════════════════════════════════ */
.lt-nav-badge {
  box-sizing: border-box;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--lt-nav-badge-bg);
  color: var(--lt-nav-badge-fg);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-family: var(--ss-font-body, system-ui, sans-serif);
}

/* On a tab / top-bar item, the icon is wrapped in .lt-nav-glyph so the badge
 * can absolutely position to its top-right corner. */
.lt-nav-glyph {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lt-nav-glyph .lt-nav-badge {
  position: absolute;
  top: -4px;
  /* Anchor the badge's centre just past the icon's top-right so the ring reads
   * as a corner cluster. `left: 55%` + a small pull-back keeps a wide "99+"
   * count from poking past the tab edge while short counts stay corner-tucked. */
  left: 55%;
  transform: translateX(-15%);
  /* Grow height/min-width to 20px so the 2px ring (4px total, border-box) leaves
   * a 16px content box matching the base line-height — digits stay centred, not
   * squished. */
  min-width: 20px;
  height: 20px;
  line-height: 16px;
  border: 2px solid var(--lt-nav-surface);
}

/* ═════════════════════════════════════════════════════════════════════════
 * BOTTOM TAB BAR  (.lt-tabbar) — mobile only.
 * ═════════════════════════════════════════════════════════════════════════ */
.lt-tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1030;                 /* below modal backdrop 1050 + offcanvas 1045 */
  display: flex;
  align-items: stretch;
  /* Keep the tab row at a constant height and put the gesture clearance below
   * it. Capping the conservative iOS inset avoids a 34px blank shelf on larger
   * phones while still keeping labels above the home indicator. */
  height: calc(var(--lt-tabbar-height) + var(--lt-tabbar-safe-space));
  padding-bottom: var(--lt-tabbar-safe-space);
  background: var(--lt-nav-surface);
  border-top: 1px solid var(--lt-nav-border);
  box-shadow: 0 -1px 12px rgba(16, 24, 40, 0.06);
}

.lt-tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 44px;              /* touch target */
  border: 0;
  background: none;
  cursor: pointer;
  padding: 4px 2px 3px;
  color: var(--lt-nav-muted);
  font-family: var(--ss-font-body, system-ui, sans-serif);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease;
}

/* The icon sits in a soft pill; the pill lights up when active. */
.lt-tab .lt-nav-glyph {
  width: 42px;
  height: 25px;
  border-radius: 13px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.lt-tab .material-symbols-outlined {
  font-size: 24px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  transition: font-variation-settings 0.15s ease;
}

/* Signature: the "lit" active tab — accent pill + top-rule + filled glyph. */
.lt-tab.active { color: var(--lt-nav-accent); }
.lt-tab.active .lt-nav-glyph { background: var(--lt-nav-accent-soft); }
.lt-tab.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.lt-tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--lt-nav-accent);
}

.lt-tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

/* Pressed feedback — the glyph springs in slightly. */
.lt-tab:active .lt-nav-glyph { transform: scale(0.92); }

/* ═════════════════════════════════════════════════════════════════════════
 * ACCOUNT MENU — one item-builder rendered into BOTH the desktop dropdown and
 * the mobile tray (shared .ss-tray Plain Sheet surface). Shared item styling
 * below; the tray surface itself lives in scratchSheet.css (.ss-tray*).
 * ═════════════════════════════════════════════════════════════════════════ */
.lt-account-menu .lt-menu-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--lt-nav-border);
  margin-bottom: 6px;
}
.lt-account-menu .lt-menu-header .user-display-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--lt-nav-ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lt-account-menu .lt-menu-header .user-email {
  font-size: 0.8rem;
  color: var(--lt-nav-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Menu item — same look in dropdown and bottom sheet. */
.lt-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 11px 16px;
  color: var(--lt-nav-ink);
  font-family: var(--ss-font-body, system-ui, sans-serif);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  border-radius: 8px;
}
.lt-menu-item .material-symbols-outlined {
  font-size: 22px;
  color: var(--lt-nav-muted);
  flex: 0 0 auto;
}
.lt-menu-item:hover,
.lt-menu-item:focus-visible {
  background: var(--lt-nav-press);
  color: var(--lt-nav-ink);
}
.lt-menu-item:active { transform: scale(0.99); }
.lt-menu-divider {
  height: 1px;
  margin: 6px 12px;
  background: var(--lt-nav-border);
  border: 0;
}

/* Desktop dropdown container: give it comfortable width + our own padding. */
.lt-account-menu.dropdown-menu {
  min-width: 268px;
  padding: 6px;
  border-color: var(--lt-nav-border);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
  border-radius: 14px;
}

/* ── Mobile tray (shared .ss-tray Plain Sheet surface) ───────────────────────
 * The account/apps menus now render inside .ss-tray (scratchSheet.css), which
 * owns the sheet surface, radius, drag handle, and 14px 16px 20px padding. The
 * menu items carry their own 16px horizontal padding, so pull the tray body
 * flush to the tray edge here to avoid a doubled 32px indent. ── */
.lt-nav-tray-body { margin: 0 -8px; }
.lt-nav-tray .lt-menu-header { padding-top: 4px; }

/* ═════════════════════════════════════════════════════════════════════════
 * APPS SWITCHER — a tappable grid of the user's authorized apps, shown in BOTH
 * the desktop dropdown panel (.lt-apps-menu) and the mobile tray (shared
 * .ss-tray Plain Sheet surface). Tiles mirror the launcher grid (icon + name).
 * ═════════════════════════════════════════════════════════════════════════ */

/* The grid itself — auto-fit tiles, same in dropdown and tray. */
.lt-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
}

/* One app tile — icon over a short label. */
.lt-apps-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 10px 6px;
  border-radius: 12px;
  color: var(--lt-nav-ink);
  font-family: var(--ss-font-body, system-ui, sans-serif);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease, transform 0.1s ease;
}
.lt-apps-tile:hover,
.lt-apps-tile:focus-visible { background: var(--lt-nav-press); }
.lt-apps-tile:active { transform: scale(0.96); }
.lt-apps-tile-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}
.lt-apps-tile-name {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--lt-nav-ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Desktop dropdown panel — same popover treatment as the account menu. */
.lt-apps-menu.dropdown-menu {
  min-width: 320px;
  max-width: 380px;
  padding: 10px;
  border-color: var(--lt-nav-border);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
  border-radius: 14px;
}

/* Inside the mobile tray, the apps grid scrolls if the list is tall. */
.lt-nav-tray .lt-apps-grid {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* ═════════════════════════════════════════════════════════════════════════
 * RESPONSIVE SWITCH
 * ═════════════════════════════════════════════════════════════════════════ */
@media (min-width: 992px) {
  .lt-topbar-nav { display: flex; }
  /* Bottom bar is .d-lg-none in markup; the mobile trays are a NO-OP above the
   * <992px band (openOverlay's mobileQuery), so nothing needed here. */
}

@media (max-width: 991.98px) {
  :root { --lt-bottom-nav-height: calc(var(--lt-tabbar-height) + var(--lt-tabbar-safe-space)); }
  /* Slim the brand strip a touch on phones. */
  .lt-topbar { min-height: 44px; }
  .lt-brand { flex: 1 1 auto; }
  .lt-brand .navbar-logo { height: 23px; }
}

/* Respect reduced-motion: drop the press/scale transitions. */
@media (prefers-reduced-motion: reduce) {
  .lt-brand,
  .lt-topitem,
  .lt-menu-item,
  .lt-tab .lt-nav-glyph,
  .lt-tab .material-symbols-outlined {
    transition: none;
  }
  .lt-brand:active,
  .lt-topitem:active,
  .lt-menu-item:active,
  .lt-tab:active .lt-nav-glyph { transform: none; }
}
