/* overlays.css — owner B6; B7 is the second writer (spec §8.1). */
/* Linked on every page after session.css (templates/layout.phtml). Two delimited sections: B6's inspector below,
   then B7's palette, shortcut sheet and palette trigger; neither edits the other's section (contract-map C-20).
   B6 selectors live under #inspector, dialog.drawer, .insp-* or body.insp-docked; private tokens are --insp-*.
   Shared primitives declared here for B7: none (B7 styles its own dialogs; `dialog::backdrop` is core app.css). */

/* === Inspector (B6) === */

/* Modal sheet (navigation.md #4): full screen below 880 px, a right-docked sheet of min(44rem, 46vw) from 880 px,
   70vw with the Wide toggle (drawer--wide). The docked follow mode reuses the same geometry, non-modal. */
#inspector {
  --insp-w: 100vw;
  --insp-pad: 1rem;
  position: fixed;
  inset: 0;
  width: var(--insp-w);
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
}
#inspector[open] { display: flex; flex-direction: column; }
@media (min-width: 880px) {
  #inspector {
    --insp-w: min(44rem, 46vw);
    inset: 0 0 0 auto;
    border-left: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
  }
  #inspector.drawer--wide { --insp-w: 70vw; }
}
@media (max-width: 879.98px) {
  #inspector .insp-wide { display: none; }
}

.insp-root { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.insp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: var(--insp-pad) var(--insp-pad) .5rem;
  border-bottom: 1px solid var(--line);
}
.insp-titles { min-width: 0; flex: 1 1 14rem; }
/* Column names are case-sensitive: undo app.css's uppercase h2 and label styles inside the inspector. */
.insp-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--fg);
  text-transform: none;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.insp-identity { margin: .2rem 0 0; font: 13px/1.4 var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }
.insp-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.insp-nav button { min-height: 24px; min-width: 24px; padding: .35rem .7rem; }
.insp-nav button[aria-disabled="true"] { opacity: .55; }
.insp-close { padding: .35rem; }
.insp-edge { margin: .5rem var(--insp-pad) 0; font-size: 13px; color: var(--muted); }
.insp-tabs { display: flex; gap: .25rem; padding: .5rem var(--insp-pad) 0; border-bottom: 1px solid var(--line); }
.insp-tab {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom-color: transparent;
  padding: .4rem 1rem;
}
.insp-tab[aria-selected="true"] { background: var(--panel); border-color: var(--line); color: var(--fg); font-weight: 600; }
.insp-tab[aria-selected="false"] { background: transparent; border-color: transparent; color: var(--fg-soft); }
.insp-callout { margin: .75rem var(--insp-pad) 0; font-size: 13px; }
.insp-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: .75rem var(--insp-pad) var(--insp-pad);
  overflow: auto;
}
.insp-panel[hidden] { display: none; }
.insp-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.insp-size { margin: 0; font-size: 13px; color: var(--muted); }
.insp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.insp-actions button, .insp-actions .btn { min-height: 24px; padding: .35rem .75rem; font-size: 13px; }
.insp-json { display: inline-flex; gap: .15rem; }
.insp-json button[aria-pressed="true"] { background: var(--accent-soft); color: var(--fg); border-color: var(--accent); }
.insp-wrap {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin: 0;
  font-size: 13px;
  color: var(--fg-soft);
  text-transform: none;
  letter-spacing: normal;
}
.insp-reason { flex-basis: 100%; margin: 0; font-size: 12.5px; color: var(--muted); }
.insp-notes:empty { display: none; }
.insp-note { margin: .5rem 0 0; font-size: 13px; color: var(--warn); }
.insp-pending { color: var(--fg-soft); }
.insp-trunc { margin: .75rem 0 0; font-size: 13px; }
/* WCAG 1.4.1 (axe link-in-text-block): the global a is colour-only, so a link in a callout's running text is underlined. */
.insp-trunc a, .insp-callout a { text-decoration: underline; text-underline-offset: .15em; }
.insp-status { margin: .5rem 0 0; font-size: 13px; color: var(--muted); }
.insp-status:empty { display: none; }
.insp-status-error { color: var(--bad); }
.insp-body {
  flex: 1 1 auto;
  min-height: 6rem;
  margin-top: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  overflow: auto;
}
.insp-text {
  margin: 0;
  padding: .75rem;
  font: 13px/1.5 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}
