/* The client's signing page (E4; esign.md section 2.5). Self-hosted fonts, no third-party anything.
 * Tokens are the Inspections theme's: primary #2D4739, white background, borders hsl(0 0% 89.8%), radius .5rem,
 * muted text hsl(0 0% 45.1%). 390 px first, a 768 px column on desktop, 44 px minimum targets, visible focus rings,
 * reduced motion respected, light mode only. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/static/fonts/InspInter-var-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Great Vibes";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/InspGreatVibes-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --insp-primary: #2D4739;
  --insp-radius: .5rem;
  --insp-border: hsl(0 0% 89.8%);
  --fg: hsl(0 0% 3.9%);
  --muted: hsl(0 0% 45.1%);
  --bg: #fff;
  --tint: hsl(150 20% 94%);
  --warn: #8a3b12;
  --warn-bg: #fff4e5;
  --tap: 44px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

/* --- frame ------------------------------------------------------------------------------------------- */

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--insp-primary);
  color: #fff;
  font-weight: 600;
  font-size: 18px;
}

.column { width: 100%; max-width: 768px; margin: 0 auto; padding: 0 16px; }

main { padding-top: 16px; padding-bottom: 112px; outline: none; }

h1 { font-size: 22px; line-height: 1.25; margin: 8px 0 8px; font-weight: 700; }
h2 { font-size: 18px; line-height: 1.3; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }

.lead { font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.loading { color: var(--muted); padding: 32px 0; text-align: center; }

/* --- cards, bands, banners --------------------------------------------------------------------------- */

.card {
  border: 1px solid var(--insp-border);
  border-radius: var(--insp-radius);
  padding: 16px;
  margin: 16px 0;
  background: var(--bg);
}
.card.neutral { margin-top: 32px; text-align: left; }

.practice {
  border: 2px solid var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--insp-radius);
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: 14px;
}
.practice strong { letter-spacing: .08em; }

.banner {
  border: 1px solid var(--warn);
  background: var(--warn-bg);
  color: #5c2508;
  border-radius: var(--insp-radius);
  padding: 12px;
  margin: 0 0 16px;
}
.banner p { margin: 0 0 8px; }
.banner p:last-child { margin-bottom: 0; }

.warn { color: var(--warn); font-weight: 600; }

/* --- buttons ----------------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--insp-border);
  border-radius: 999px;
  background: #fff;
  color: var(--fg);
  font: 600 16px/1.2 "Inter", system-ui, sans-serif;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--insp-primary); border-color: var(--insp-primary); color: #fff; }
.btn.secondary { background: #fff; color: var(--insp-primary); border-color: var(--insp-primary); }
.btn.link { border-color: transparent; background: transparent; color: var(--insp-primary); text-decoration: underline; padding: 0 8px; }
.btn.grow { flex: 1 1 auto; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

:focus-visible {
  outline: 3px solid var(--insp-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}
.btn.primary:focus-visible { outline-color: #111; }

.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.secondary-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }

/* --- bottom bar -------------------------------------------------------------------------------------- */

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg);
  border-top: 1px solid var(--insp-border);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
}
.bar-inner { display: flex; gap: 10px; align-items: center; }

/* --- documents and pages ----------------------------------------------------------------------------- */

.doc { margin: 16px 0; }
.doc-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.doc-head h1, .doc-head h2 { margin: 0; flex: 1 1 200px; }

.pages { display: flex; flex-direction: column; gap: 12px; }

.page {
  position: relative;
  width: 100%;
  background: #fff;
  border: 1px solid var(--insp-border);
  border-radius: var(--insp-radius);
  overflow: hidden;
}
.page.with-fields { overflow: visible; }
.page-img { display: block; width: 100%; height: auto; }

/* --- consent ----------------------------------------------------------------------------------------- */

.consent-text {
  max-height: 40vh;
  overflow: auto;
  padding: 12px;
  margin: 8px 0 12px;
  border: 1px solid var(--insp-border);
  border-radius: var(--insp-radius);
  background: var(--tint);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.tick-row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 4px 0; cursor: pointer; }
