/* ══════════════════════════════════════════════════════════════════════════
   pshell.css — Probily application shell.

   The shell is built on TWO pinned open-source foundations:

     · PatternFly 6.6.0 (MIT, Red Hat) — the visual application-shell
       components: Page, Nav, Menu, MenuToggle, Avatar, Label, Spinner, Alert.
       Consumed as `vendor/patternfly-6.6.0-components.css` plus a subset of
       its design tokens. Every PatternFly class carries the `pf-v6-` prefix,
       which is why it can be dropped into 651 KB of existing unlayered CSS
       without touching a single existing rule — measured: 0 of 381 elements
       moved on the Report page, against 214 for the Bootstrap-derived
       alternative.

     · Unpoly 3.14.3 (MIT) — navigation lifecycle. Its CSS is namespaced to
       `up-*` custom elements and `[up-*]` attributes, so it collides with
       nothing either.

   THIS file is the deliberate mapping from PatternFly's design language to
   Probily's. PatternFly ships as a light-first Red Hat console; Probily is a
   dark amber "Bureau". We do not restyle PatternFly's components rule by rule
   — we re-point the ~40 semantic tokens they are built from at Bureau values,
   which is the supported theming path and survives a PatternFly upgrade.

   Nothing here uses `!important` and nothing here targets a non-`pf-` class
   belonging to another part of the app.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. PatternFly semantic tokens → Bureau values ────────────────────────
   Re-pointed at :root so every PatternFly component inherits Probily's
   palette, type and motion without per-component overrides. */
