/* ==========================================================================
   DSC setup — the public /dsc/setup page (dsc/setup.html) and the shared
   stepper (dsc/_stepper.html, layouts "page" and "card"). Prefix dss-.
   States come from js/dsc-setup-status.js (initStepper): data-state on each
   .dss-step (checking | todo | current | done | warn | fail | skip), data-open
   on the steps whose body shows. Tokens only (DESIGN_SYSTEM §2); motion §2.5:
   the open step grows with --ds-dur-slow, a live tick flashes once.
   ========================================================================== */

/* Anything the script hides stays hidden, whatever display its class sets. */
.dss [hidden] { display: none !important; }

/* ── Page ─────────────────────────────────────────────────────────────── */
.dss-hero { padding: var(--ds-space-12) 0 var(--ds-space-10); background: var(--ds-surface-alt); border-bottom: 1px solid var(--ds-border); }
.dss-hero__inner { max-width: var(--ds-container-narrow); }
.dss-hero__title { margin: var(--ds-space-4) 0 0; font-size: var(--ds-text-3xl); font-weight: var(--ds-weight-medium); line-height: var(--ds-leading-tight); letter-spacing: var(--ds-tracking-tight); color: var(--ds-ink); }
.dss-hero__lead { margin: var(--ds-space-3) 0 0; max-width: 60ch; font-size: var(--ds-text-lg); line-height: var(--ds-leading-body); color: var(--ds-muted); }

.dss-main { padding: var(--ds-space-10) 0 var(--ds-space-16); }
.dss-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--ds-space-8); align-items: start; }
.dss-card { overflow: hidden; }

.dss-rail { display: grid; gap: var(--ds-space-4); }
.dss-rail__card { overflow: hidden; }
.dss-rail__head { margin: 0; padding: var(--ds-space-3) var(--ds-space-5); background: var(--ds-surface-alt); border-bottom: 1px solid var(--ds-border-soft); font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium); color: var(--ds-ink); }
.dss-rail__list { list-style: none; margin: 0; padding: var(--ds-space-4) var(--ds-space-5); display: grid; gap: var(--ds-space-3); font-size: var(--ds-text-sm); color: var(--ds-text); }
.dss-rail__list li { display: flex; gap: var(--ds-space-2); align-items: flex-start; }
.dss-rail__list .ds-icon { flex: none; margin-top: 2px; color: var(--ds-primary); }
.dss-rail__text { margin: 0; padding: var(--ds-space-4) var(--ds-space-5); font-size: var(--ds-text-sm); line-height: var(--ds-leading-body); color: var(--ds-muted); }
.dss-rail__links { display: flex; flex-wrap: wrap; gap: var(--ds-space-2) var(--ds-space-5); margin: var(--ds-space-1) 0 0; padding-inline: var(--ds-space-1); font-size: var(--ds-text-sm); }
.dss-rail__links .ds-link { font-weight: var(--ds-weight-medium); }

/* ── Stepper ──────────────────────────────────────────────────────────── */
.dss { --dss-pad: var(--ds-space-6); --dss-mark: 28px; color: var(--ds-text); }
.dss-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ds-space-4); padding: var(--ds-space-5) var(--dss-pad); border-bottom: 1px solid var(--ds-border-soft); }
.dss-head__title { margin: 0; font-size: var(--ds-text-lg); font-weight: var(--ds-weight-medium); color: var(--ds-ink); }
.dss-head__sum { margin: 2px 0 0; font-size: var(--ds-text-sm); color: var(--ds-subtle); font-variant-numeric: tabular-nums; }
.dss-recheck { flex: none; }

.dss-steps { list-style: none; margin: 0; padding: var(--ds-space-2) 0; }
.dss-step { position: relative; padding: var(--ds-space-4) var(--dss-pad); transition: background-color var(--ds-dur-fast) var(--ds-ease); }
.dss-step[data-state="current"], .dss-step[data-state="fail"] { background: var(--ds-primary-soft); }
/* The line joining one mark to the next; green once the step above is done. */
.dss-step:not(:last-child)::before {
  content: ""; position: absolute; left: calc(var(--dss-pad) + var(--dss-mark) / 2 - 1px);
  top: calc(var(--ds-space-4) + var(--dss-mark) + 4px); bottom: calc(4px - var(--ds-space-4));
  width: 2px; background: var(--ds-border-soft);
}
.dss-step[data-state="done"]:not(:last-child)::before { background: var(--ds-success); }

