/* Quiet Shelf app shell (QS-1): header and help slot, tab bar, powered-by lockup, route screens.
   Loaded after the explorer's own CSS so the framework floors win: header buttons 48, tab bar 60
   with 18 px labels, lockup row 48 with an 18 px label, body text 18. Tokens only.
   QS-13 fidelity pass: header, tab bar, lockup and content frame match the regenerated reference
   (docs/design/quiet-shelf/reference/quiet-shelf-reference.html, classes .hd, .tb, .pb, .bd). */

html {
  scroll-padding-block: var(--gap);
  /* No double-tap zoom (and no tap delay) on phones; pinch zoom stays (WCAG 1.4.4). */
  touch-action: manipulation;
}

body {
  background: var(--chrome);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
}

.shell {
  background: var(--bg);
}

a {
  color: var(--primary);
  text-decoration: underline;
}

main {
  scroll-padding-block: var(--gap);
}

#main h1 {
  font-family: var(--font-head);
  font-size: var(--fs-title);
  font-weight: var(--weight-head);
  line-height: var(--lh-head);
}

:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* ---------- Header ----------
   Web (O2w, H3): the --chrome bar; a 40 px rounded --card tile with the library mark (the
   ThemeConfig logo, else the library's initial in --primary); the full library name on one line,
   system bold, --on-chrome; the round help button. 9 px above and 14 px below a 48 px button. */
.chrome {
  gap: var(--gap);
  padding: 9px var(--gutter) 14px;
  /* The page uses viewport-fit=cover. The top inset is iOS only (AIA-80, below); env() is 0
     elsewhere, and on Android (adjustMarginsForEdgeToEdge "force" insets the WebView natively). */
  padding-left: calc(var(--gutter) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right, 0px));
  background: var(--chrome);
  color: var(--on-chrome);
}

.chrome :focus-visible {
  outline: var(--focus-w) solid var(--focus-on-chrome);
  outline-offset: var(--focus-offset);
}

.brandline {
  gap: var(--gap);
}

.logoTile {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--primary);
}

.logoTile__initial {
  font-family: var(--font-head);
  font-size: var(--fs-action);
  font-weight: 800;
  line-height: 1;
}

/* A ThemeConfig logo (always an <img>, Shell.bindBrand) is fitted inside the tile, never cropped. */
.logoTile__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brandnames {
  flex: 1 1 auto;
}

/* One line: the full name, or the short name when the full one does not fit (Shell.fitBrandName). */
.brandnames strong {
  color: var(--on-chrome);
  font-family: var(--font-head);
  font-size: var(--fs-body);
  font-weight: var(--weight-head);
  line-height: var(--lh-head);
}

.acctBtn {
  min-height: var(--target-min);
  font-family: var(--font-body);
  font-size: var(--fs-body);
}

.iconBtn {
  width: var(--target-min);
  height: var(--target-min);
}

.chromeActions {
  gap: var(--gap);
}

.qsHelpSlot {
  display: flex;
}

/* The one help slot (Q20): a round 48 px header button, translucent white on the chrome. Its
   accessible name is the "Help" text, visually hidden. */
.qsHelp {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--target-min);
  height: var(--target-min);
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--on-chrome-fill);
  color: var(--on-chrome);
  cursor: pointer;
}

.qsHelp:hover {
  background: var(--on-chrome-fill-hover);
}

.qsHelp .ic {
  width: 28px;
  height: 28px;
}

.qsHelp__label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Native (H1, H2): no chrome bar. The library chip (opens L3) at the top left and the same round
   help button at the top right, on --bg. Before a library is chosen there is no chip and the
   brand line stays. A kiosk keeps its chrome header. */
:root[data-platform="native"]:not([data-surface="kiosk"]) .chrome {
  background: var(--bg);
  color: var(--fg);
}