.tick-row input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--insp-primary); }

/* --- fields over the page images --------------------------------------------------------------------- */

.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; min-height: 0; margin-bottom: 8px; }
.strip-text { font-weight: 600; }

.field {
  position: absolute;
  min-width: var(--tap);
  min-height: var(--tap);
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--muted);
  border-radius: 6px;
  background: hsl(150 20% 94% / .7);
  color: var(--fg);
  font: 500 15px/1.2 "Inter", system-ui, sans-serif;
  overflow: hidden;
}
.field.req { border-color: var(--insp-primary); background: hsl(150 30% 88% / .75); }
.field.done { border-style: solid; background: hsl(150 20% 96% / .6); }
.field.mark, .field.check { container-type: size; cursor: pointer; }
.field.date { border-style: dotted; cursor: default; font-size: 11px; line-height: 1.15; padding: 0 3px; text-align: center; color: var(--muted); }
.field.text { padding: 0 8px; font-size: 16px; background: hsl(150 20% 96% / .85); }
.field.text::placeholder { color: var(--muted); }
.field .prompt { font-size: 14px; font-weight: 600; color: var(--insp-primary); }
.field .box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--insp-primary);
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--insp-primary);
  font-weight: 700;
  line-height: 1;
}

.sig-text { font-family: "Great Vibes", "Snell Roundhand", cursive; white-space: nowrap; line-height: 1.1; }
.sig-text.in-field { font-size: clamp(14px, min(60cqh, 14cqw), 40px); max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.sig-canvas { display: block; }
.sig-canvas.in-field { width: 100%; height: 100%; object-fit: contain; }
.sig-box { border: 1px solid var(--insp-border); border-radius: var(--insp-radius); padding: 12px; margin: 8px 0 12px; background: #fff; }
.sig-text.review { font-size: 40px; display: block; overflow: hidden; text-overflow: ellipsis; }
.sig-canvas.review { width: 100%; max-width: 320px; height: auto; aspect-ratio: 5 / 2; }
.consent-line { color: var(--muted); font-size: 14px; }

/* --- adopt dialog ------------------------------------------------------------------------------------ */

dialog.dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(92vw, 480px);
  max-height: 92vh;
  overflow: auto;
  color: var(--fg);
  background: #fff;
}
dialog.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-body { padding: 20px; }

.field-label { display: block; font-weight: 600; margin: 12px 0 4px; }
.text-input, .note {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid hsl(0 0% 60%);
  border-radius: var(--insp-radius);
  font: 16px/1.4 "Inter", system-ui, sans-serif;
  color: var(--fg);
  background: #fff;
}
.text-input.short { max-width: 140px; }
.text-input[aria-invalid="true"] { border-color: var(--warn); }
.note { resize: vertical; }

.tabs { display: flex; gap: 8px; margin: 16px 0 8px; }
.tab {
  flex: 1 1 0;
  min-height: var(--tap);
  border: 1px solid var(--insp-border);
  border-radius: 999px;
  background: #fff;
  color: var(--insp-primary);
  font: 600 16px/1.2 "Inter", system-ui, sans-serif;
  cursor: pointer;
}
.tab.on { background: var(--insp-primary); border-color: var(--insp-primary); color: #fff; }
.tab.on:focus-visible { outline-color: #111; }

.sig-preview {
  min-height: 80px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--insp-border);
  border-radius: var(--insp-radius);
  background: #fff;
  font: 44px/1.2 "Great Vibes", "Snell Roundhand", cursive;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.draw-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 2;
  border: 1px dashed hsl(0 0% 55%);
  border-radius: var(--insp-radius);
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.downloads { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.problem { margin-top: 8px; }

/* --- desktop ----------------------------------------------------------------------------------------- */

@media (min-width: 768px) {
  h1 { font-size: 26px; }
  main { padding-top: 24px; }
}

/* --- reduced motion ---------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