:root {
  /* Surfaces */
  --pf-t--global--background--color--primary--default: var(--bg-0);
  --pf-t--global--background--color--secondary--default: var(--bg-1);
  --pf-t--global--background--color--control--default: transparent;
  --pf-t--global--background--color--action--plain--default: transparent;
  --pf-t--global--background--color--action--plain--hover: color-mix(in oklch, white 5%, transparent);
  --pf-t--global--background--color--action--plain--clicked: color-mix(in oklch, white 8%, transparent);
  --pf-t--global--background--color--floating--default: var(--bg-2);

  /* Text */
  --pf-t--global--text--color--regular: var(--text-secondary);
  --pf-t--global--text--color--subtle: var(--text-tertiary);
  --pf-t--global--text--color--disabled: var(--text-disabled);
  --pf-t--global--text--color--brand--default: var(--brand-500);
  --pf-t--global--text--color--brand--hover: var(--brand-400);
  --pf-t--global--text--color--on-brand--default: var(--gray-1000, #0b0b0c);

  /* Icons */
  --pf-t--global--icon--color--regular: var(--text-tertiary);
  --pf-t--global--icon--color--subtle: var(--text-disabled);
  --pf-t--global--icon--color--brand--default: var(--brand-500);

  /* Borders — Bureau borders are colour-mixed alpha, not solid greys */
  --pf-t--global--border--color--default: var(--border-subtle);
  --pf-t--global--border--color--hover: var(--border-default);
  --pf-t--global--border--color--high-contrast: var(--border-strong);
  --pf-t--global--border--color--brand--default: var(--brand-600);
  --pf-t--global--border--width--regular: 1px;
  --pf-t--global--border--width--high-contrast--regular: 1px;
  --pf-t--global--border--radius--small: 6px;
  --pf-t--global--border--radius--medium: 9px;
  --pf-t--global--border--radius--large: 12px;
  --pf-t--global--border--radius--pill: 999px;

  /* Type — Probily is Geist, never PatternFly's Red Hat Text */
  --pf-t--global--font--family--body: var(--font-sans);
  --pf-t--global--font--family--heading: var(--font-sans);
  --pf-t--global--font--family--mono: var(--font-mono);
  --pf-t--global--font--size--body--default: 0.875rem;
  --pf-t--global--font--size--body--sm: 0.8125rem;
  --pf-t--global--font--weight--body--default: 450;
  --pf-t--global--font--weight--body--bold: 600;

  /* Focus — one ring, amber, everywhere */
  --pf-t--global--color--brand--default: var(--brand-500);
  --pf-t--global--box-shadow--color--100: color-mix(in oklch, black 40%, transparent);

  /* Motion — Bureau is restrained; PatternFly's defaults are a touch slow */
  --pf-t--global--motion--duration--fade--default: 120ms;
  --pf-t--global--motion--duration--fade--short: 90ms;
}

/* ── 2. The shell frame ───────────────────────────────────────────────────
   The sidebar occupies the SAME grid slot the previous rail did
   (`.app > .cbsb { grid-column:1; grid-row:1/-1 }` in tokens-bureau.css), so
   no page layout changes. Only the rail's own contents are new. */
.pshell {
  grid-column: 1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  inline-size: 248px;
  min-inline-size: 0;
  block-size: 100%;
  overflow: hidden;
  background: var(--bg-1);
  border-inline-end: 1px solid var(--border-subtle);
}

/* Brand — fixed height so the rail header never shifts between surfaces. */
.pshell-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  block-size: 52px;
  padding-inline: 16px;
  flex: 0 0 auto;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.pshell-brand img { display: block; }

/* Primary action. The one amber element in the rail — everything else is
   quiet, so "New report" reads as the primary verb of the product. */
.pshell-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 2px 12px 12px;
  padding-block: 9px;
  flex: 0 0 auto;
  border-radius: 8px;
  /* Literal fallbacks on BOTH halves. The label is near-black by design, so a
     missing `--brand-500` does not merely lose the amber — it paints black on
     black and the button becomes an almost invisible glyph with no text. A
     token that fails to load must degrade to a visible button, never to a
     disappeared one. */
  background: var(--brand-500, #e0a33e);
  color: var(--gray-1000, #0b0b0c);
  font-size: 0.8125rem;
  font-weight: 600;
  /* The label is the action. It may never wrap or be clipped away. */
  white-space: nowrap;
  text-decoration: none;
  transition: background 120ms var(--pf-t--global--motion--timing-function--default, ease);
}
.pshell-cta:hover { background: var(--brand-400); }
.pshell-cta:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }

/* Scroll region — the nav scrolls, the brand and account row do not. */
.pshell-scroll {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ── 3. PatternFly Nav, mapped to Bureau ─────────────────────────────────── */
/* ONE deliberate step between a group and the next group's label. PatternFly
   derives this from an em-based margin, which measured 9.13px here — a value
   nobody chose, and half of a rhythm the rest of the rail does not share. */
.pshell .pf-v6-c-nav__section { margin-block-start: 14px; }
.pshell .pf-v6-c-nav__section + .pf-v6-c-nav__section { margin-block-start: 14px; }
.pshell .pf-v6-c-nav__list { margin: 0; padding: 0; list-style: none; }
.pshell .pf-v6-c-nav__section > .pf-v6-c-nav__list { margin: 0; padding: 0; list-style: none; }

.pshell .pf-v6-c-nav__section-title {
  margin: 0;
  padding-inline: 16px;
  padding-block-end: 5px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  border: 0;
}

.pshell .pf-v6-c-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  font-size: 0.8438rem;
  line-height: 1.3;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  transition: color 120ms ease, background 120ms ease;
}
.pshell .pf-v6-c-nav__link::before,
.pshell .pf-v6-c-nav__link::after { border: 0; inset-inline-start: 0; }

.pshell .pf-v6-c-nav__link:hover { color: var(--text-primary); background: color-mix(in oklch, white 4%, transparent); }
.pshell .pf-v6-c-nav__link:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }

/* Active route. Unpoly maintains `pf-m-current` client-side (see pshell.js);
   the server renders the same class so the state is correct without JS and
   there is never a moment where nothing is marked. */
.pshell .pf-v6-c-nav__link.pf-m-current {
  color: var(--text-primary);
  background: color-mix(in oklch, var(--brand-500) 10%, transparent);
  box-shadow: inset 2px 0 0 var(--brand-500);
  font-weight: 550;
}
.pshell .pf-v6-c-nav__link.pf-m-current .pshell-ico { color: var(--brand-500); }

.pshell-ico { flex: 0 0 auto; color: var(--text-disabled); transition: color 120ms ease; }
.pshell .pf-v6-c-nav__link:hover .pshell-ico { color: var(--text-tertiary); }

/* Long labels truncate rather than wrap — a two-line nav item breaks the
   vertical rhythm and is the most common way an app menu starts to look
   improvised. */