/* AIA-80: on iOS the header starts under the status bar and the Dynamic Island, which overlapped the
   library chip. Add the top safe-area inset to the 9 px top padding; Android and the web are unchanged. */
:root[data-os="ios"][data-platform="native"]:not([data-surface="kiosk"]) .chrome {
  padding-top: calc(9px + env(safe-area-inset-top, 0px));
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .chrome :focus-visible {
  outline-color: var(--focus);
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .brandnames strong {
  color: var(--fg);
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .chrome:has(.qsLibChip) .brandline {
  display: none;
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .chrome:has(.qsLibChip) .chromeActions {
  flex: 1 1 auto;
  min-width: 0;
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .qsHelp {
  background: var(--primary-soft);
  color: var(--primary);
}

:root[data-platform="native"]:not([data-surface="kiosk"]) .qsHelp:hover {
  background: var(--line);
}

/* The library chip: a --primary-soft pill, a --primary dot, the name, a chevron. */
.chrome .qsLibChip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: var(--target-min);
  max-width: 100%;
  margin-inline-end: auto;
  padding: 4px 14px 4px 11px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--weight-action);
  line-height: var(--lh-head);
  cursor: pointer;
}

.qsLibChip__dot {
  flex: none;
  width: 23px;
  height: 23px;
  border-radius: var(--r-pill);
  background: var(--primary);
}

.qsLibChip .qsLibChip__chev {
  width: 20px;
  height: 20px;
}

.chrome .qsLibChip:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--focus-offset);
}

.skip {
  min-height: var(--target-min);
  display: inline-flex;
  align-items: center;
}

/* The skip link shows over the header: its ring sits on the chrome (high contrast, more
   contrast and the EnvisionWare light set would lose a --focus ring there). */
.skip:focus-visible {
  outline-color: var(--focus-on-chrome);
}

/* ---------- Tab bar ---------- */
.tabbar {
  grid-template-columns: repeat(var(--tab-count, 3), minmax(0, 1fr));
  overflow-x: visible;
  /* Clear of the iPhone home indicator (see .chrome). */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card);
  border-top: var(--line-w) solid var(--line);
}

/* Tab labels: system bold, uppercase, +0.08em, 18 px (DESIGN.md 3); 20 px icons over the label.
   The current tab: --primary, a 3 px top bar over the middle 60% and the filled icon. */
.tabbar button {
  position: relative;
  gap: 3px;
  min-height: var(--target-tab);
  padding: 6px 2px;
  color: var(--muted);
  font-family: var(--font-head);
  font-size: var(--fs-tab);
  font-weight: var(--weight-head);
  letter-spacing: var(--ls-eyebrow);
  line-height: var(--lh-head);
  text-transform: uppercase;
}

.tabbar button .ic {
  width: var(--icon-tab);
  height: var(--icon-tab);
}

.tabbar button[aria-current="page"] {
  color: var(--primary);
  box-shadow: none;
}

.tabbar button[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: var(--tab-bar-w);
  border-radius: 0 0 var(--r-pill) var(--r-pill);
  background: var(--primary);
}

.tabbar button[aria-current="page"] .tabLabel {
  font-weight: var(--weight-head);
}

/* The line icon by default; its filled variant (Shell.tabIconHtml) only on the current tab. */
.tabbar button .ic--fill,
.tabbar button[aria-current="page"] .ic--line {
  display: none;
}

.tabbar button[aria-current="page"] .ic--fill {
  display: block;
  stroke-width: 1.75;
}

.tabbar .ic__cut {
  fill: var(--card);
  stroke: var(--card);
}

/* A label wraps between words and hyphenates a long one (html lang picks the rules), never
   mid-word at an arbitrary letter. */
