/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
/* ==========================================================================
   Application shell + Navigation Dock (current development theme; shared tokens only).

   .msh (container "msh" = the shell's own width)
     └ .msh__in   flex: the dock on its configured edge, the content takes the remaining space
         ├ .msh__dock → .mnav
         └ .msh__main → the dashboard
   Edge per breakpoint (data-nav-desktop / -tablet / -mobile on .msh):
     mobile  < 560px   top | bottom only (left/right are never implemented here)
     tablet  ≥ 560px   left | right | top | bottom
     desktop ≥ 960px   left | right | top | bottom
   ========================================================================== */

.msh { container: msh / inline-size; width: 100%; min-width: 0; }
.msh__in { display: flex; flex-direction: column-reverse; gap: 12px; min-width: 0; }
.msh__main { flex: 1 1 auto; min-width: 0; }
/* a sidebar (components/sidebar) beside the content: the content takes the remaining width */
.msh__main--side { display: flex; flex-direction: row; align-items: flex-start; gap: 0; }
.msh__main--side[data-side="right"] { flex-direction: row-reverse; }
.msh__main--side > :not(.isb) { flex: 1 1 auto; min-width: 0; }
.msh__dock { flex: none; min-width: 0; }
/* a side rail stays reachable while the page scrolls: it sticks below the host's sticky header
   (--msh-sticky-top). It sits BESIDE the content, so it never covers a widget. Top / bottom docks stay
   in the flow (a sticky horizontal bar would slide over the dashboard). */
@container msh (min-width: 560px) and (max-width: 959.98px) {
  .msh:is([data-nav-tablet="left"], [data-nav-tablet="right"]) .msh__dock { position: sticky; z-index: 5; top: var(--msh-sticky-top, 12px); }
}
@container msh (min-width: 960px) {
  .msh:is([data-nav-desktop="left"], [data-nav-desktop="right"]) .msh__dock { position: sticky; z-index: 5; top: var(--msh-sticky-top, 12px); }
}
.msh__dock[hidden] { display: none; }

/* mobile: top | bottom */
.msh[data-nav-mobile="top"] > .msh__in { flex-direction: column; }
/* tablet */
@container msh (min-width: 560px) {
  .msh[data-nav-tablet="top"] > .msh__in { flex-direction: column; }
  .msh[data-nav-tablet="bottom"] > .msh__in { flex-direction: column-reverse; }
  .msh[data-nav-tablet="left"] > .msh__in { flex-direction: row; align-items: flex-start; }
  .msh[data-nav-tablet="right"] > .msh__in { flex-direction: row-reverse; align-items: flex-start; }
}
/* desktop */
@container msh (min-width: 960px) {
  .msh[data-nav-desktop="top"] > .msh__in { flex-direction: column; align-items: stretch; }
  .msh[data-nav-desktop="bottom"] > .msh__in { flex-direction: column-reverse; align-items: stretch; }
  .msh[data-nav-desktop="left"] > .msh__in { flex-direction: row; align-items: flex-start; }
  .msh[data-nav-desktop="right"] > .msh__in { flex-direction: row-reverse; align-items: flex-start; }
}

