/* Quiet Shelf card registration (QS-8): T4a-T4c, T5 / T5n, T5r and the under-13 guidance
   screen. Tokens only (theme/tokens.css). QS-13: the layout of the reference T4a-T5r (progress
   bars over the step line, fields with the label inside the box, the dashed document box, the
   checklist card, the outcome head under a round mark, the last action at the foot). The 16 px
   gutter is the shell's (#main). Inputs are 56+ (standard), the primary action 72. */

.qsCard {
  display: grid;
  align-content: start;
  gap: var(--gap);
  box-sizing: border-box;
}

/* The flow screens fill the main area, so the last action can sit at the foot (the reference .fill). */
.qsCard--flow {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.qsCard h1,
.qsCard__sub,
.qsCard__next {
  margin: 0;
}

.qsCard__sub,
.qsCard__next {
  color: var(--muted);
}

/* An email address or a reference is one long word: it breaks inside the column at 320 px with
   200% text and the WCAG 1.4.12 spacing instead of scrolling the page (1.4.10). */
.qsCard__sub {
  overflow-wrap: anywhere;
}

/* The guidance screen's title: the outcome size (24). */
#main .qsCard--guardian h1 {
  font-size: var(--fs-section);
}

.qsCard > .qsBtn,
.qsCard__form > .qsBtn {
  width: 100%;
}

/* ---------- Steps: the bars, then the step line (the h1, styled as the reference .eb) ---------- */
#main .qsCard h1.qsCard__step {
  order: 1;
  margin: 0;
  padding-inline-end: 0;
  color: var(--muted);
  font-family: var(--font-head);
  font-size: var(--fs-eyebrow);
  font-weight: var(--weight-head);
  letter-spacing: var(--ls-eyebrow);
  line-height: var(--lh-head);
  text-transform: uppercase;
}

.qsCard--flow > * {
  order: 2;
}

.qsCard--flow > .qsCardSteps {
  order: 0;
}

.qsCardSteps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qsCardSteps__item {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--line);
}

.qsCardSteps__item--done,
.qsCardSteps__item--on {
  background: var(--primary);
}

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

/* ---------- Fields (the reference .field): the label inside the box, over the value ----------
   The box is the field wrapper; the label (and the date hint, at the end of the label line) is a
   real row above the borderless input, so a label that wraps (narrow screens, translations, text
   spacing) pushes the value down and never covers it (1.4.10, 1.4.12). */
.qsCard__form {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gap);
}

.qsCardField {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  box-sizing: border-box;
  padding: 9px 0 3px;
  border: var(--line-w) solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--card);
}

.qsCardField:focus-within {
  border-color: var(--primary);
}

.qsCardField__label {
  grid-column: 1;
  grid-row: 1;
  padding: 0 0 0 17px;
  color: var(--muted);
  font-weight: var(--weight-action);
  letter-spacing: 0.04em;
  line-height: var(--lh-head);
  text-transform: uppercase;
}

.qsCardField__hint {
  margin: 0;
  color: var(--muted);
}

.qsCardField > .qsCardField__hint {
  grid-column: 2;
  grid-row: 1;
  padding: 0 17px 0 8px;
  line-height: var(--lh-head);
}

.qsCardField__input {
  grid-column: 1 / 3;
  grid-row: 2;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: var(--target-min);
  margin: 0;
  padding: 0 17px;
  border: 0;
  border-radius: var(--r-card);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--weight-action);
  line-height: var(--lh-head);
}

/* The ring is on the input itself, drawn inside the box. */
.qsCardField__input:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: calc(-1 * var(--focus-w));
}

/* The select draws its own caret (an edge triangle in --muted, no image). */
.qsCardField--select .qsCardField__input {
  appearance: none;
  padding-right: 44px;
  text-overflow: ellipsis;
}

.qsCardField--select::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 25px;
  border-top: 6px solid var(--muted);
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  pointer-events: none;
}

/* Invalid: the box edge turns --danger and three times wider (not color alone; the width stays
   visible in forced colors). */
.qsCardField:has(.qsCardField__input[aria-invalid="true"]) {
  border-color: var(--danger);
  border-width: calc(var(--line-w) * 3);
}

.qsCard__req {
  margin: 0;
  color: var(--muted);
}

.qsCard__err {
  margin: 0;
  color: var(--danger);
  font-weight: var(--weight-action);
}

.qsCard__err:empty {
  display: none;
}

/* The last action of a flow screen sits at the foot. */
.qsCard__foot,
.qsCard__privacy.qsCard__foot {
  margin-top: auto;
}

/* ---------- Proof of address: the dashed document box ---------- */
.qsCard__doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 23px 8px 24px;
  border: var(--line-w) dashed var(--line-strong);
  border-radius: var(--r-card);
  background: var(--card);
  text-align: center;
}

.qsCard__shoot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: var(--target-min);
  min-height: var(--target-min);
  padding: 8px 16px;
  border: 0;
  border-radius: var(--r-card);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--weight-head);
  cursor: pointer;
}