.insp-body.insp-nowrap .insp-text { white-space: pre; overflow-wrap: normal; }
.insp-hex { white-space: pre; overflow-wrap: normal; }
.insp-empty, .insp-hint { margin: .75rem; color: var(--muted); font-style: italic; }
.insp-body > .null-badge { margin: .75rem; }

/* Record tab: a <dl> of the readable columns. */
.insp-record { margin: .25rem 0 0; }
.insp-rec-row { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.insp-rec-name { font-weight: 600; overflow-wrap: anywhere; }
.insp-rec-type { font: 400 12px var(--font-mono); color: var(--muted); }
.insp-rec-key { color: var(--warn); }
.insp-rec-value { margin: .25rem 0 0; }
.insp-rec-text { font: 13px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.insp-rec-size { font-size: 12px; color: var(--muted); }
.insp-rec-inspect { min-height: 24px; padding: .15rem .6rem; font-size: 12.5px; }
.insp-hidden { margin: .75rem 0 0; font-size: 13px; color: var(--muted); }

/* Docked follow mode (D16, last B6 item): non-modal, below the sticky top bar and above the bottom bars; the page
   reserves its width. `.main`'s decorative blur would make it the containing block of this fixed drawer, so it is
   lifted while docked (removing a blur only; the A1 hand-over forbids re-adding one). z-index ≤ 30 (map section 5). */
.insp-follow {
  display: inline-flex;
  flex-basis: 100%;
  align-items: center;
  gap: .3rem;
  margin: 0;
  font-size: 13px;
  color: var(--fg-soft);
  text-transform: none;
  letter-spacing: normal;
}
body.insp-docked { --insp-dock-w: min(44rem, 46vw); }
body.insp-docked.insp-docked-wide { --insp-dock-w: 70vw; }
body.insp-docked .main { backdrop-filter: none; -webkit-backdrop-filter: none; }
body.insp-docked .layout-2col { padding-right: calc(var(--insp-dock-w) + 1rem); }
body.insp-docked .with-drawer { scroll-padding-right: 1rem; }
#inspector[data-nonmodal] {
  top: calc(var(--sticky-top) + 1.3rem);
  bottom: var(--bars-h, 0px);
  right: 0;
  left: auto;
  width: var(--insp-dock-w, min(44rem, 46vw));
  height: auto;
  z-index: 30;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}

@media (forced-colors: active) {
  #inspector { border: 1px solid CanvasText; }
  .insp-tab[aria-selected="true"] { border: 2px solid CanvasText; }
}

/* === Palette, shortcut sheet and palette trigger (B7) === */
/* Selectors stay under #palette, .palette*, #shortcut-sheet, .sheet* or .palette-trigger (C-20). */

.palette-trigger {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 32px;
  padding: .3rem .65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--fg-soft);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.palette-trigger:hover { border-color: var(--accent); color: var(--accent); }
.palette-trigger .icon { width: 14px; height: 14px; }
.palette-trigger-keys { display: inline-flex; gap: .15rem; }
.palette-trigger-keys kbd {
  padding: 0 .3rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 880px) {
  .palette-trigger { padding: .3rem; min-width: 32px; justify-content: center; }
  .palette-trigger-label {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .palette-trigger-keys { display: none; }
}
/* ≤ 480 px the left zone holds brand, nav and trigger in 270 px at 320 px: a 28 px target keeps it inside the bar. */
@media (max-width: 480px) {
  .palette-trigger { min-width: 28px; min-height: 28px; padding: .2rem; }
}

#palette, #shortcut-sheet {
  color: var(--fg);
  background: var(--panel-alt);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0;
}
#palette { width: min(640px, calc(100vw - 2rem)); margin-top: 10vh; }
#palette .palette-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--line);
}
#palette .palette-search .icon { color: var(--muted); flex: none; }
#palette #palette-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  padding: .35rem 0;
}
#palette #palette-list {
  list-style: none;
  margin: 0;
  padding: .3rem 0;
  max-height: min(55vh, 460px);
  overflow-y: auto;
}
#palette #palette-list ul { list-style: none; margin: 0; padding: 0; }
#palette .pal-group {
  padding: .45rem .9rem .2rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
#palette [role="option"] {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .1rem .4rem;
  padding: .4rem .9rem;
  cursor: pointer;
}
/* The active option: a background plus an outline, because focus stays in the combobox (no focus ring on the option)
   and forced-colors mode replaces backgrounds with Canvas (WCAG 2.4.7). */
