/* sign.css — lo propio de las páginas públicas de app-sign (firmante y
   verificación). `app.css` es la copia común de la suite y NO se edita: aquí
   sólo lo que estas dos páginas necesitan encima.

   Pensadas para un móvil de 360 px con el pulgar: letra de 16 px, botones y
   casillas de al menos 44 px, foco siempre visible y nada que obligue a
   desplazarse a lo ancho. Los colores salen de las variables de app.css, que
   ya están medidas contra WCAG AA en claro y en oscuro; la marca del despacho
   entra por `--brand` / `--on-brand` (la pone brand.js, que elige el texto
   de encima por contraste). */

:root {
  --brand: var(--a);
  --on-brand: var(--on-accent);
  --focus-ring: var(--tx);
  --sg-page-max: 760px;
  --sg-gutter: 16px;
  --sg-touch: 44px;
  --sg-fs: 16px;
}

.sg-body {
  font-size: var(--sg-fs);
  line-height: 1.5;
  background: var(--bg);
  color: var(--tx);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* El foco se ve SIEMPRE con teclado, encima de cualquier regla de app.css que
   lo quite (`outline: none` en los campos). */
.sg-body :focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.sg-body .field input:focus-visible,
.sg-body input:focus-visible,
.sg-body textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.sg-skip {
  position: absolute;
  left: var(--sg-gutter);
  top: -100px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--bg2);
  color: var(--tx);
  border: 2px solid var(--focus-ring);
  border-radius: var(--radius);
}
.sg-skip:focus { top: 8px; }

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

/* ── Cabecera con la marca del despacho ─────────────────────────────────── */
.sg-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px var(--sg-gutter);
  background: var(--brand);
  color: var(--on-brand);
}
.sg-brand-logo {
  display: block;
  max-height: 40px;
  max-width: 160px;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 6px;
  padding: 3px;
}
/* El display: block de arriba le gana al [hidden] del navegador: sin esto, sin logotipo se ve un recuadro blanco. */
.sg-brand-logo[hidden] { display: none; }
.sg-brand-name {
  font-weight: 700;
  font-size: 17px;
  overflow-wrap: anywhere;
}
/* S17.5 · La marca del producto, a la derecha y más discreta que la del despacho. */
.sg-product-name {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
}

/* ── Página ──────────────────────────────────────────────────────────────── */
.sg-page {
  width: 100%;
  max-width: var(--sg-page-max);
  margin: 0 auto;
  padding: var(--sg-gutter);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 0 auto;
}
.sg-page:focus { outline: none; }
.sg-heading { display: flex; flex-direction: column; gap: 4px; }
.sg-title {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.sg-position { color: var(--dim); font-weight: 500; }

.sg-section {
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: var(--sg-gutter);
  min-width: 0;
}
.sg-section h2 {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  margin-bottom: 8px;
}
.sg-section p + p { margin-top: 8px; }

.sg-notices:empty { display: none; }
.sg-body .notice { font-size: var(--sg-fs); margin: 0; }
.sg-notice-text { overflow-wrap: anywhere; }
.sg-reference {
  margin-top: 4px;
  font-size: 13px;
  color: var(--dim);
  overflow-wrap: anywhere;
}
.sg-state { margin: 0; }
.sg-state-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }

.sg-footer {
  padding: 12px var(--sg-gutter) 20px;
  text-align: center;
  font-size: 14px;
  color: var(--dim);
}

/* ── Botones y campos: al menos 44 px, letra de 16 (iOS no hace zoom) ──── */
.sg-body .btn {
  min-height: var(--sg-touch);
  height: auto;
  padding: 10px 18px;
  font-size: var(--sg-fs);
  line-height: 1.3;
  text-align: center;
  white-space: normal;
}
.sg-body .btn-primary { background: var(--brand); color: var(--on-brand); }
.sg-body .btn-primary:hover { background: var(--brand); filter: brightness(0.92); }
.sg-body .btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.sg-body .btn-link {
  background: none;
  border: none;
  color: var(--a);
  text-decoration: underline;
  padding: 10px 4px;
}
.sg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.sg-actions .btn { flex: 1 1 auto; }

.sg-body .field { gap: 6px; margin-top: 12px; }
.sg-body .field label { font-size: var(--sg-fs); color: var(--tx); }
.sg-body .field input,
.sg-body .field textarea {
  min-height: var(--sg-touch);
  height: auto;
  font-size: var(--sg-fs);
  font-family: inherit;
  padding: 8px 12px;
  width: 100%;
  max-width: 100%;
}
.sg-hint { font-size: 14px; color: var(--dim); }

@media (max-width: 420px) {
  .sg-actions .btn { width: 100%; }
}

/* ── Visor del documento (pdf.js) ────────────────────────────────────────
   La página se ajusta al ancho del marco; al ampliar, se desplaza DENTRO del
   marco (que es un elemento enfocable, para poder moverse con el teclado), y
   la página de fuera nunca se desplaza a lo ancho. */
.sg-viewer { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; min-width: 0; }
.sg-viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.sg-viewer-bar .btn { flex: 0 1 auto; min-width: var(--sg-touch); }
.sg-viewer-page, .sg-viewer-zoom-label { font-weight: 600; text-align: center; flex: 1 1 auto; }
.sg-viewer-frame {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--bd2);
  border-radius: var(--radius);
  background: var(--bg3);
  max-height: 80vh;
}
.sg-viewer-canvas { display: block; background: #FFFFFF; }
.sg-document-meta { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sg-document-meta .btn { align-self: flex-start; }
.sg-hash { overflow-wrap: anywhere; }
.sg-hash code, .sg-hash-full code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.sg-hash-full summary { cursor: pointer; padding: 11px 0; color: var(--a); }

/* ── El código de un solo uso ─────────────────────────────────────────── */
.sg-body .field input.sg-code-input {
  font-size: 24px;
  letter-spacing: 0.25em;
  font-variant-numeric: tabular-nums;
  max-width: 14ch;
  min-height: 52px;
}
.sg-field-error { color: var(--danger-tx); font-weight: 600; }
.sg-code-sent { font-weight: 600; overflow-wrap: anywhere; }

/* ── Firmar y rechazar ────────────────────────────────────────────────── */
.sg-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--sg-touch);
  padding: 10px 0;
  cursor: pointer;
  font-weight: 600;
}
.sg-check input {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
}
.sg-decline {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--bd);
}
.sg-decline .sg-step-title { font-size: 16px; }
/* El rojo de app.css con letra blanca no llega a 4,5:1 en oscuro: el botón de
   rechazar usa la pareja suave, medida en los dos temas. */
.sg-body .btn-danger {
  background: var(--danger-soft);
  color: var(--danger-tx);
  border-color: var(--danger-bd);
}

/* ── Página de verificación ───────────────────────────────────────────── */
.sg-body input[type=file] {
  min-height: var(--sg-touch);
  max-width: 100%;
  font-size: var(--sg-fs);
  padding: 6px 0;
}
.sg-verdict { margin: 8px 0 12px; }
.sg-signature {
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 12px var(--sg-gutter);
  margin-top: 12px;
  background: var(--bg);
}
.sg-signature h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.sg-signature h4 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.sg-signature-facts { display: flex; flex-direction: column; gap: 10px; }
.sg-signature-facts dt { font-weight: 600; }
.sg-signature-facts dd { overflow-wrap: anywhere; }
.sg-signature-facts .badge { font-size: 14px; margin-right: 4px; }
.sg-problems ul { padding-left: 20px; }
.sg-problems li { overflow-wrap: anywhere; }
