/* The signed-in shell (S2, #168; markup in src/View/AppShell.php, behaviour
   in shell.js). One navigation landmark: a rail beside the page on wide
   screens, CCM's bottom bar on phones (navigation-shell.md). Active item:
   bold label and a persimmon-tint pill behind the icon. Stewarding is in
   Dusk. Uses only existing tokens. */

.app-frame {
  --rail-width: 5.25rem;
  --bar-height: 4rem;
  --bar-space: 0px;
}

/* Until the session is known (and on the sign-in screen) there is no shell. */
.skip-link {
  position: fixed;
  z-index: 60;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 6px 20px var(--shadow-soft);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; outline: 2px solid var(--signature-text); outline-offset: 2px; }
body:not(:has(.app-frame.has-nav)) .skip-link { display: none; }

.app-nav[hidden], .app-nav [hidden] { display: none !important; }

.app-nav {
  display: flex;
  z-index: 20;
  /* Holds still across the page-to-page cross-fade (tokens.css, L10). */
  view-transition-name: app-nav;
  background: var(--surface);
  color: var(--text-muted);
}
.app-nav-list { display: flex; margin: 0; padding: 0; list-style: none; }
.app-nav-entry { display: flex; }

.app-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 0.9rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}
.app-nav-item:hover { color: var(--text); }
.app-nav-item:focus-visible { outline: 2px solid var(--signature-text); outline-offset: 2px; }

.app-nav-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 2rem;
  border-radius: 1rem;
}
.app-nav-icon svg { width: 1.4rem; height: 1.4rem; }

.app-nav-item[aria-current] { color: var(--text); font-weight: 700; }
.app-nav-item[aria-current] .app-nav-icon { background: color-mix(in srgb, var(--signature) 18%, var(--surface)); }

.app-nav-badge {
  position: absolute;
  top: -0.2rem;
  right: 0.3rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--signature);
  color: var(--on-signature);
  font-size: var(--type-caption);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25rem;
  text-align: center;
}

/* The installation's own icon heads the rail (Lantern Next L2, owner decision). Its
   name is shown at the top of each list pane and each page instead (panes.css and the
   page header below), where a long name has room; here it stays as text for screen
   readers, so the brand is never a bare image. It's a header, not a control: no hover,
   no pointer. Any icon an operator sets is shown as given, in a rounded frame with a
   fine edge so a dark icon doesn't vanish into a dark rail. */