.tabbar button .tabLabel {
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Five or six tabs at large text, or on a narrow screen (22.5em is 360 px at the default size and
   wider when the browser text size is raised): two rows of three, so labels keep whole words. */
:root[data-text="large"] .tabbar[data-tab-count="5"],
:root[data-text="large"] .tabbar[data-tab-count="6"],
:root[data-text="larger"] .tabbar[data-tab-count="5"],
:root[data-text="larger"] .tabbar[data-tab-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 22.5em) {
  .tabbar[data-tab-count="5"],
  .tabbar[data-tab-count="6"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Powered-by lockup (never themeable) ----------
   A 48 px row on --card under the tab bar: the multicolor Iris mark (a fixed image,
   assets/envisionware-iris.png, decorative inside the labelled button), then "Powered by
   EnvisionWare" in regular weight and --muted, centered (DESIGN.md 5). */
.powered {
  display: block;
  padding: 0;
  background: var(--card);
  border-top: 0;
  font-size: var(--fs-body);
  color: var(--muted);
}

.qsLockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: var(--target-min);
  padding: 0 var(--gutter);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--weight-body);
  line-height: var(--lh-head);
  cursor: pointer;
}

.qsLockup__mark {
  flex: none;
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.qsLockup:focus-visible {
  outline-offset: calc(-1 * (var(--focus-w) + 1px));
}

/* ---------- Content frame ----------
   The page ground is --bg and the content gutter is 16 px (DESIGN.md 4), set once here on the
   scrolling main; a screen adds no side padding of its own (views remove theirs). 6 px above the
   first block and 11 px under the last, as the reference body (.bd). */
#main {
  padding: 6px var(--gutter) 11px;
  background: var(--bg);
}

#main > .qsScreen {
  padding: 0;
}

/* A route change moves focus to the h1 (tabindex -1, never in the Tab order) so a screen reader
   starts there. That focus is programmatic, not a keyboard move to a control: no ring. Every
   interactive control keeps its ring. */
#main[tabindex="-1"]:focus,
#main h1[tabindex="-1"]:focus,
#main h1[tabindex="-1"]:focus-visible {
  outline: none;
}

/* ---------- Route screens with no view of their own yet ---------- */
.qsScreen {
  padding-top: var(--gap);
}

@media (forced-colors: active) {
  .qsHelp,
  .qsLockup,
  .chrome .qsLibChip {
    border: var(--line-w) solid ButtonText;
  }

  /* box-shadow is dropped in forced colors: the current tab keeps a real border. Every tab
     reserves the same width, so marking one does not move the others. */
  .tabbar button {
    border-top: var(--tab-bar-w) solid transparent;
  }

  .tabbar button[aria-current="page"] {
    border-top: var(--tab-bar-w) solid Highlight;
  }

  .tabbar button[aria-current="page"]::before {
    content: none;
  }

  /* The punched-out parts of a filled icon follow the system canvas; the current tab's label is
     underlined too, a cue that is neither color nor the bar alone. */
  .tabbar .ic__cut {
    fill: Canvas;
    stroke: Canvas;
  }

  .tabbar button[aria-current="page"] .tabLabel {
    text-decoration: underline;
  }
}

/* Popovers inside the dark header (the account menu) sit on the card: use the card focus ring. */
.chrome .acctMenu :focus-visible {
  outline-color: var(--focus);
}

/* The first and last tab touch the frame edge: draw the ring inside, focus-w + 1px in (the same
   inset as the lockup and list rows). */
.tabbar button:focus-visible {
  outline-offset: calc(-1 * (var(--focus-w) + 1px));
}

/* Keep the h1 clear of the fixed staff buttons at the top right (2.4.11). */
.qsScreen h1 {
  padding-inline-end: calc(var(--target-min) + 8px);
}

/* Forced colors: the 3 px Highlight ring from tokens.css, restated after the shell's own ring. */
@media (forced-colors: active) {
  :focus-visible,
  .chrome :focus-visible {
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }
}

/* REQ-HOM-6: web header = library logo, name and help only. */
[data-platform="web"] #clock,
[data-platform="web"] .acctWrap { display: none; }
