/* ═══════════════════════════════════════════════════════════════════
   components.css — reusable pieces: buttons, chips, segmented controls,
   toggles, cards, banners, toasts, modals, drawer, upload zone, tags.
   Nothing here knows about the wizard or the review surface.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }
.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost {
  background: none;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn.ghost:hover { background: var(--bg-sunken); border-color: transparent; color: var(--text); }

.btn.back {
  background: none;
  border-color: transparent;
  color: var(--text-muted);
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
}
.btn.back:hover { color: var(--text); border-color: transparent; }

.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-light); border-color: var(--red); }

.btn.export { background: var(--green); border-color: var(--green); color: #fff; }
.btn.export:hover { background: var(--green-hover); border-color: var(--green-hover); }

.btn.prompt { background: var(--violet); border-color: var(--violet); color: #fff; }

.btn-sm {
  min-height: 34px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
}
.btn-sm svg { width: 14px; height: 14px; }

.btn-block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.btn-row.center { justify-content: center; }

/* Icon-only button — needs an aria-label, hence the reminder selector */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-sunken); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.danger:hover { background: var(--red-light); color: var(--red); }

/* ── Chips — single and multi select ─────────────────────────────────
   Canonical selected state is .selected (aria-pressed mirrors it for AT).
   .multi-selected is kept as an alias of the previous wizard's markup.
   ──────────────────────────────────────────────────────────────────── */
.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.chip.selected,
.chip.multi-selected,
.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}
.chip.selected:hover,
.chip.multi-selected:hover,
.chip[aria-pressed="true"]:hover { background: var(--accent-hover); color: var(--text-on-accent); }

/* Multi-select chips earn a tick so the interaction model is legible. */
.choice-chips[data-multi="true"] .chip.selected::after,
.choice-chips[data-multi="true"] .chip[aria-pressed="true"]::after,
.chip.multi-selected::after {
  content: '✓';
  font-size: var(--fs-xs);
  opacity: 0.85;
}
.choice-chips[data-multi="true"]::before {
  content: 'Pick as many as apply';
  flex-basis: 100%;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}

/* A prefilled answer is a claim about the user's CV — mark it visibly. */
.chip.prefilled { box-shadow: 0 0 0 2px var(--green); }

