/* ==================================================================== *
 * Quercia viva — the help centre and its drawer
 *
 * The help used to be a framework alert pinned above eleven lists, each
 * carrying a stock illustration in colours the token layer has no say
 * over — so it was the one part of the product that looked the same in
 * both themes because it belonged to neither.
 *
 * Two surfaces here:
 *   .qc-help*         the centre at /help, laid out on the settings hub's
 *                     two-pane shell (components.css §Settings hub) — the
 *                     same shape, so only what differs is written down
 *   .qc-help-drawer*  the panel the `?` in a page header opens
 *
 * Prose is the one thing the brand had no recipe for; §3's scale and the
 * text tokens do the work, and nothing here invents a colour.
 * ==================================================================== */

/* ------------------------------------------------------------------ *
 * The centre
 * ------------------------------------------------------------------ */

/* The index has no rail beside it — a table of contents does not need a table
   of contents — so the pane takes the whole width and the cards get a column
   more to fit in. */
.qc-help--wide { grid-template-columns: minmax(0, 1fr); }

/* Family headings in the rail. They step aside below lg, where the rail
   is one scrolling row and a heading would break the line. */
.qc-help__railgroup {
  margin: .75rem .75rem .25rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--qc-text-tertiary);
}
.qc-help__rail .qc-help__railgroup:first-child { margin-top: .25rem; }

/* The hero: the topic's mark, and the line saying what it is for. The name is
   not repeated here — the page header above carries it. */
.qc-help__intro {
  display: flex;
  align-items: center;
  gap: .875rem;
}
.qc-help__intro .qc-shell__lede { margin: 0; }
.qc-help__introicon {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--qc-radius-btn);
  color: var(--qc-primary);
  background: color-mix(in srgb, var(--qc-primary) 12%, transparent);
}

.qc-help__family { margin-bottom: 1.75rem; }
.qc-help__familytitle {
  font-family: var(--qc-font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 .625rem;
  color: var(--qc-text-secondary);
}

.qc-help__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: .625rem;
}

/* The index card. The same border, radius and surface as .qc-form__option
   in forms.css — that one is a <label> wrapped round a radio, this one is
   a link, and the two would fight over :has(input:checked). */
.qc-help__card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1rem;
  border: 1px solid var(--qc-border);
  border-radius: var(--qc-radius-card);
  background: var(--qc-surface-light);
  color: var(--qc-text-primary);
  text-decoration: none;
  transition: border-color var(--qc-dur-standard) var(--qc-ease-standard),
              background-color var(--qc-dur-standard) var(--qc-ease-standard);
}
.qc-help__card:hover {
  border-color: var(--qc-primary);
  color: var(--qc-text-primary);
}
.qc-help__cardicon {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--qc-radius-btn);
  color: var(--qc-primary);
  background: color-mix(in srgb, var(--qc-primary) 10%, transparent);
}
.qc-help__cardtext { min-width: 0; }
.qc-help__cardname { display: block; font-weight: 600; }
.qc-help__cardlede {
  display: block;
  font-size: .875rem;
  color: var(--qc-text-secondary);
}
.qc-help__cardarrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--qc-text-tertiary);
  transition: transform var(--qc-dur-fast) var(--qc-ease-fast);
}
.qc-help__card:hover .qc-help__cardarrow {
  transform: translateX(3px);
  color: var(--qc-primary);
}

/* ------------------------------------------------------------------ *
 * The prose itself — shared by the page and the drawer
 * ------------------------------------------------------------------ */
.qc-help__body { color: var(--qc-text-primary); }
.qc-help__body > :first-child { margin-top: 0; }
.qc-help__body > :last-child { margin-bottom: 0; }
.qc-help__body p { margin-bottom: .875rem; line-height: 1.6; }
.qc-help__body a { color: var(--qc-primary); }

/* A line of prose gets a measure. Sixty-odd characters is where the eye stops
   losing the start of the next line, and the pane is far wider than that on a
   desk — the same reason .qc-form holds its own width (docs/brand §3).
   The figures are exempt: a chain of steps is read across, not along. */
.qc-help__body p,
.qc-help__body .qc-help__h,
.qc-help__body .qc-help__terms,
.qc-help__body .qc-help__legend,
.qc-help__body .qc-help__timeline,
.qc-help__body .qc-help__aside,
.qc-help__body .alert { max-width: 66ch; }

/* And the mock is a specimen, not the table itself: at full width it stops
   reading as an illustration and starts reading as the real grid. */