.dss-step__head { display: flex; align-items: flex-start; gap: var(--ds-space-3); border-radius: var(--ds-radius); }
.dss-step__text { min-width: 0; flex: 1; padding-top: 2px; }
.dss-step__title { margin: 0; font-size: var(--ds-text-base); font-weight: var(--ds-weight-medium); line-height: var(--ds-leading-snug); color: var(--ds-ink); }
.dss-step__status { margin: 2px 0 0; min-height: 1.4em; font-size: var(--ds-text-sm); line-height: 1.4; color: var(--ds-muted); }
.dss-step[data-state="todo"] .dss-step__title { color: var(--ds-subtle); font-weight: var(--ds-weight-regular); }
.dss-step[data-state="todo"] .dss-step__status { display: none; }
.dss-step[data-state="todo"] .dss-step__text { padding-top: 4px; }
.dss-sk { display: inline-block; width: 128px; height: 10px; vertical-align: middle; }

/* Mark: number, tick or warning, by state. */
.dss-mark {
  flex: none; display: grid; place-items: center; width: var(--dss-mark); height: var(--dss-mark); border-radius: 50%;
  border: 1.5px solid var(--ds-border-strong); background: var(--ds-surface); color: var(--ds-subtle);
  font-size: var(--ds-text-xs); font-weight: var(--ds-weight-medium); font-variant-numeric: tabular-nums;
  transition: background-color var(--ds-dur-fast) var(--ds-ease), border-color var(--ds-dur-fast) var(--ds-ease), color var(--ds-dur-fast) var(--ds-ease);
}
.dss-mark > * { grid-area: 1 / 1; }
.dss-mark__ok, .dss-mark__warn { display: none; }
.dss-step[data-state="current"] .dss-mark { border-color: var(--ds-primary); color: var(--ds-primary); background: var(--ds-surface); }
.dss-step[data-state="done"] .dss-mark { border-color: var(--ds-success); background: var(--ds-success); color: var(--ds-on-primary); }
.dss-step[data-state="warn"] .dss-mark { border-color: var(--ds-warning); background: var(--ds-warning-bg); color: var(--ds-warning-text); }
.dss-step[data-state="fail"] .dss-mark { border-color: var(--ds-danger); background: var(--ds-danger-bg); color: var(--ds-danger-text); }
.dss-step[data-state="skip"] .dss-mark { background: var(--ds-neutral-bg); color: var(--ds-neutral-text); }
.dss-step[data-state="done"] .dss-mark__ok,
.dss-step:is([data-state="warn"], [data-state="fail"]) .dss-mark__warn { display: block; }
.dss-step:is([data-state="done"], [data-state="warn"], [data-state="fail"]) .dss-mark__n { display: none; }

/* Body: only the open step shows it; it grows into place (layout motion), and
   once shut it is hidden too (after the collapse), not just clipped. */
.dss-step__body {
  display: grid; grid-template-rows: 0fr; visibility: hidden; margin-left: calc(var(--dss-mark) + var(--ds-space-3));
  /* visibility interpolates as "visible" while either end is: shown at once on open, hidden at the end on close */
  transition: grid-template-rows var(--ds-dur-slow) var(--ds-ease), visibility var(--ds-dur-slow);
}
.dss-step[data-open] .dss-step__body { grid-template-rows: 1fr; visibility: visible; }
.dss-step__inner { min-height: 0; overflow: hidden; }
/* Gap under the status line (a pseudo-element: the first child may be a hidden face). */
.dss-step__inner::before { content: ""; display: block; height: var(--ds-space-3); }
.dss-step__inner > :last-child { margin-bottom: var(--ds-space-1); }

.dss-text, .dss-why, .dss-note, .dss-sub { margin: 0 0 var(--ds-space-2); font-size: var(--ds-text-sm); line-height: var(--ds-leading-body); }
.dss-text { color: var(--ds-text); }
.dss-why { color: var(--ds-muted); }
.dss-note { color: var(--ds-subtle); }
.dss-sub { color: var(--ds-muted); }
.dss-note b, .dss-text b, .dss-more b { font-weight: var(--ds-weight-medium); color: var(--ds-text); }
.dss-note code { font-family: var(--ds-font-mono); font-size: var(--ds-text-xs); }
.dss-note .ds-act { margin-left: var(--ds-space-1); }

.dss-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-3) var(--ds-space-4); margin: var(--ds-space-1) 0 var(--ds-space-3); }
.dss-os__others { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: var(--ds-space-1) var(--ds-space-3); font-size: var(--ds-text-sm); color: var(--ds-subtle); }
.dss-os__link { font-weight: var(--ds-weight-medium); }

