/*
 * The app shell (AB#313): the header, navigation, the user chip and the page frame every screen renders inside.
 * Loaded after the tokens, the guide's component styles and the base layer, so it may only USE tokens; no color
 * literal belongs here (a test enforces it). The shell is one dark surface (surface-header over surface-page):
 * everything in it reads from the dark theme, never a mix.
 *
 * The guide has no navigation component, so this is assembled from tokens and the guide's own Button and Avatar.
 * Focus is never suppressed: the global :focus-visible ring (maluce-base.css) applies to every link and button here.
 */
.ml-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--surface-page);
  color: var(--ink);
}

.ml-shell__header {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-shrink: 0;
  padding: var(--space-3) var(--space-6);
  background: var(--surface-header);
  border-bottom: 1px solid var(--border);
}

.ml-shell__brand {
  display: block;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

/* The wordmark is never recolored or restyled and is at least 120px wide (guide, Logos). */
.ml-shell__brand .brand-wordmark {
  display: block;
  width: 132px;
  height: auto;
}

.ml-shell__menu {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

.ml-shell__nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

/* The current page is marked by an underline AND heavier ink, never by color alone. */
.ml-shell__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.ml-shell__link:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.ml-shell__link[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--brand-fill);
}

.ml-shell__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.ml-shell__account {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  text-decoration: none;
}

.ml-shell__account:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.ml-shell__account-name {
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shown only on a phone, where the links collapse behind it. */
.ml-shell__menu-toggle {
  display: none;
  margin-left: auto;
}

/* The frame the page renders in. Pages size themselves to it (h-100) and scroll their own panes. */
.ml-shell__main {
  flex: 1 1 0;
  min-height: 0;
  /* clip, not hidden: "hidden" still makes this a scroll container, and focusing something that is sliding in from off the page (the People and
     Notes flyouts) scrolled the whole page content sideways until the animation ended. A clipped box cannot be scrolled at all. */
  overflow: clip;
}

/* The support-access bar (AB#240): a persistent region above every page while a session is active. */
.ml-support-bar {
  flex-shrink: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border-strong);
}

.ml-support-bar .ml-feedback-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.ml-support-bar__detail {
  color: var(--ink-secondary);
}

.ml-support-bar__countdown {
  margin-left: auto;
  color: var(--ink);
}

/* Phone width: the links and the account collapse behind a Menu button. */
@media (max-width: 767px) {
  .ml-shell__header {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3) var(--space-4);
  }

  .ml-shell__menu-toggle {
    display: inline-flex;
  }

  .ml-shell__menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .ml-shell__menu.is-open {
    display: flex;
  }

  .ml-shell__nav {
    flex-direction: column;
    align-items: stretch;
  }

  .ml-shell__link {
    padding: var(--space-3);
  }

  .ml-shell__user {
    justify-content: space-between;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }

  .ml-support-bar__countdown {
    margin-left: 0;
  }
}

/* AB#344: the unread count on the Notifications link. Gold fill with navy text (brand-fill / on-brand), a number in a pill so it is not color alone. */
.ml-shell__badge {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: var(--space-2);
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--brand-fill);
  color: var(--on-brand);
  font-size: 0.75rem;
  line-height: 1.25rem;
  text-align: center;
}

/* Grouped navigation (one button per menu, a panel of ordinary links). The button looks like a link; the chevron and the open panel say it is a menu. */
.ml-shell__menu-group {
  position: relative;
}

.ml-shell__menu-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  gap: var(--space-2);
}

.ml-shell__menu-button[data-current="true"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--brand-fill);
}

.ml-shell__chevron {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.ml-shell__menu-button[aria-expanded="true"] .ml-shell__chevron {
  transform: translateY(1px) rotate(-135deg);
}

.ml-shell__panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  min-width: 13rem;
  margin: var(--space-1) 0 0;
  padding: var(--space-2);
  list-style: none;
  background: var(--surface-100);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.ml-shell__panel[hidden] {
  display: none;
}

.ml-shell__panel .ml-shell__link {
  display: flex;
}

@media (max-width: 767px) {
  /* On a phone the whole menu is already behind the Menu button, so a group opens inline instead of floating. */
  .ml-shell__panel {
    position: static;
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0 0 0 var(--space-4);
    background: transparent;
  }
}

/* AB#151: the "your organization requires two-step sign-in" notice sits under the header, above the page. */
.ml-shell__notice {
  padding: var(--space-3) var(--space-4) 0;
}
