/* MundaApp — the bottom shelf.
 *
 * One bar, seven doors, in the owner's order:
 *   Home · Munda Flow · Munda Share · Shops · Market · Munda CI · Me
 *
 * The labels are set as a small lockup rather than wrapped text. The three
 * "Munda" doors carry the shared word as a quiet kicker above the name, so
 * every door's name lands on one baseline and the shared prefix stops shouting:
 *
 *        MUNDA        MUNDA        MUNDA
 *   HOME  FLOW   SHARE   SHOPS  MARKET  CI    ME
 *
 * One active signal, not three: a gold chip behind the icon and the label in
 * deep green. The extra underline is gone — it changed the height of the label
 * it sat under, which is why the row never looked level.
 *
 * Selectors cover both kinds of bar: `.tabbar .tab` in the shell, and
 * `.tabbar > a` on /share and /diaries, where `.tab` is already the feed's
 * filter chip and must not be touched.
 */

:root { --tabbar-h: 62px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; align-items: stretch; justify-content: space-between;
  padding: 3px 0 env(safe-area-inset-bottom);
  border-top: 0;
  background:
    linear-gradient(90deg, #0C6E42 0 25%, #C8102E 25% 50%, #14110E 50% 75%, #DFA03C 75% 100%) 0 0 / 100% 3px no-repeat,
    linear-gradient(180deg, #FFFCF3 0%, #FDF8EC 46%, #F8F1DE 100%);
  box-shadow: 0 -10px 26px -20px rgba(12, 40, 26, .65), inset 0 1px 0 #FFFFFF;
}

/* one door */
.tabbar .tab,
.tabbar > a {
  position: relative;
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  gap: 5px; padding: 0 0 7px;
  color: #66756D; text-decoration: none; text-align: center;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  line-height: 11px; text-transform: uppercase;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color .18s ease;
}

.tabbar .tab svg,
.tabbar > a svg {
  width: 21px; height: 21px; flex: none; display: block;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  color: #5F6E65;
  position: relative; z-index: 1;
  transition: color .16s ease, transform .16s cubic-bezier(.25, 1, .5, 1);
}

/* the label: a fixed two-line box, text packed to the bottom so every door's
   name sits on one baseline whatever is above it */
.tabbar .tab > span:not(.n),
.tabbar > a > span:not(.n) {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  width: 100%; height: 21px;
  margin: 0; padding: 0;
  line-height: 11px; font-size: 9.5px; letter-spacing: .05em;
  white-space: normal; overflow: visible; text-overflow: clip;
  word-break: keep-all;
  position: relative; z-index: 1;
}

/* the shared word, quieter */
.tabbar .tab > span:not(.n) > em,
.tabbar > a > span:not(.n) > em {
  font-style: normal;
  font-size: 7.2px; line-height: 9px; letter-spacing: .12em;
  font-weight: 650; opacity: .68;
}

/* the door you are standing in */
.tabbar .tab.on,
.tabbar > a.on { color: #0A5334; }

.tabbar .tab::before,
.tabbar > a::before {
  content: "";
  position: absolute;
  top: 3px; left: 50%;
  width: min(46px, calc(100% - 6px)); height: 28px;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFBEF 0%, #FBF1DA 62%, #F5E7C8 100%);
  box-shadow:
    inset 0 0 0 1px #E3C58A,
    inset 0 1px 0 #FFFFFF,
    0 6px 13px -11px rgba(120, 86, 20, .60);
  transform: translateX(-50%) scale(.88);
  opacity: 0;
  z-index: 0;
  transition: opacity .2s ease, transform .26s cubic-bezier(.25, 1, .5, 1);
}
.tabbar .tab.on::before,
.tabbar > a.on::before {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

.tabbar .tab.on svg,
.tabbar > a.on svg {
  color: #0A5334; stroke-width: 2.05;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .7));
  transform: translateY(-1px);
}
.tabbar .tab.on > span:not(.n) > em,
.tabbar > a.on > span:not(.n) > em { opacity: .85; }

.tabbar .tab:active svg,
.tabbar > a:active svg { transform: scale(.94); }
.tabbar .tab:active,
.tabbar > a:active { color: #0A5334; }

/* unread count */
.tabbar .tab .n,
.tabbar > a .n {
  position: absolute; top: 0; right: 50%; margin-right: -20px; z-index: 2;
  background: #C8102E; color: #fff;
  font-size: 8.5px; font-weight: 700; letter-spacing: 0;
  min-width: 15px; height: 15px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 3px;
  box-shadow: 0 0 0 2px #FFFDF7;
}

/* a 320px phone leaves 45px a door — give the words back their room */
@media (max-width: 359px) {
  .tabbar .tab,
  .tabbar > a { font-size: 8.9px; letter-spacing: .02em; }
  .tabbar .tab > span:not(.n),
  .tabbar > a > span:not(.n) { font-size: 8.9px; letter-spacing: .02em; }
  .tabbar .tab > span:not(.n) > em,
  .tabbar > a > span:not(.n) > em { font-size: 6.8px; letter-spacing: .1em; }
  .tabbar .tab svg,
  .tabbar > a svg { width: 20px; height: 20px; }
  .tabbar .tab::before,
  .tabbar > a::before { width: min(42px, calc(100% - 2px)); }
}

/* ---------------------------------------------------------------- page change
 * The shell swaps #view's contents on every route, so the incoming screen fades
 * up instead of snapping in.
 *
 * Opacity only, and that is a deliberate engineering choice: an animated
 * `transform` is left behind as `matrix(1,0,0,1,0,0)` by `fill-mode: both`, and
 * an identity matrix still makes the element a containing block for
 * `position: fixed` children. Animating <body> that way put this very bar at the
 * bottom of the document, 3,000px down, instead of at the bottom of the screen.
 * A fade cannot do that.
 */
@keyframes munda-page-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#view.mv-in { animation: munda-page-in .3s cubic-bezier(.22, .61, .36, 1) both; }
body.mv-page { animation: munda-page-in .32s cubic-bezier(.22, .61, .36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .tabbar .tab::before, .tabbar > a::before { transition: none; }
  #view.mv-in, body.mv-page { animation: none; }
}