.pshell .pf-v6-c-nav__link-text {
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Count badge */
.pshell .pf-v6-c-badge {
  margin-inline-start: auto;
  flex: 0 0 auto;
  background: color-mix(in oklch, white 8%, transparent);
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  font-weight: 600;
  min-inline-size: 20px;
  padding-inline: 6px;
}

/* Sub-items (recent reports) — one indent level, quieter. */
.pshell-sub .pf-v6-c-nav__link {
  padding-block: 5px;
  padding-inline-start: 42px;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

/* ── 4. Current-Project context ──────────────────────────────────────────
   Rendered only where the request genuinely has an open Project, and marked
   `[up-hungry]` so it follows navigation without the rest of the rail being
   replaced. */
.pshell-ctx {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 2px;
  padding: 6px 10px;
  border-radius: 7px;
  background: color-mix(in oklch, var(--brand-500) 7%, transparent);
  border: 1px solid color-mix(in oklch, var(--brand-500) 18%, transparent);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.pshell-ctx .dot {
  inline-size: 6px; block-size: 6px; flex: 0 0 auto;
  border-radius: 50%; background: var(--brand-500);
}
.pshell-ctx .lbl { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pshell-ctx:empty { display: none; }

/* ── 5. Account area — PatternFly MenuToggle + Menu ──────────────────────── */
/* NO border across the top. Settings and the account row are anchored to the
   bottom of the rail — the correct pattern, and the one that keeps the account
   from moving as you navigate. But on a sparse workspace that leaves ~449px of
   empty rail above them, and a hairline drawn across that emptiness reads as
   an unfinished panel rather than as quiet space. Judged from the rendered
   rail, not from the number: the gap itself is fine, the rule through it was
   not. Spacing separates the two regions instead. */
.pshell-foot {
  flex: 0 0 auto;
  /* NO inline padding. The foot holds a nav link (Settings), and a nav link
     brings its own 16px inset — padding here as well pushed the Settings icon
     to 28px while every other icon in the rail sits at 16px. One left rhythm:
     icons at 16, labels at 42, all the way down. The account chip is a bordered
     pill rather than a row, so it takes the 12px inset itself. */
  padding: 10px 0 12px;
}
.pshell-foot > .pshell-acct { margin-inline: 12px; }

.pshell .pf-v6-c-menu-toggle {
  inline-size: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  text-align: start;
  cursor: pointer;
}
.pshell .pf-v6-c-menu-toggle:hover { background: color-mix(in oklch, white 5%, transparent); border-color: var(--border-subtle); }
.pshell .pf-v6-c-menu-toggle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.pshell .pf-v6-c-menu-toggle[aria-expanded="true"] { background: color-mix(in oklch, white 6%, transparent); border-color: var(--border-default); }

.pshell .pf-v6-c-avatar {
  inline-size: 28px; block-size: 28px; flex: 0 0 auto;
  border-radius: 50%;
  background: color-mix(in oklch, var(--brand-500) 18%, var(--bg-3));
  color: var(--brand-400);
  display: grid; place-items: center;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid color-mix(in oklch, var(--brand-500) 25%, transparent);
}

/* `display:block` matters: these are `<span>`s, and `text-overflow: ellipsis`
   has no effect on an inline box — the address was clipped mid-domain with no
   ellipsis, which reads as a rendering fault rather than a shortened label. */
.pshell-who { display: block; min-inline-size: 0; flex: 1 1 auto; }
.pshell-who .em {
  display: block;
  font-size: 0.75rem; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pshell-who .pl {
  display: block;
  font-size: 0.625rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-disabled); margin-block-start: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* The dropdown. `<details>` keeps it keyboard- and no-JS-operable; PatternFly
   supplies the panel's visual language. */
.pshell-acct { position: relative; }
.pshell-acct > summary { list-style: none; }
.pshell-acct > summary::-webkit-details-marker { display: none; }
.pshell-acct .pf-v6-c-menu {
  position: absolute;
  inset-block-end: calc(100% + 6px);
  inset-inline: 0;
  z-index: 60;
  background: var(--bg-2);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: 0 12px 32px color-mix(in oklch, black 55%, transparent);
  padding-block: 5px;
  overflow: hidden;
}
.pshell-acct .pf-v6-c-menu__list-item + .pf-v6-c-menu__list-item .pf-v6-c-menu__item { border-block-start: 0; }
/* `display:block`, not flex. These items are text only, and PatternFly's own
   menu-item rules add inline padding of their own on top of a flex container,
   which pushed the label 55px in from a 13px padding edge. A block box honours
   the padding directly and cannot drift. `<button>` also centres its text by
   default, so `text-align` is set explicitly or the sign-out item sits centred
   while the two links sit left — three items, two alignments. */
.pshell-acct .pf-v6-c-menu__item {
  display: block;
  inline-size: 100%;
  padding-block: 8px;
  padding-inline: 13px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: transparent; border: 0;
  text-align: start;
  text-decoration: none; cursor: pointer;
}
.pshell-acct .pf-v6-c-menu__list { margin: 0; padding: 0; list-style: none; }
.pshell-acct .pf-v6-c-menu__item:hover { background: color-mix(in oklch, white 6%, transparent); color: var(--text-primary); }
.pshell-acct .pf-v6-c-menu__item:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.pshell-acct .pf-v6-c-divider { margin-block: 5px; border-block-start: 1px solid var(--border-subtle); }
.pshell-acct .pshell-danger { color: var(--danger); }

/* ── 6. Navigation feedback ──────────────────────────────────────────────
   Unpoly's progress bar, in Probily's amber. This is the ONLY thing that
   should move during a navigation — the shell itself must not. */
:root { --up-progress-bar-height: 2px; }
up-progress-bar {
  background-color: var(--brand-500);
  box-shadow: 0 0 8px color-mix(in oklch, var(--brand-500) 60%, transparent);
}

/* While a navigation is in flight the outgoing content dims very slightly.
   Enough to acknowledge the click, far too little to read as a page change. */
.main.up-loading { opacity: 0.62; transition: opacity 140ms ease 90ms; }

/* The clicked nav item shows it was the one activated. */
.pshell .pf-v6-c-nav__link.up-active { color: var(--text-primary); }

/* ── 7. Mobile ───────────────────────────────────────────────────────────
   Below 900px the rail becomes an overlay drawer. The existing
   `cabinet-mobile.js` toggles `.open` on the rail and `.cbsb-scrim` on the
   backdrop; both selectors are preserved so that file keeps working. */
.pshell-burger {
  display: none;
  position: fixed;
  inset-block-start: 10px;
  inset-inline-start: 10px;
  z-index: 70;
  inline-size: 38px; block-size: 38px;
  align-items: center; justify-content: center;
  border-radius: 9px;
  background: var(--bg-2);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
}
.pshell-burger:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

@media (max-width: 900px) {
  .pshell {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 200ms var(--pf-t--global--motion--timing-function--default, cubic-bezier(0.2, 0, 0.2, 1));
    box-shadow: 0 0 40px color-mix(in oklch, black 60%, transparent);
  }
  .pshell.open { transform: translateX(0); }
  .pshell-burger { display: flex; }
  .pshell-scrim {
    position: fixed; inset: 0; z-index: 79;
    background: color-mix(in oklch, black 55%, transparent);
    opacity: 0; pointer-events: none;
    transition: opacity 200ms ease;
  }
  .pshell-scrim.on { opacity: 1; pointer-events: auto; }
  body.pshell-locked { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .pshell,
  .pshell-cta,
  .pshell .pf-v6-c-nav__link,
  .main.up-loading { transition: none; }
}

/* ── 8. Public (signed-out) variant ──────────────────────────────────────
   A guest on a public Dossier or Report gets the brand and a way in, never a
   navigation full of links that only bounce to /login. */
.pshell--public { inline-size: 60px; align-items: center; }
.pshell--public .pshell-brand { padding-inline: 0; justify-content: center; }
.pshell--public .pshell-brand .wm { display: none; }
.pshell--public .pshell-signin {
  display: grid; place-items: center;
  inline-size: 38px; block-size: 38px;
  margin-block-start: auto; margin-block-end: 14px;
  border-radius: 9px;
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
}
.pshell--public .pshell-signin:hover { color: var(--brand-500); border-color: var(--brand-600); }
@media (max-width: 900px) { .pshell--public { display: none; } }