/* ---------------------------------------------------------------- the dock (horizontal by default) */
.mnav {
  font-family: var(--font);
  border-radius: var(--radius-lg);
  background: var(--nav-bg);
  box-shadow: 0 0 0 1px var(--border-subtle), var(--shadow-secondary);
  padding: 6px;
}
.mnav[hidden] { display: none; }
.mnav__list {
  display: flex;
  gap: 4px;
  margin: 0; padding: 0;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.mnav__i { flex: none; scroll-snap-align: start; }
.mnav__b {
  position: relative;
  min-width: 64px;
  min-height: 52px;                    /* touch target ≥ --hit-min */
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--nav-inactive, var(--text-secondary));
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.mnav__icon { width: 22px; height: 22px; display: grid; place-items: center; }
.mnav__icon svg { width: 100%; height: 100%; }
.mnav__label { max-width: 96px; font-size: 11px; font-weight: var(--iq-fw-status); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mnav__b:hover { color: var(--text-primary); background: var(--surface-tertiary); }
.mnav__b:active { transform: scale(.97); }
.mnav__b:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }
.mnav__b[aria-current="page"] { color: var(--nav-active, var(--accent)); background: var(--nav-active-bg, var(--accent-soft)); box-shadow: inset 0 0 0 1px var(--accent-line); }
.mnav__b[aria-current="page"]::after {          /* active marker on the edge facing the content */
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px;
  border-radius: 2px; background: var(--nav-indicator, var(--accent));
}

/* top / bottom on tablet + desktop: icon beside the label */
@container msh (min-width: 560px) {
  .mnav__b { flex-direction: row; gap: 8px; min-height: 44px; padding: 6px 14px; }
  .mnav__label { font-size: 13px; max-width: 160px; }
}

/* left / right (tablet + desktop): a compact vertical rail — small labels under the icons */
@container msh (min-width: 560px) and (max-width: 959.98px) {
  .msh:is([data-nav-tablet="left"], [data-nav-tablet="right"]) .msh__dock { width: 80px; align-self: flex-start; }
  .msh:is([data-nav-tablet="left"], [data-nav-tablet="right"]) .mnav__list { flex-direction: column; overflow-x: hidden; overflow-y: auto; }
  .msh:is([data-nav-tablet="left"], [data-nav-tablet="right"]) .mnav__b { width: 100%; min-width: 0; min-height: 56px; flex-direction: column; gap: 3px; padding: 6px 4px; }
  .msh:is([data-nav-tablet="left"], [data-nav-tablet="right"]) .mnav__label { font-size: 10.5px; max-width: 64px; }
  .msh[data-nav-tablet="left"] .mnav__b[aria-current="page"]::after { left: 1px; top: 50%; bottom: auto; width: 3px; height: 18px; margin: -9px 0 0; }
  .msh[data-nav-tablet="right"] .mnav__b[aria-current="page"]::after { left: auto; right: 1px; top: 50%; bottom: auto; width: 3px; height: 18px; margin: -9px 0 0; }
  .msh[data-nav-tablet="top"] .mnav__b[aria-current="page"]::after { top: auto; bottom: 2px; }
}
@container msh (min-width: 960px) {
  .msh:is([data-nav-desktop="left"], [data-nav-desktop="right"]) .msh__dock { width: 84px; align-self: flex-start; }
  .msh:is([data-nav-desktop="left"], [data-nav-desktop="right"]) .mnav__list { flex-direction: column; overflow-x: hidden; overflow-y: auto; }
  .msh:is([data-nav-desktop="left"], [data-nav-desktop="right"]) .mnav__b { width: 100%; min-width: 0; min-height: 60px; flex-direction: column; gap: 4px; padding: 8px 4px; }
  .msh:is([data-nav-desktop="left"], [data-nav-desktop="right"]) .mnav__label { font-size: 11px; max-width: 68px; }
  .msh[data-nav-desktop="left"] .mnav__b[aria-current="page"]::after { left: 1px; top: 50%; bottom: auto; width: 3px; height: 20px; margin: -10px 0 0; }
  .msh[data-nav-desktop="right"] .mnav__b[aria-current="page"]::after { left: auto; right: 1px; top: 50%; bottom: auto; width: 3px; height: 20px; margin: -10px 0 0; }
}
@media (prefers-reduced-motion: reduce) { .mnav__b { transition: none; } .mnav__b:active { transform: none; } }

/* ---------------------------------------------------------------- the screen layer (popups + notifications) */
.mscr { position: fixed; z-index: 900; pointer-events: none; overflow: hidden; }
.mscr__layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mscr__layer > * { pointer-events: auto; }
.mscr__layer > .mnote-stack { pointer-events: none; }

/* NONE: no Navigation Dock at that size — the dashboard brings its own (e.g. a Studio sidebar or tab bar with "On tap: open page") */
@container msh (min-width: 960px) { .msh[data-nav-desktop="none"] .msh__dock { display: none; } }
@container msh (min-width: 560px) and (max-width: 959.98px) { .msh[data-nav-tablet="none"] .msh__dock { display: none; } }
@container msh (max-width: 559.98px) { .msh[data-nav-mobile="none"] .msh__dock { display: none; } }
.mnav__badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; font: 700 10px/1 var(--font); color: #fff; background: var(--danger, #e5484d); }
.mnav__badge[hidden] { display: none; }
.mnav__b { position: relative; }