.qc-help__mock { max-width: 44rem; }

/* A heading inside a topic. Bricolage like every other title, but small: it
   divides a page, it does not open one. */
.qc-help__h {
  font-family: var(--qc-font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 .5rem;
  color: var(--qc-text-primary);
}
.qc-help__body > .qc-help__h:first-child { margin-top: 0; }

/* Where a status leads next, as the chips the work list already uses. */
.qc-help__next {
  display: block;
  margin-top: .375rem;
  font-size: .8125rem;
  color: var(--qc-text-tertiary);
}
.qc-help__next .qc-statuschip {
  margin-left: .25rem;
  font-size: .75rem;
}

/* A term and what it means. The old notes ran these together as
   <b>Label</b>: text<br/>, which reads as a paragraph and scans as
   nothing. */
.qc-help__terms { margin: 0 0 1rem; }
.qc-help__terms dt {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  color: var(--qc-text-primary);
}
.qc-help__terms dt:not(:first-child) { margin-top: .875rem; }
.qc-help__terms dd {
  margin: .125rem 0 0;
  color: var(--qc-text-secondary);
  line-height: 1.6;
}
.qc-help__terms--icons dd { padding-left: 2rem; }
.qc-help__termicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
}
.qc-help__termicon .icon { width: 20px; height: 20px; }
.qc-help__termicon i { font-size: 1.125rem; color: var(--qc-text-secondary); }

/* A legend: one line per mark the table can show. */
.qc-help__legend {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.qc-help__legend li {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .375rem 0;
  color: var(--qc-text-secondary);
}
.qc-help__legendicon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--qc-radius-btn);
  color: var(--qc-primary);
  background: color-mix(in srgb, var(--qc-primary) 10%, transparent);
}

/* An afterthought that is still part of the answer — dimmed by token, never
   by opacity (brand §2.2). Prose: a sentence with a link in it has to wrap
   as a sentence, so this is a block — a flex row would split it into columns
   around the <a>. */
.qc-help__aside {
  display: block;
  margin: 1rem 0 0;
  padding-top: .875rem;
  border-top: 1px solid var(--qc-divider);
  font-size: .875rem;
  line-height: 1.6;
  color: var(--qc-text-secondary);
}

/* ------------------------------------------------------------------ *
 * The drawer
 * ------------------------------------------------------------------ */
.qc-help-drawer {
  position: fixed;
  inset: 0;
  z-index: 1055;             /* over the sidebar, under Bootstrap's modals */
}
.qc-help-drawer[hidden] { display: none; }

.qc-help-drawer__scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--qc-text-primary) 32%, transparent);
  opacity: 0;
  transition: opacity var(--qc-dur-standard) var(--qc-ease-standard);
}
.qc-help-drawer.is-open .qc-help-drawer__scrim { opacity: 1; }

.qc-help-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(26rem, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--qc-card-bg);
  border-left: 1px solid var(--qc-border);
  box-shadow: var(--qc-shadow-lg);
  transform: translateX(100%);
  transition: transform var(--qc-dur-standard) var(--qc-ease-standard);
}
.qc-help-drawer.is-open .qc-help-drawer__panel { transform: translateX(0); }
.qc-help-drawer__panel:focus { outline: none; }

.qc-help-drawer__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--qc-divider);
}
.qc-help-drawer__title {
  font-family: var(--qc-font-display);
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 0;
  flex: 1 1 auto;
}

.qc-help-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem;
}

/* The way out of the drawer and into the centre: the drawer answers this
   page's question, the centre holds the rest. */
.qc-help__more {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  margin-top: 1.25rem;
  padding-top: .875rem;
  border-top: 1px solid var(--qc-divider);
  width: 100%;
  color: var(--qc-primary);
  font-weight: 600;
  font-size: .875rem;
  text-decoration: none;
}
.qc-help__more:hover { color: var(--qc-primary-dark); }

/* The page behind the drawer does not scroll under it. */
body.qc-help-drawer-open { overflow: hidden; }

