/*
 * The signed-in app shell - sidebar and app bar.
 *
 * design-pack v2 (26 Aug 2026) splits the two areas, and this file is the
 * signed-in half of that split:
 *
 *   public pages   -> top header with mega-menus   (.irc-nav, site.css)
 *   signed-in      -> left sidebar plus an app bar (.irc-side / .irc-appbar, here)
 *
 * Adapted from design-pack/design/portal.css. Three deliberate departures from
 * the pack, each because this portal already had a decision the pack did not
 * know about:
 *
 *  1. The pack puts the page <h1> in the app bar. It stays in <main> here. Two
 *     h1s on a page is a strict-mode violation for `page.locator('h1')`, which
 *     no-js.spec.ts uses to read data-interactive, and it would move the heading
 *     out of the landmark that names the page. The app bar carries the brand
 *     instead.
 *
 *  2. The pack collapses the sidebar into the content flow below 1000px. Here it
 *     is hidden and the existing .irc-drawer takes over, driven by the existing
 *     wwwroot/js/nav.js. A 30-item nav stacked above the content pushes the page
 *     itself off the first screen on a phone, and the drawer already exists.
 *
 *  3. Colour goes through site.css's semantic aliases (--accent, --bg, --border)
 *     rather than the raw brand tokens, so the derived dark scheme keeps working
 *     and so every white-on-red surface here inherits --irc-red-text-bg - see
 *     the note in tokens.css on which reds can carry text.
 *
 * Loaded after site.css. Nothing here is interactive: the shell is static SSR
 * (ADR-0006), and a sidebar does not need a circuit.
 */

/* ---------- app shell ---------- */

.irc-app {
  background: var(--surface);
  display: grid;
  /* minmax(0,1fr) rather than 1fr: a grid track's default min-width is auto,
     which lets a wide table in the content push the whole shell sideways. */
  grid-template-columns: var(--irc-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* The content column. `main` keeps its own twelve-column grid untouched - this
   only gives it a column to sit in. */
.irc-app__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.irc-app__body > main {
  flex: 1 0 auto;
}

/* ---------- sidebar (.irc-side) ---------- */

.irc-side {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.irc-side__head {
  border-bottom: 1px solid var(--border);
  padding: var(--irc-s5);
}

/* The portal's own name, under the lockup. Says which of the organisation's
   three signed-in surfaces this is - the pack's README notes two others are
   live today. */
.irc-side__portal {
  color: var(--muted);
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-100);
  font-weight: 700;
  letter-spacing: var(--irc-tracking-caps);
  margin: var(--irc-s2) 0 0;
  text-transform: uppercase;
}

/* IRC-2618: the label is the link to the dashboard now the logo goes to redcross.ie. */
.irc-side__portal a {
  color: inherit;
}

.irc-side__nav {
  display: grid;
  flex: 1;
  gap: var(--irc-s5);
  padding: var(--irc-s4) var(--irc-s3);
}

.irc-side__group-title {
  color: var(--muted);
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-100);
  font-weight: 700;
  letter-spacing: var(--irc-tracking-caps);
  margin: 0 0 var(--irc-s2);
  padding-inline: var(--irc-s3);
  text-transform: uppercase;
}

/* Second level. The catalogue's Manage section carries five titled groups, and
   flattening them produces an eighteen-item run with no seam in it. */
.irc-side__sub {
  margin-bottom: var(--irc-s3);
}

.irc-side__sub-title {
  color: var(--muted);
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-100);
  font-weight: 600;
  margin: 0 0 var(--irc-s1);
  padding-inline: var(--irc-s3);
}

.irc-side__list {
  display: grid;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.irc-side__list a {
  align-items: center;
  border-left: 3px solid transparent;
  border-radius: var(--irc-radius-sm);
  color: var(--fg);
  display: flex;
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-200);
  font-weight: 600;
  gap: var(--irc-s3);
  justify-content: space-between;
  /* 44px minimum tap target, which the pack sets and WCAG 2.2 AA asks for. */
  min-height: 44px;
  padding: var(--irc-s3);
  text-decoration: none;
}

.irc-side__list a:hover {
  background: var(--surface);
  color: var(--fg);
}

.irc-side__list a[aria-current='page'] {
  background: var(--accent-subtle);
  border-left-color: var(--accent-text);
  color: var(--accent-text);
}

.irc-side__foot {
  border-top: 1px solid var(--border);
  font-size: var(--irc-fs-100);
  padding: var(--irc-s4) var(--irc-s5);
}

/* ---------- app bar (.irc-appbar) ---------- */

.irc-appbar {
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--irc-s3);
  min-height: var(--irc-appbar-h);
  padding: var(--irc-s2) var(--irc-s5);
  position: sticky;
  top: 0;
  z-index: var(--irc-z-header);
}

.irc-appbar__spacer {
  flex: 1 1 auto;
}

/* Shown only when the sidebar is not - there is never a moment with two
   lockups on screen, and never a moment with none. */
.irc-appbar__brand {
  display: none;
}

/*
 * What gives when the bar is short of room, in order. The search box shrinks
 * first, down to the width its own button needs; then the member's name and
 * affiliation truncate. The controls - burger, inbox badge, sign-out - never
 * shrink and never wrap their labels: a two-line "Sign out" and a Search button
 * spilling over the badge are what happened between 720px and 1160px before
 * this (15 Oct 2026). Below 60rem and 54rem the name and the search box are
 * withdrawn outright - see the responsive section.
 */
.irc-appbar > .irc-burger,
.irc-appbar > form:not(.irc-search),
.irc-appbar > a {
  flex: none;
}