.dss-drivers { list-style: none; margin: 0 0 var(--ds-space-3); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--ds-space-2) var(--ds-space-4); font-size: var(--ds-text-sm); }
.dss-drivers .ds-link { font-weight: var(--ds-weight-medium); }

.dss-more { margin: 0 0 var(--ds-space-2); font-size: var(--ds-text-sm); }
.dss-more summary { display: inline-flex; align-items: center; gap: var(--ds-space-1); color: var(--ds-primary); font-weight: var(--ds-weight-medium); cursor: pointer; list-style: none; border-radius: var(--ds-radius-sm); }
.dss-more summary::-webkit-details-marker { display: none; }
.dss-more summary:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.dss-more p { margin: var(--ds-space-2) 0 0; color: var(--ds-muted); line-height: var(--ds-leading-body); }

/* Test my token */
.dss-test__spin { display: none; }
[data-dss-test][aria-busy] .dss-test__spin { display: inline-block; animation: ds-spin var(--ds-dur-spin) linear infinite; }
.dss-certs { list-style: none; margin: 0 0 var(--ds-space-3); padding: 0; display: grid; gap: var(--ds-space-2); }
.dss-cert { display: grid; gap: 2px; padding: var(--ds-space-3) var(--ds-space-4); background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius); min-width: 0; }
.dss-cert__name { font-size: var(--ds-text-sm); font-weight: var(--ds-weight-medium); color: var(--ds-ink); overflow-wrap: anywhere; }
.dss-cert__issuer { font-size: var(--ds-text-sm); color: var(--ds-muted); overflow-wrap: anywhere; }
.dss-cert__exp { font-size: var(--ds-text-sm); }

/* Done */
.dss-final {
  display: flex; align-items: center; gap: var(--ds-space-4); flex-wrap: wrap;
  margin: var(--ds-space-2) var(--dss-pad) var(--ds-space-6); padding: var(--ds-space-4) var(--ds-space-5);
  background: var(--ds-success-bg); border: 1px solid var(--ds-success); border-radius: var(--ds-radius-lg);
}
.dss-final__mark { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ds-accent); color: var(--ds-on-primary); }
.dss-final__text { flex: 1; min-width: 12rem; }
.dss-final__title { margin: 0; font-size: var(--ds-text-base); font-weight: var(--ds-weight-medium); color: var(--ds-success-text); }
.dss-final__sub { margin: 2px 0 0; font-size: var(--ds-text-sm); color: var(--ds-text); }
.dss-final__go { flex: none; }

/* ── Card layout (signing page right panel) ───────────────────────────── */
.dss--card { --dss-pad: 0px; --dss-mark: 22px; }
.dss--card .dss-head { padding: 0 0 var(--ds-space-3); }
.dss--card .dss-head__title { font-size: var(--ds-text-sm); }
.dss--card .dss-head__sum { font-size: var(--ds-text-xs); }
.dss--card .dss-steps { padding: var(--ds-space-1) 0 0; }
.dss--card .dss-step { padding-block: var(--ds-space-3); }
.dss--card .dss-step[data-state="current"], .dss--card .dss-step[data-state="fail"] { background: none; }
.dss--card .dss-step:not(:last-child)::before { top: calc(var(--ds-space-3) + var(--dss-mark) + 4px); bottom: calc(4px - var(--ds-space-3)); }
.dss--card .dss-step__title { font-size: var(--ds-text-sm); }
.dss--card .dss-step__status { font-size: var(--ds-text-xs); }
.dss--card .dss-mark { font-size: var(--ds-text-xs); }
.dss--card .dss-why { display: none; }
.dss--card .dss-drivers { grid-template-columns: 1fr; }
.dss--card .dss-final { margin: var(--ds-space-2) 0 0; padding: var(--ds-space-3); gap: var(--ds-space-3); }
.dss--card .dss-final__mark { width: 28px; height: 28px; }
.dss--card .dss-final__go { width: 100%; justify-content: center; }

/* ── Narrow ───────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .dss-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .dss-hero { padding: var(--ds-space-8) 0 var(--ds-space-6); }
  .dss-hero__lead { font-size: var(--ds-text-base); }
  .dss-main { padding: var(--ds-space-6) 0 var(--ds-space-12); }
  .dss--page { --dss-pad: var(--ds-space-4); }
  .dss-head { flex-wrap: wrap; }
  .dss-final__go { width: 100%; justify-content: center; }
}
