/* The shell above the page. Below 900px: a contextual top bar, a fixed bottom
   bar and the one full-screen menu it opens. From 900px: a single header for
   every page with one panel under it. The footer is in footer.css.
   Every colour and corner comes from :root in app.css (ADR 0029). */

/* The gutter is reserved at every width so that locking the page under an open
   panel does not take the scrollbar away and shift the header sideways. */
html { scrollbar-gutter: stable; }
html.nav-open { overflow: hidden; }

/* ---------- mobile: the top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 60px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.dbrand { display: flex; align-items: center; gap: var(--space-3); }
.topbar-spacer { flex: 1; }
.topbar-action {
  width: 44px; height: 44px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-primary); font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
}
.topbar-back {
  min-width: 44px; min-height: 44px; font-size: 22px; color: var(--text-primary);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control);
}
.topbar-title { font-weight: 600; font-size: 16px; color: var(--text-primary); }
.menu-btn { border: 0; cursor: pointer; }

/* ---------- mobile: the fixed bar ---------- */
/* It never hides on scroll: a bar that comes and goes is a bar the reader
   stops reaching for. */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0 12px env(safe-area-inset-bottom);
  display: flex; align-items: center;
  background: var(--surface-card);
  border-top: 1px solid var(--border-subtle);
}
/* Equal slots, not space-around: with content-sized items a longer label
   ("Ulubione" vs "Katalog") shifts the middle slot and the FAB drifts off
   centre. Equal flex basis pins it to exactly 50%. */
.bottomnav > * { flex: 1 1 0; min-width: 0; }
.nav-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; padding: 0;
  background: transparent; border: 0; cursor: pointer;
  font-size: 10.5px; font-weight: 500; color: var(--text-muted);
  border-radius: var(--radius-card);
}
/* The saved-listings count sits off the heart's shoulder; zero draws nothing. */
.nav-badge {
  position: absolute; top: 3px; left: calc(50% + 7px);
  min-width: 16px; height: 16px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--action-primary); color: var(--action-ink);
  font-size: 10px; font-weight: 700; line-height: 1;
  border-radius: var(--radius-pill);
}
.nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.active { color: var(--text-primary); background: var(--surface-sky); }
.nav-item:active { color: var(--text-primary); background: var(--surface-lilac); }
.nav-fab {
  flex: 1 1 0; height: 48px;
  display: flex; align-items: center; justify-content: center;
  margin-top: -22px; color: var(--action-ink);
}
/* The disc is the inner box, so the flex slot stays the same width as its
   siblings while the visible button keeps its 48px circle. */
.nav-fab svg {
  display: block; width: 48px; height: 48px; padding: 13px;
  background: var(--action-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.nav-fab:active svg { background: var(--action-primary-hover); }
.nav-avatar {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--text-primary); color: var(--surface-page);
  font-size: 12px; font-weight: 700;
  border-radius: var(--radius-pill);
}
/* The keyboard takes the bottom of the screen; 64px of navigation on top of a
   field the reader is filling in is 64px of that field lost. */
body:has(:is(textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"])):focus) .bottomnav { display: none; }

/* The page ends above the bar, not behind it. */
@media (max-width: 899px) { .page { padding-bottom: var(--space-8); } }

/* ---------- mobile: the menu ---------- */
.sheet {
  width: 100%; max-width: none;
  height: 100vh; max-height: 100vh;
  height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--text-primary); overflow: hidden;
}
.sheet::backdrop { background: color-mix(in srgb, var(--overlay-ink) 55%, transparent); }
.sheet-in {
  display: flex; flex-direction: column; gap: 14px;
  height: 100%;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-card);
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
}
/* The dialog slides, not the list inside it: a transform on the scroll
   container makes the browser scroll the opening sheet past its own header. */
.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-grab {
  width: 44px; height: 4px; flex: none; margin: 0 auto;
  background: var(--border-strong); border-radius: var(--radius-pill);
}
.sheet-head { display: flex; align-items: center; gap: var(--space-3); }
.sheet-profile {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-warm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}
.sheet-profile-name { font-weight: 600; flex: 1; min-width: 0; }
.sheet-go { color: var(--text-muted); font-size: 20px; }
.sheet-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sheet-tile {
  display: grid; place-items: center;
  min-height: 66px; padding: 8px;
  text-align: center; font-size: 12.5px; font-weight: 600;
  background: var(--surface-sky); border-radius: var(--radius-card);
}
.sheet-invite { padding: 16px; background: var(--surface-sky); border-radius: var(--radius-card); }
.sheet-invite h2 { margin: 0; font-family: var(--font-marketing); font-weight: 400; font-size: var(--type-h3); }
.sheet-invite p { margin: 6px 0 14px; color: var(--text-secondary); font-size: 13.5px; }
.sheet-sec {
  font-family: var(--font-ui); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-muted);
}
.sheet-nav { display: flex; flex-direction: column; margin-top: -10px; }
.sheet-nav form { display: contents; }
.sheet-nav a, .sheet-logout {
  display: flex; align-items: center;
  width: 100%; min-height: 48px; padding: 0 8px;
  font-weight: 500; font-size: 15px; text-align: start; color: var(--text-primary);
  background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.sheet-nav > :last-child, .sheet-nav form:last-child .sheet-logout { border-bottom: 0; }
.sheet-pitch {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 16px;
  background: var(--surface-butter); border-radius: var(--radius-card);
}
.sheet-pitch span { color: var(--text-secondary); font-size: 13px; }
.sheet-foot {
  margin-top: auto; padding-top: 6px;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 12px; color: var(--text-muted);
}