@media (max-width: 575.98px) {
  /* On a phone the panel is the page: a 26rem sheet squeezed into 24rem of
     viewport is a drawer that has forgotten what it is for. */
  .qc-help-drawer__panel {
    width: 100vw;
    border-left: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qc-help-drawer__scrim,
  .qc-help-drawer__panel,
  .qc-help__cardarrow,
  .qc-help__card {
    transition: none;
  }
  .qc-help__card:hover .qc-help__cardarrow { transform: none; }
}

/* ------------------------------------------------------------------ *
 * Figures
 *
 * Four shapes, drawn in markup and coloured by token rather than saved
 * as pictures: they follow the theme, their labels come out of the
 * catalogs like every other string, and nobody has to remember to
 * redraw them when a screen changes.
 * ------------------------------------------------------------------ */

/* The prose area is the container the figures adapt to. The same topic is
   read on a wide page and in a 26rem drawer, and a viewport query cannot
   tell the two apart: the drawer sits in a wide window and never reached
   the phone breakpoint, so its steps stayed side by side in slivers. */
.qc-help__body { container-type: inline-size; }

/* A chain of steps. Left to right where there is room, top to bottom in
   the drawer and on a phone — the connector swings with it. A step needs
   room for a heading and a sentence: never narrower than 15rem, so six
   steps on a wide page make two rows rather than six slivers. */
.qc-help__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: .75rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  counter-reset: qc-help-step;
}
.qc-help__step {
  position: relative;
  padding: .875rem;
  border: 1px solid var(--qc-border);
  border-radius: var(--qc-radius-card);
  background: var(--qc-surface-light);
}
/* The arrow between one step and the next, drawn on the gap. */
.qc-help__step + .qc-help__step::before {
  content: "";
  position: absolute;
  left: -.625rem;
  top: 50%;
  width: .5rem;
  height: .5rem;
  border-top: 1.5px solid var(--qc-border);
  border-right: 1.5px solid var(--qc-border);
  transform: translateY(-50%) rotate(45deg);
}
.qc-help__stepnum {
  counter-increment: qc-help-step;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: .5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--qc-primary) 14%, transparent);
  color: var(--qc-primary);
  font-size: .8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.qc-help__stepnum::before { content: counter(qc-help-step); }
.qc-help__stephead { display: block; font-weight: 600; margin-bottom: .125rem; }
.qc-help__steptext { display: block; font-size: .875rem; color: var(--qc-text-secondary); }

/* Where the steps stack — a narrow container (the drawer) or a phone — the
   arrow points down instead. Both rules, on purpose: the container query is
   what the drawer needs, the viewport query is what an old browser gets. */
@container (max-width: 34rem) {
  .qc-help__steps { grid-template-columns: minmax(0, 1fr); }
  .qc-help__step + .qc-help__step::before {
    left: 1.25rem;
    top: -.625rem;
    transform: rotate(135deg);
  }
}
@media (max-width: 575.98px) {
  .qc-help__steps { grid-template-columns: minmax(0, 1fr); }
  .qc-help__step + .qc-help__step::before {
    left: 1.25rem;
    top: -.625rem;
    transform: rotate(135deg);
  }
}

/* A table, drawn small, so a column can be pointed at by name. */
.qc-help__mock {
  margin: 0 0 1.25rem;
  border: 1px solid var(--qc-border);
  border-radius: var(--qc-radius-card);
  background: var(--qc-surface-light);
  overflow-x: auto;
}
.qc-help__mock table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}
.qc-help__mock th {
  padding: .5rem .75rem;
  text-align: left;
  font-weight: 600;
  color: var(--qc-text-primary);
  border-bottom: 1px solid var(--qc-divider);
  white-space: nowrap;
}
.qc-help__mock td {
  padding: .5rem .75rem;
  color: var(--qc-text-secondary);
  border-bottom: 1px solid var(--qc-divider);
  white-space: nowrap;
}
.qc-help__mock tr:last-child td { border-bottom: none; }
.qc-help__mock .qc-numeric { font-variant-numeric: tabular-nums; }
.qc-help__mockcap {
  padding: .5rem .75rem;
  font-size: .8125rem;
  color: var(--qc-text-tertiary);
  border-top: 1px solid var(--qc-divider);
}

/* What happens, and when. A rail down the left with a dot per moment. */
.qc-help__timeline {
  margin: 0 0 1.25rem;
  padding: 0 0 0 1.25rem;
  list-style: none;
  border-left: 2px solid var(--qc-divider);
}
.qc-help__moment { position: relative; padding-bottom: 1rem; }
.qc-help__moment:last-child { padding-bottom: 0; }
.qc-help__moment::before {
  content: "";
  position: absolute;
  left: calc(-1.25rem - 5px);
  top: .35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--qc-primary);
}
.qc-help__momentwhen {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--qc-text-tertiary);
}
.qc-help__momenttext { display: block; color: var(--qc-text-secondary); }
