/* ==========================================================================
   Tab bar — the row of main sections at the bottom of a phone app, in thumb reach.

   <nav class="tabbar" aria-label="Main">
     <a class="tabbar-item" href="/" aria-current="page"><i class="mi mi-house"></i><span>Home</span></a>
     <a class="tabbar-item" href="/inbox"><i class="mi mi-inbox"></i><span>Inbox</span><span class="tabbar-badge">3</span></a>
     …
   </nav>

   Fixed to the bottom on phones and tablets (with room for the iPhone home bar), gone from
   1024px where the sidebar takes over — .tabbar-always keeps it. The page gets bottom padding so
   nothing hides under it, toasts float above it, and it steps aside while the keyboard is up.
   .tabbar-floating (a rounded pill) · .tabbar-action (a big middle button) ·
   data-moey-hide-on-scroll (slides away while scrolling down).
   ========================================================================== */

.tabbar {
  --mo-tabbar-height: 3.5rem;
  position: fixed;
  inset: auto 0 0;
  z-index: var(--mo-z-fixed);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in oklab, var(--mo-bg-surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  box-shadow: 0 -1px 0 var(--mo-border-color);
  transition: translate .25s var(--mo-ease);
}
.tabbar-item {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: .1875rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--mo-tabbar-height);
  padding: .375rem .25rem;
  font: inherit;
  font-size: .6875rem;
  font-weight: var(--mo-font-weight-medium);
  line-height: 1.1;
  color: var(--mo-fg-3);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: 0;
  outline: none;
}
.tabbar-item > .mi,
.tabbar-item > svg { font-size: 1.375rem; width: 1.375rem; height: 1.375rem; line-height: 1; }
.tabbar-item > span:not(.tabbar-badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar-item:hover { color: var(--mo-fg-body); }
.tabbar-item:is([aria-current]:not([aria-current="false"]), .active) { color: var(--mo-default-base); }
.tabbar-item:focus-visible::after { position: absolute; inset: .25rem; content: ""; border-radius: var(--mo-radius-control); box-shadow: 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring); }
.tabbar-item:active > :is(.mi, svg) { scale: .9; }
.tabbar-badge {
  position: absolute;
  top: .25rem;
  inset-inline-start: calc(50% + .375rem);
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 .3125rem;
  font-size: .625rem;
  font-weight: var(--mo-font-weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1.125rem;
  color: var(--mo-white);
  text-align: center;
  background: var(--mo-red-600);
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--mo-bg-surface);
}
.tabbar-badge:empty { min-width: .5rem; width: .5rem; height: .5rem; padding: 0; top: .5rem; }
/* The big middle button (new post, scan, add) */
.tabbar-action { flex: 0 0 auto; padding-inline: .5rem; }
.tabbar-action > :is(.mi, svg) {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.375rem;
  color: var(--mo-default-base-contrast, var(--mo-white));
  background: var(--mo-default-base);
  border-radius: 999px;
}
.tabbar-action > span:not(.tabbar-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* A floating pill instead of a full-width bar */
.tabbar-floating {
  inset: auto .75rem calc(.75rem + env(safe-area-inset-bottom));
  padding: 0 .25rem;
  border-radius: 1.25rem;
  box-shadow: var(--mo-shadow-overlay);
}
/* Slides away while scrolling down (data-moey-hide-on-scroll) and while the keyboard is up */
.tabbar.is-hidden,
html.mo-keyboard .tabbar { translate: 0 calc(100% + 1rem); }
@media (prefers-reduced-motion: reduce) { .tabbar { transition: none; } }

/* Room for it: the page and the toasts keep clear of the bar */
:root:has(.tabbar) { --mo-tabbar-space: calc(3.5rem + env(safe-area-inset-bottom)); }
:root:has(.tabbar-floating) { --mo-tabbar-space: calc(4.75rem + env(safe-area-inset-bottom)); }
body:has(> .tabbar, > .app > .tabbar, > .app .tabbar) { padding-bottom: var(--mo-tabbar-space); }

/* Wide screens: the sidebar or navbar takes over (unless .tabbar-always) */
@media (width >= 1024px) {
  .tabbar:not(.tabbar-always) { display: none; }
  :root:has(.tabbar):not(:has(.tabbar-always)) { --mo-tabbar-space: 0px; }
}