.qsCard__shoot .ic {
  width: 40px;
  height: 40px;
  color: var(--muted);
}

/* A control that reads as a text link (the reference .link): underlined --primary. */
.qsCard__link {
  align-self: center;
  min-width: var(--target-min);
  min-height: var(--target-min);
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-family: var(--font-body);
  font-size: var(--fs-action);
  font-weight: var(--weight-action);
  text-align: center;
  text-decoration: underline;
  cursor: pointer;
}

.qsCard__doc .qsCard__link {
  font-size: var(--fs-body);
}

.qsCard__shoot:focus-visible,
.qsCard__link:focus-visible {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--focus-offset);
}

.qsCard__preview img {
  display: block;
  max-width: 100%;
  max-height: 40vh;
  border: var(--line-w) solid var(--line-strong);
  border-radius: var(--r-card);
}

.qsCard__file {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* ---------- Checking: the checklist card ---------- */
.qsVsteps {
  margin: 0;
  padding: 4px 17px;
  list-style: none;
  background: var(--card);
  border: var(--line-w) solid var(--line);
  border-radius: var(--r-card);
}

.qsVstep {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--target-min);
  padding: 8px 0;
  color: var(--fg);
}

.qsVstep + .qsVstep {
  border-top: var(--line-w) solid var(--line);
}

.qsVstep__icon {
  display: flex;
  color: var(--primary);
}

.qsVstep__check {
  display: none;
}

/* runCardPipeline adds .done as each step completes: the row's icon becomes a check. */
.qsVstep.done .qsVstep__icon {
  color: var(--success);
}

.qsVstep.done .qsVstep__icon .ic {
  display: none;
}

.qsVstep.done .qsVstep__icon .qsVstep__check {
  display: block;
}

.qsVstep__label {
  flex: 1;
}

.qsCard__privacy {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

/* ---------- Outcomes (the reference .ok-big) ---------- */
.qsCard__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  padding: 14px 0 4px;
  text-align: center;
}

#main .qsCard__head h1 {
  padding-inline-end: 0;
  font-size: var(--fs-section);
}

.qsCard__mark {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border-radius: var(--r-pill);
  background: var(--acc-events-wash);
  color: var(--success);
}

.qsCard__mark .ic {
  width: 46px;
  height: 46px;
}

.qsCard__mark--wait {
  background: var(--acc-way-wash);
  color: var(--acc-way);
}

.qsCard__hours .qsSheet__text,
.qsCard__hours .qsStaff__h {
  margin-left: 0;
  margin-right: 0;
}

/* The digital card (DESIGN.md section 5; the reference .dcard): the chrome to primary gradient,
   as on M1 (me.css .qsCard--digital); the code on its own white panel. */
.qsCardDc {
  display: grid;
  gap: 4px;
  padding: 17px;
  border-radius: var(--r-bar);
  background: linear-gradient(135deg, var(--chrome), var(--primary));
  color: var(--on-chrome);
}

/* Dark: the gradient end is too light for white text; the card stays on chrome. */
:root[data-theme="dark"] .qsCardDc {
  background: var(--chrome);
  border: var(--line-w) solid var(--line-strong);
}

/* System dark (no data-theme): the same, as me.css does for the M1 card. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .qsCardDc {
    background: var(--chrome);
    border: var(--line-w) solid var(--line-strong);
  }
}

.qsCardDc__name {
  margin: 0;
  font-family: var(--font-head);
  font-weight: var(--weight-head);
}

.qsCardDc__lib {
  margin: 0;
}

.qsCardDc__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--gap);
  margin-top: 8px;
}

.qsCardDc__code {
  width: 96px;
  padding: 6px;
  border-radius: var(--r-card);
  background: var(--on-chrome);
}

.qsCardDc__code--bars {
  width: 100%;
}
.qsCardDc__bars {
  display: block;
  width: 100%;
  height: 56px;
}
.qsCardDc__bars rect {
  fill: var(--chrome);
}

.qsCardDc__num {
  margin: 0;
  letter-spacing: var(--ls-eyebrow);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Continue waits for a document: say so visually as well as in the aria-disabled state (not
   native disabled, so a press still reaches the error that says what to do). */
.qsCard .qsBtn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (forced-colors: active) {
  .qsCardDc,
  .qsVsteps,
  .qsCard__doc {
    border: var(--line-w) solid CanvasText;
  }

  .qsCardSteps__item {
    border: var(--line-w) solid CanvasText;
  }

  /* Color only: an invalid field keeps its three-times-wider edge. */
  .qsCardField {
    border-color: CanvasText;
  }

  .qsCardSteps__item--done,
  .qsCardSteps__item--on {
    forced-color-adjust: none;
    background: Highlight;
  }

  .qsCard .qsBtn[aria-disabled="true"] {
    opacity: 1;
    color: GrayText;
    border-color: GrayText;
  }
}