#palette [role="option"][aria-selected="true"] {
  background: var(--accent-soft);
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
#palette .pal-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
#palette .pal-schema, #palette .pal-note { font-size: 12px; color: var(--muted); }
#palette .pal-locked .pal-name { opacity: .7; }
#palette .pal-lock { color: var(--muted); }
#palette .pal-lock .icon { width: 12px; height: 12px; }
#palette .kind-badge { font-size: 10px; padding: 0 .35rem; }
#palette mark { background: var(--warn-soft); color: var(--fg); border-radius: 2px; }
#palette li.pal-note { padding: .4rem .9rem; }
#palette .palette-more, #palette .palette-footer {
  margin: 0;
  padding: .4rem .9rem;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
#palette .palette-footer kbd { font-size: 11px; }

#shortcut-sheet { width: min(760px, calc(100vw - 2rem)); max-height: calc(100vh - 4rem); overflow-y: auto; }
#shortcut-sheet .sheet-body { padding: .9rem 1.2rem 1.2rem; }
#shortcut-sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
#shortcut-sheet .sheet-head h2 { margin: 0; font-size: 1.1rem; }
#shortcut-sheet .sheet-close { min-width: 32px; min-height: 32px; }
#shortcut-sheet .sheet-toggle { margin: .75rem 0 .25rem; }
#shortcut-sheet .sheet-switch {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .3rem .1rem;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
#shortcut-sheet .sheet-switch-track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  flex: none;
}
#shortcut-sheet .sheet-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .12s ease;
}
#shortcut-sheet .sheet-switch[aria-checked="true"] .sheet-switch-track { background: var(--accent); border-color: var(--accent); }
#shortcut-sheet .sheet-switch[aria-checked="true"] .sheet-switch-track::after { transform: translateX(16px); background: var(--accent-fg); }
#shortcut-sheet .sheet-note { margin: 0 0 .75rem; font-size: 12.5px; color: var(--muted); }
#shortcut-sheet .sheet-group h3 { margin: 1rem 0 .35rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#shortcut-sheet .sheet-keys { width: 100%; border-collapse: collapse; font-size: 13px; }
/* The sheet's row labels are plain cells, not column headers: undo every part of the core th rule (app.css) that would leak in.
   white-space: nowrap would push the chords out of a narrow sheet; position: sticky; top: 0 would pile the labels up at the
   top edge of the scrolling dialog and detach them from their row rules; the panel-alt fill, bottom border, uppercase 11.5px
   letter-spaced type are table-header styling. */
#shortcut-sheet .sheet-keys th {
  position: static; background: none; border-bottom: 0;
  color: inherit; font-size: inherit; text-transform: none; letter-spacing: normal;
  text-align: left; font-weight: 400; padding: .3rem .5rem .3rem 0; white-space: normal;
}
#shortcut-sheet .sheet-keys td { text-align: right; padding: .3rem 0; white-space: nowrap; }
#shortcut-sheet .sheet-keys tr + tr { border-top: 1px solid var(--line); }
/* Nor the core grid's zebra stripes, hover fill and cell borders (app.css `tbody tr`, `th, td`): the rule between rows is
   the sheet's own `tr + tr` line above (B7's ledger, B9). */
#shortcut-sheet .sheet-keys td { border-bottom: 0; }
#shortcut-sheet .sheet-keys tbody tr:nth-child(even), #shortcut-sheet .sheet-keys tbody tr:hover { background: none; }
#shortcut-sheet kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 .35rem;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  background: var(--panel);
}
#shortcut-sheet .sheet-or { font-size: 11px; color: var(--muted); }
@media (forced-colors: active) {
  #palette [role="option"][aria-selected="true"] { outline-color: Highlight; }
  /* The switch's fills and thumb would all collapse to Canvas (WCAG 2.1.4 control with no visible state). */
  #shortcut-sheet .sheet-switch-track, #shortcut-sheet .sheet-switch-track::after { forced-color-adjust: none; }
  #shortcut-sheet .sheet-switch-track { background: Canvas; border-color: CanvasText; }
  #shortcut-sheet .sheet-switch-track::after { background: CanvasText; }
  #shortcut-sheet .sheet-switch[aria-checked="true"] .sheet-switch-track { background: Highlight; border-color: Highlight; }
  #shortcut-sheet .sheet-switch[aria-checked="true"] .sheet-switch-track::after { background: HighlightText; }
}
@media (max-width: 480px) {
  #palette { margin-top: 1rem; }
  #shortcut-sheet .sheet-keys td { white-space: normal; }
}
