/* =========================================================================
   TEGO e-signature (P7): the signing page, /sign/<token> (js/sign-app.js),
   and the signing view (js/sign-view.js), which checkout mounts too.
   tego.css's tokens and parts (card, btn, field, segmented, checkbox-row,
   pill, eyebrow) in one column at every width, as checkout's panels: the
   page's own rules start sign-, the view's sv-. The verify page's rules
   are appended below by its own task.
   ========================================================================= */

.sign-section { padding-block: clamp(1.5rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem); }
.sign-wrap { max-width: 780px; }
.sign-loading { color: var(--muted); }

/* ---- the request's head ------------------------------------------------- */

.sign-head { margin-bottom: 22px; }
/* A title is typed by a person (ops' Send for signature): it breaks rather
   than run past a phone's edge. */
.sign-head h1 { font-size: clamp(1.75rem, 4.4vw, 2.6rem); margin-bottom: 0.4em; overflow-wrap: anywhere; }
.sign-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; font-size: 0.9rem; color: var(--muted); }
.sign-ref { color: var(--ink); font-weight: 600; }
.sign-message {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--periwinkle);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--brand-tint);
  font-size: 0.95rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.sign-signers { margin-top: 16px; border-top: 1px solid var(--border); }
.sign-signers li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.sign-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.sign-when { color: var(--muted); }
.sign-signers li.is-signed .sign-when { color: var(--ok); font-weight: 600; }

/* ---- where a request stands (checkout's confirmation card) -------------- */

.sign-state { text-align: center; padding-block: 44px; }
.sign-state h1,
.sign-state h2 { font-size: clamp(1.45rem, 3.4vw, 1.95rem); margin-bottom: 0.45em; }
.sign-state h2:focus { outline: none; }
.sign-state p { max-width: 46ch; margin-inline: auto; color: var(--muted); overflow-wrap: anywhere; }
.sign-state p a { color: var(--brand); font-weight: 600; }
.sign-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mist);
  color: var(--brand);
}
.sign-state-icon svg { width: 26px; height: 26px; }
.sign-state-icon.is-tick { background: var(--brand); color: #fff; }
.sign-state-icon.is-cross { background: var(--error-bg); color: var(--error); }
.sign-state-actions { justify-content: center; margin-top: 22px; gap: 10px; }

/* ---- the view: three steps ---------------------------------------------- */

.sv { display: grid; gap: 16px; }
.sv-step { padding: clamp(18px, 4vw, 26px); min-width: 0; }
.sv-step h2 { display: flex; align-items: center; gap: 12px; font-size: 1.3rem; margin-bottom: 14px; }
.sv-num {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mist);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.sv-step.is-done .sv-num { background: var(--ok); color: #fff; }

/* 1. Read: a document a row, as checkout's documents. min-width: 0, or a
   long file name holds the row wider than a phone. */
.sv-docs { display: grid; gap: 12px; }
.sv-doc { min-width: 0; border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 14px 16px; }
.sv-doc-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.sv-doc-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--mist); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }
.sv-doc-icon svg { width: 17px; height: 17px; }
.sv-doc-title b { display: block; font-size: 0.95rem; font-weight: 600; overflow-wrap: anywhere; }
.sv-doc-sub { display: block; margin-top: 2px; font-size: 0.82rem; color: var(--muted); }
.sv-doc-flag { padding-top: 3px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ok); white-space: nowrap; }
.sv-doc-flag:empty { display: none; }
/* The PDF in the page, from 800px (js/sign-view.js); a browser with no
   viewer shows the line inside instead. */