.app-nav-brand {
  display: grid;
  justify-items: center;
  margin: 0 0 1.1rem;
  cursor: default;
  color: var(--text);
}
.app-nav-brand img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 22%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line);
}
.app-nav-brand span {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Stewarding, for staff, in Dusk. */
.app-nav-steward .app-nav-item { color: var(--steward); }
.app-nav-steward .app-nav-item[aria-current] .app-nav-icon { background: color-mix(in srgb, var(--steward) 18%, var(--surface)); }

/* Wide screens: a rail beside the page. Extra width goes to the page. */
@media (min-width: 48rem) {
  .app-frame.has-nav {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    align-items: start;
  }
  .app-frame.has-nav > :is(main, .chat-shell, .messages-shell) { grid-column: 2; min-width: 0; }
  .app-nav {
    position: sticky;
    top: 0;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    padding: 1rem 0;
    /* Part of the quiet frame (L2): the page's own ground, and no line beside it. */
    background: var(--ground);
  }
  .app-nav-list { flex-direction: column; gap: 0.75rem; }
  /* Each item takes the whole rail, and its label stays inside it: "Stewarding" in bold
     is about 77px, wider than a narrower item, and text that spills past the window's left
     edge can't be scrolled into view. With wider letters (text spacing, a minimum font size)
     a label wraps inside its item instead of overflowing. */
  .app-nav-item { box-sizing: border-box; width: var(--rail-width); min-height: 3.5rem; }
  .app-nav-label { max-width: 100%; overflow-wrap: anywhere; }
  .app-nav-steward { margin-top: auto; }
}

/* Phones: CCM's bottom bar, gone while typing so the composer keeps its room:
   a focused message box, or (data-keyboard, shell.js) any on-screen keyboard.
   Other fields don't count by focus alone, since autofocus opens no keyboard. */
@media (max-width: 47.99rem) {
  .app-frame.has-nav { --bar-space: calc(var(--bar-height) + env(safe-area-inset-bottom, 0px)); padding-bottom: var(--bar-space); }
  .app-nav {
    position: fixed;
    inset: auto 0 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--line);
  }
  .app-nav-list { flex: 1; }
  /* Every destination keeps its slot (S7g): slots shrink, never drop off the bar. */
  .app-nav-entry { flex: 1 1 0; min-width: 0; justify-content: center; }
  .app-nav-item { flex: 1; min-width: 0; min-height: var(--bar-height); }
  .app-nav-icon { width: min(3.5rem, 100%); }
  .app-nav-brand { display: none; }
  /* On phones Stewarding lives inside You (S2b); until then the account menu has it. */
  .app-nav-steward { display: none; }

  .app-frame.has-nav:is([data-keyboard], :has(textarea:focus)) {
    --bar-space: 0px;
  }
  .app-frame.has-nav:is([data-keyboard], :has(textarea:focus)) > .app-nav {
    display: none;
  }

  /* The chat page is exactly one viewport tall; the bar takes its share. */
  .app-frame.has-nav .chat-shell { height: calc(100vh - var(--bar-space)); height: calc(100dvh - var(--bar-space)); }
}

@media (any-pointer: coarse) {
  .app-nav-item { min-width: 3rem; min-height: 3rem; }
}

@media (forced-colors: active) {
  .app-nav-item[aria-current] .app-nav-icon { outline: 2px solid CanvasText; }
  .app-nav-badge { border: 1px solid CanvasText; }
}

/* The unread count read with a tab's name (", 3 unread"; AppShell::item()).
   Invisible but kept inline: a visually-hidden span that is absolutely
   positioned or inline-block counts as a block for the accessible name, and
   Chromium then puts a space before the comma. Zero-size inline text takes no
   room under the label and is still in the accessibility tree. */
.app-nav-count {
  font-size: 0;
  line-height: 0;
  white-space: nowrap;
}

/* Very narrow (a phone with large text): icons only; each label stays the link's name. */
@media (max-width: 20rem) {
  /* Four slots share the bar even with a coarse pointer's 3rem minimum (above): at 180 CSS px
     that minimum pushed You off the screen. Each slot is still about 45px wide. */
  .app-nav-item { min-width: 0; }
  .app-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---- One page header (Lantern Next L2) ----
   Activity, Search and the stewardship pages each styled their own header: titles from
   2rem to 3.25rem, in two weights, with an upper-case tracked eyebrow in three colours.
   They now share the list panes' pattern: the installation's name as a quiet label in
   sentence case (it wraps; it never scrolls the page), then the title in Display M.
   shell.css loads after each page's own stylesheet, so these win at equal weight; the
   pages' phone rules that hide the eyebrow or shrink the title use IDs and still apply. */
:is(.account-header, .admin-header, .message-search-header, .inspection-header, .moderation-header)
  :is(.account-eyebrow, .admin-eyebrow, .message-search-eyebrow, .messages-eyebrow, .moderation-eyebrow) {
  margin: 0 0 0.2rem;
  color: var(--text-muted);
  font-size: var(--type-label);
  font-weight: 600;
  letter-spacing: 0;
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
  text-transform: none;
}

:is(.account-header, .admin-header, .message-search-header, .inspection-header, .moderation-header) h1 {
  font-family: var(--display-font);
  font-size: var(--type-display-m);
  font-weight: 700;
  letter-spacing: var(--title-tracking);
  line-height: var(--leading-display);
  overflow-wrap: anywhere;
}