/* ── Segmented control — 2-4 mutually exclusive options ──────────── */
.segmented {
  display: flex;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.segmented > * {
  flex: 1;
  min-height: 38px;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.segmented > .selected,
.segmented > [aria-pressed="true"],
.segmented > [aria-checked="true"] {
  background: var(--card);
  color: var(--accent);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
}
/* 4 segments do not fit a narrow phone in one row — stack them. */
@media (max-width: 419px) {
  .segmented.wrap { flex-wrap: wrap; border-radius: var(--r-md); }
  .segmented.wrap > * { flex-basis: calc(50% - 4px); border-radius: var(--r-sm); }
}

/* ── Toggle — the per-skill "I sell this" switch ─────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  background: var(--border-strong);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch.selected,
.toggle-switch[aria-checked="true"] { background: var(--green); }
.toggle-switch.selected::after,
.toggle-switch[aria-checked="true"]::after { transform: translateX(16px); }
.toggle-switch[aria-checked="true"] ~ .toggle-label,
.toggle-switch.selected ~ .toggle-label { color: var(--green-text); font-weight: var(--fw-semibold); }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  padding: var(--sp-5);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--sp-3); }
.card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.card-head h3 { font-size: var(--fs-lg); }
.card-head p { font-size: var(--fs-sm); color: var(--text-muted); }
.card.accent { background: var(--accent-soft); border-color: var(--accent-light); }
.card.quiet { background: var(--bg-sunken); box-shadow: none; }

/* Confirm card — "From your CV, right?" */
.confirm-card {
  padding: var(--sp-5);
  background: var(--green-light);
  border: 1px solid var(--green);
  border-radius: var(--radius);
}
.confirm-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--fs-md);
}
.confirm-row:last-of-type { border-bottom: none; }
.confirm-row .confirm-label {
  flex: 0 0 96px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
.confirm-row .confirm-value { flex: 1; min-width: 0; word-break: break-word; }

/* ── Banners / callouts ──────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}
.banner .banner-text { flex: 1; min-width: 0; }
.banner svg { width: 18px; height: 18px; }
.banner.info { background: var(--accent-soft); border-color: var(--accent-light); color: var(--text); }
.banner.warn { background: var(--amber-light); border-color: var(--amber-border); color: var(--amber-text); }
.banner.error { background: var(--red-light); border-color: var(--red-border); color: var(--red-text); }
.banner.success { background: var(--green-light); border-color: var(--green); color: var(--green-text); }
@media (max-width: 599px) {
  .banner { flex-wrap: wrap; }
  .banner .btn { width: 100%; }
}

/* Stale-content banner — the showRegenBanner() surface, now two of them */
.regen-banner { margin: var(--sp-4) 0; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  background: var(--bg-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.empty-state h4 { margin-bottom: var(--sp-1); }
.empty-state p {
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* ── Tags ────────────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.tag {
  padding: 2px var(--sp-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
}
.tag.accent { background: var(--accent-light); border-color: var(--accent-light); color: var(--accent); }

/* ── Divider with a word in it ───────────────────────────────────── */
.or-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Upload zone ─────────────────────────────────────────────────── */
.upload-zone {
  position: relative;
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  background: var(--card);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover,
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone > svg { width: 40px; height: 40px; color: var(--accent); }
.upload-zone h3 { margin-top: var(--sp-3); }
.upload-zone p { font-size: var(--fs-sm); color: var(--text-muted); }
.upload-zone .formats { font-size: var(--fs-xs); margin-top: var(--sp-2); }
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  max-width: min(92vw, 420px);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-sm);
  color: #fff;
  background: #1a1d26;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition), transform var(--transition);
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: var(--scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.modal p { font-size: var(--fs-sm); color: var(--text-secondary); }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-5);
}

/* ── Drawer ──────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  background: var(--scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: absolute;
  top: 0;
  right: -100%;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: 100%;
  background: var(--card);
  box-shadow: var(--shadow-panel);
  transition: right var(--transition-slow);
}
.drawer-overlay.open .drawer { right: 0; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.drawer-header h3 { font-size: var(--fs-lg); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
}

/* Definition rows — used by the CV drawer */
.dl-row {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--fs-sm);
}
.dl-label {
  flex: 0 0 100px;
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}
.dl-value { color: var(--text); word-break: break-word; }
.dl-list { margin: 0; padding-left: var(--sp-4); }
.dl-list li { margin-bottom: var(--sp-1); }
.dl-section { margin-top: var(--sp-4); }
.dl-section h4 { margin-bottom: var(--sp-2); color: var(--accent); }

/* ── Website preview — sandboxed iframe, never injected into the SPA ── */
.preview-frame {
  width: 100%;
  height: min(70vh, 720px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.preview-toolbar .tb-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-right: auto;
}

/* ── A link that is really a button ────────────────────────────────
   An <a> with no href is not focusable and not activatable by keyboard,
   which had made the only route from register back to login
   mouse-only. These are buttons that read as links. */
.link-btn {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-hover); }
.link-btn:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }

/* ── The login call-to-action (ui/authgate.js) ──────────────────────
   An owner-only endpoint reached anonymously is the moment to ask for
   the account, so it gets a real banner with somewhere to click — not a
   toast that fades out reading "Access denied". */
.banner.login-cta {
  flex-wrap: wrap;
  align-items: center;
}
.banner.login-cta .btn-row { flex: 0 0 auto; }

/* ── Export groups, one per artifact the bundle can actually serve ── */
.exports { margin-top: var(--sp-6); }
.export-group + .export-group { margin-top: var(--sp-5); }
.export-heading {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-align: center;
}

/* ── Read-back of a repeater answer (render/summary.js) ─────────────
   Used by both the wizard summary and review zone 1. Every column the
   user filled, labelled — a result is its figure and its unit, not its
   title, and a row that renders as one word is the answer thrown away.
   System columns never reach here: the prefill flag is not the user's
   words.                                                              */
.answer-rows {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}
.answer-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-sunken);
  border-radius: var(--r-sm);
}
.answer-ordinal {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}
.answer-pairs {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: var(--sp-1);
}
.answer-pair {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}
.answer-key {
  flex: 0 0 auto;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.answer-text {
  flex: 1 1 160px;
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

/* Private answers show on the user's own screens and nowhere else. The
   marker says which is which, so nothing here reads as public copy. */
.private-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-normal);
  text-transform: none;
  letter-spacing: 0;
  color: var(--violet);
}

/* A row a CV proposed and nobody cleared. Every builder drops it, so the
   read-back says so rather than promising a line the site will not carry. */
.answer-row[data-unconfirmed] { background: var(--amber-light); }
.answer-flag {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--amber-text);
}