.sv-pdf { display: block; width: 100%; height: min(70vh, 760px); margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--mist); }
.sv-pdf-none { margin: 0; padding: 28px 20px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.sv-doc-actions { margin-top: 12px; gap: 8px; padding-left: 44px; }
.sv-doc .field-error { padding-left: 44px; }

/* 2. Confirm it's you. */
.sv-lede { margin-bottom: 14px; color: var(--muted); overflow-wrap: anywhere; }
.sv-code-field { max-width: 230px; margin-bottom: 4px; }
.sv-code-field input { font-size: 1.35rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.sv-resend { margin-top: 8px; margin-left: -10px; }
.sv-ok { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-weight: 600; color: var(--ok); overflow-wrap: anywhere; }
.sv-ok svg { width: 18px; height: 18px; flex: none; margin-top: 3px; }

/* 3. Sign. The pad is the box a signature is kept in, 1,000 x 400 (5:2),
   at any width; it takes no touch gesture of the browser's, so a finger
   drawing in it never scrolls or zooms the page. */
.sv-method { max-width: 320px; margin-bottom: 14px; }
.sv-pad {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 2;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sv-pad svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sv-pad path { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sv-pad-line { position: absolute; left: 6%; right: 6%; bottom: 24%; border-bottom: 1.5px solid var(--border-strong); pointer-events: none; }
.sv-pad-hint { position: absolute; left: 6%; bottom: calc(24% + 8px); font-size: 0.85rem; color: var(--muted-2); pointer-events: none; }
.sv-pad.has-ink .sv-pad-hint { visibility: hidden; }
.sv-pad-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.sv-type { margin-bottom: 8px; }
.sv-type input { font-family: var(--font-display); font-size: 1.5rem; font-style: italic; font-weight: 500; }
.sv-consent { margin: 18px 0 4px; }
.sv-consent a { color: var(--brand); font-weight: 500; }
/* Sign names what is missing, in a sentence that may be long in French: it
   wraps, and while something is missing it reads as a step still to take,
   not as a disabled button. */
.sv-submit { margin-top: 16px; white-space: normal; text-align: center; }
.sv-submit.is-waiting,
.sv-submit.is-waiting:hover { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: none; }
.sv-submit-error { margin-top: 10px; }

@media (max-width: 560px) {
  .sv-doc-actions, .sv-doc .field-error { padding-left: 0; }
  .sv-submit { width: 100%; }
  .sv-method { max-width: none; }
}

/* =========================================================================
   The verify page, /verify/<id> (js/verify-app.js, P7 Task 16): the
   verdict, then a card each for the document, the signers, the trail, the
   seal and Check a file, one column at every width; Nothing to verify and
   the page's failures are the signing page's .sign-state cards above.
   Hashes, the sealed JSON and the signature are monospace and break
   anywhere (a hash between its groups of eight first), so none runs past a
   phone's edge.
   ========================================================================= */

.verify-head .eyebrow { margin-bottom: 12px; }
.verify-verdict {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: clamp(20px, 4vw, 28px);
}
.verify-verdict h1 { font-size: clamp(1.75rem, 4.4vw, 2.6rem); margin-bottom: 0.25em; }
.verify-verdict p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.verify-verdict p a { color: var(--brand); font-weight: 600; }
.verify-verdict[data-verdict="verified"] { border-color: rgba(14, 122, 80, 0.35); }
.verify-verdict[data-verdict="retired"] { border-color: var(--warn-border); background: var(--warn-bg); }
.verify-verdict[data-verdict="mismatch"] { border-color: var(--error); background: var(--error-bg); }
.verify-verdict-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.verify-verdict-icon svg { width: 26px; height: 26px; }
.verify-verdict-icon.is-tick { background: var(--ok); }
.verify-verdict-icon.is-clock { background: #e3a92b; }
.verify-verdict-icon.is-cross { background: var(--error); }

.verify-cards { display: grid; gap: 16px; }
.verify-card { padding: clamp(18px, 4vw, 26px); min-width: 0; }
.verify-card h2 { font-size: 1.3rem; margin-bottom: 14px; }
.verify-lede { margin-bottom: 12px; color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }

/* The document: its facts, a label beside each value (above it on a
   phone), then each value a person compares or copies whole. */
.verify-facts { display: grid; gap: 8px; margin: 0; }
.verify-facts div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 2px 16px; }
.verify-facts dt { color: var(--muted); font-size: 0.9rem; }
.verify-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.verify-issuer { margin: 14px 0 0; font-size: 0.88rem; color: var(--muted); }
.verify-value { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); min-width: 0; }
.verify-label { display: block; margin-bottom: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.verify-value-row { display: flex; align-items: flex-start; gap: 6px 12px; }
.verify-mono {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.verify-copy { flex: none; margin-top: -6px; }

/* The signers, in order. */
.verify-signers li { display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--border); }
.verify-signers li:first-child { padding-top: 0; border-top: none; }
.verify-signer-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.verify-signer-head b { font-size: 1rem; overflow-wrap: anywhere; }
.verify-signer-email,
.verify-signer-when { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.verify-signer-code { display: flex; align-items: flex-start; gap: 6px; font-size: 0.88rem; font-weight: 600; color: var(--ok); }
.verify-signer-code svg { width: 15px; height: 15px; flex: none; margin-top: 3px; }

/* The trail: a line of dots, oldest first. */
.verify-trail { position: relative; display: grid; gap: 12px; padding-left: 22px; }
.verify-trail::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; border-left: 1.5px solid var(--border-strong); }
.verify-trail li { position: relative; display: grid; gap: 1px; }
.verify-trail li::before { content: ""; position: absolute; left: -22px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--periwinkle); }
.verify-trail b { font-size: 0.95rem; font-weight: 600; overflow-wrap: anywhere; }
.verify-trail-sub { font-size: 0.84rem; color: var(--muted); overflow-wrap: anywhere; }

/* The seal, and what anyone needs to check it without TEGO. */
.verify-seal-line { margin: 0 0 12px; }
.verify-yourself summary { width: fit-content; cursor: pointer; font-weight: 600; color: var(--brand); }
.verify-yourself[open] summary { margin-bottom: 12px; }
.verify-key { color: var(--brand); }

/* Check a file: the file input is the button's own, kept for the keyboard
   and a screen reader; the answer under it wears its colour. */
.verify-local { display: flex; align-items: flex-start; gap: 8px; font-size: 0.92rem; font-weight: 600; }
.verify-local svg { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--brand); }
.verify-pick { position: relative; }
.verify-pick:focus-within { outline: 2px solid var(--brand); outline-offset: 3px; }
.verify-result { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; font-weight: 600; overflow-wrap: anywhere; }
/* Empty, it takes no room yet stays in the tree, so its live region is
   heard when the answer arrives (the final review's F16). */
.verify-result:empty { margin: 0; }
.verify-result svg { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.verify-result[data-match="document"],
.verify-result[data-match="certificate"] { color: var(--ok); }
.verify-result[data-match="none"],
.verify-result[data-match="error"] { color: var(--error); }
.verify-result[data-match="busy"] { font-weight: 500; color: var(--muted); }

@media (max-width: 560px) {
  .verify-verdict { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; }
  .verify-verdict-icon { width: 44px; height: 44px; }
  .verify-verdict-icon svg { width: 22px; height: 22px; }
  .verify-facts div { grid-template-columns: 1fr; }
}