.irc-appbar button,
.irc-appbar a {
  white-space: nowrap;
}

.irc-appbar__user {
  align-items: center;
  border-left: 1px solid var(--border);
  display: flex;
  flex: 0 1 auto;
  gap: var(--irc-s3);
  min-width: 0;
  padding-left: var(--irc-s4);
}

.irc-avatar {
  /* Decorative - the name is right beside it in text - but it carries white on
     red, so it uses the passing value rather than the brand one anyway. */
  background: var(--accent);
  border-radius: 50%;
  color: var(--accent-fg);
  display: grid;
  flex: none;
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-200);
  font-weight: 700;
  height: 36px;
  place-items: center;
  width: 36px;
}

.irc-appbar__meta {
  font-size: var(--irc-fs-100);
  line-height: 1.3;
  /* A long name or branch truncates rather than pushing the controls over. */
  max-width: 14rem;
  min-width: 0;
}

.irc-appbar__meta strong {
  display: block;
  font-family: var(--irc-font-display);
  font-size: var(--irc-fs-200);
}

.irc-appbar__meta span {
  color: var(--muted);
  display: block;
}

.irc-appbar__meta strong,
.irc-appbar__meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- app bar search ---------- */

.irc-search {
  display: flex;
  flex: 0 1 260px;
  gap: var(--irc-s2);
  /* Room for the Search button and a usable field. With min-width: 0 the form
     shrank below its own button, which then spilled over the inbox badge. */
  min-width: 14rem;
}

.irc-search input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--irc-radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: var(--irc-fs-200);
  min-height: 40px;
  min-width: 0;
  padding: 0 var(--irc-s3);
  width: 100%;
}

.irc-search button {
  flex: none;
  letter-spacing: normal;
  min-height: 40px;
  padding-inline: var(--irc-s4);
  text-transform: none;
}

/* The /search screen's own field. A grid item, so .irc-search's flex-basis does
   not apply and it would otherwise run the full twelve columns. */
.search-form {
  margin-bottom: var(--irc-s5);
  max-width: var(--measure);
}

/* ---------- search results ---------- */

.search-results {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results li {
  border-bottom: 1px solid var(--border);
  padding: var(--irc-s3) 0;
}

.search-results li:last-child {
  border-bottom: 0;
}

.search-results a {
  font-family: var(--irc-font-display);
  font-weight: 600;
}

.search-results .search-results__where {
  color: var(--muted);
  display: block;
  font-family: var(--irc-font-body);
  font-size: var(--irc-fs-200);
  font-weight: 400;
}

/* ---------- responsive ---------- */

/*
 * 68rem is site.css's own drawer breakpoint, reused rather than re-chosen. Below
 * it the drawer is what nav.js will open and `.irc-burger` is already shown;
 * above it the drawer is `display: none` and the burger is already hidden. One
 * threshold for both shells means there is no band where the sidebar and the
 * burger are both on screen offering the same links.
 *
 * The sidebar is withdrawn rather than restacked into the content flow, which is
 * where this departs from the pack: the alternative leaves a phone user
 * scrolling past thirty links to reach the page they asked for.
 */
@media (max-width: 68rem) {
  .irc-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .irc-side {
    display: none;
  }

  .irc-appbar__brand {
    display: flex;
  }
}

/*
 * ...and above it the sidebar is the navigation, so the app bar's burger and the
 * drawer it opens are withdrawn. site.css keeps the PUBLIC header's burger up to
 * 77.5rem (its mega-menus need 1240px), and the app bar reuses that burger - so
 * from 68rem to 77.5rem the signed-in shell showed the sidebar AND a Menu button
 * opening the same links, and the burger's 91px pushed the rest of the bar into
 * the overlaps described above. One threshold for the signed-in shell again.
 */
@media (min-width: 68.001rem) {
  .irc-appbar .irc-burger,
  .irc-app ~ .irc-drawer {
    display: none;
  }
}

/*
 * The middle band: no sidebar, so the burger and the lockup are back in the bar,
 * and the full row needs about 940px. The member's name goes first - the avatar
 * stays, and the dashboard greets them by name - and below 54rem the search box
 * follows it into the drawer, as on a phone. Measured, not guessed: the sweep in
 * layout.spec.ts ("The app bar between a phone and a desktop") holds both.
 */
@media (max-width: 60rem) {
  .irc-appbar__meta {
    display: none;
  }
}

@media (max-width: 54rem) {
  .irc-appbar__search {
    display: none;
  }
}

/*
 * The global `button` rule paints every button with the primary fill, and
 * `button:hover:not(:disabled)` outranks a single class - the same trap
 * site.css documents for the header burger. Without this the app bar's burger
 * turns into a red block on hover.
 */
.irc-appbar .irc-burger,
.irc-appbar .irc-burger:hover {
  background: none;
  color: var(--fg);
}

/*
 * A phone app bar carries the burger, the lockup, the inbox and the way out.
 * The search box is reached from the drawer instead, as a link to the screen
 * that owns it - one search landmark on the page rather than two.
 *
 * flex-wrap is the belt to that braces: layout.spec.ts asserts zero horizontal
 * overflow at 360px on every signed-in page, and a nowrap row of five controls
 * is exactly the thing that broke it last time. Wrapping makes the bar taller
 * instead of wider, which is the failure mode that is allowed to happen.
 */
@media (max-width: 44rem) {
  .irc-appbar {
    flex-wrap: wrap;
    gap: var(--irc-s2);
    padding-inline: var(--irc-s4);
  }

  .irc-appbar__search,
  .irc-appbar__meta {
    display: none;
  }

  .irc-appbar__user {
    border-left: 0;
    padding-left: 0;
  }
}
