/*
 * Inkslip — the signing page, the kiosk and the embedded form (ROADMAP §S-DESIGN).
 *
 * A centred card (full width on a phone), one accent colour from the business
 * (the server darkens it until white text on it reads at 4.5:1), the system font
 * stack (no web fonts — nothing is fetched from anywhere else), 17px text on
 * phones, 44px targets, 16px+ inputs so iOS never zooms, a sticky primary
 * button, dark mode from the device, right-to-left by logical properties.
 */

.inkslip {
  --inkslip-ink: #1b2230;
  --inkslip-muted: #5a6475;
  --inkslip-line: #dfe4ec;
  --inkslip-soft: #f3f5f9;
  --inkslip-card: #ffffff;
  --inkslip-error: #b42318;
  --inkslip-error-bg: #fef3f2;
  --inkslip-ok: #067647;
  --inkslip-radius: 12px;
  --inkslip-accent-ink: #ffffff;
  box-sizing: border-box;
  color: var(--inkslip-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* Inside a theme's page: the theme's own rules for inputs and buttons must not
 * reach in (a theme that makes every button orange would break the form). */
.inkslip.inkslip-embed :where(*) {
  all: revert;
  box-sizing: border-box;
}

.inkslip.inkslip-embed {
  margin: 1.5em 0;
}

/* ── the standalone page ─────────────────────────────────────────────── */
body.inkslip-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #eef1f6;
}

.inkslip-standalone {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 16px;
}

.inkslip .inkslip-card {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  background: var(--inkslip-card);
  border-radius: var(--inkslip-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.08);
  padding: 28px 28px 0;
}

.inkslip .inkslip-card-wide {
  max-width: 1080px;
}

.inkslip .inkslip-message,
.inkslip .inkslip-done {
  padding-bottom: 28px;
  text-align: center;
}

.inkslip .inkslip-loading {
  color: var(--inkslip-muted);
  text-align: center;
  padding: 48px 16px;
  margin: 0;
}

/* ── header, progress ────────────────────────────────────────────────── */
.inkslip .inkslip-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.inkslip .inkslip-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: 48px;
  max-width: 140px;
  border-radius: 8px;
}

.inkslip .inkslip-message .inkslip-logo {
  margin: 0 auto 8px;
}

.inkslip .inkslip-business {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--inkslip-muted);
}

.inkslip .inkslip-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--inkslip-soft);
  overflow: hidden;
}

.inkslip .inkslip-progress-bar {
  display: block;
  height: 100%;
  background: var(--inkslip-accent, #2f5d50);
  border-radius: 4px;
  transition: width 0.25s ease;
}

.inkslip .inkslip-step {
  margin: 10px 0 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--inkslip-muted);
}

/* ── text ────────────────────────────────────────────────────────────── */
.inkslip .inkslip-title {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  outline: none;
}

.inkslip .inkslip-h2 {
  margin: 0 0 14px;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
  outline: none;
}

.inkslip .inkslip-h3 {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
}

.inkslip .inkslip-meta,
.inkslip .inkslip-muted,
.inkslip .inkslip-hint {
  margin: 0 0 14px;
  color: var(--inkslip-muted);
  font-size: 14px;
}

.inkslip .inkslip-hint {
  margin: 6px 0 0;
}

.inkslip .inkslip-lead {
  font-size: 17px;
  margin: 8px 0;
}

.inkslip .inkslip-text {
  max-height: 52vh;
  max-height: 52dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px;
  margin: 0 0 16px;
  background: var(--inkslip-soft);
  border: 1px solid var(--inkslip-line);
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.6;
}

.inkslip .inkslip-text:focus-visible {
  outline: 3px solid var(--inkslip-accent, #2f5d50);
  outline-offset: 2px;
}

.inkslip .inkslip-text h1,
.inkslip .inkslip-text h2,
.inkslip .inkslip-text h3,
.inkslip .inkslip-text h4 {
  font-size: 17px;
  margin: 1.1em 0 0.35em;
}

.inkslip .inkslip-text > :first-child {
  margin-top: 0;
}

.inkslip .inkslip-text p,
.inkslip .inkslip-text ul,
.inkslip .inkslip-text ol {
  margin: 0 0 0.8em;
}

.inkslip .inkslip-text ul,
.inkslip .inkslip-text ol {
  padding-inline-start: 1.3em;
}

/* ── form fields ─────────────────────────────────────────────────────── */
.inkslip .inkslip-form {
  margin: 0;
}

.inkslip .inkslip-field {
  margin: 0 0 16px;
}

.inkslip .inkslip-label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 15px;
}

.inkslip .inkslip-optional {
  font-weight: 400;
  color: var(--inkslip-muted);
}

.inkslip .inkslip-input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 11px 13px;
  font: inherit;
  font-size: 17px;
  color: var(--inkslip-ink);
  background: #fff;
  border: 1.5px solid #c8cfda;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
}

.inkslip select.inkslip-input {
  background-image: linear-gradient(45deg, transparent 50%, var(--inkslip-muted) 50%), linear-gradient(135deg, var(--inkslip-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-inline-end: 36px;
}

[dir="rtl"] .inkslip select.inkslip-input {
  background-position: 14px 50%, 20px 50%;
}

.inkslip textarea.inkslip-input {
  min-height: 96px;
  resize: vertical;
}

/* A field brought into view (by focus, by a tap, by the browser) stops clear of
 * the sticky button bar at the bottom — never hidden behind it. */
.inkslip .inkslip-input,
.inkslip .inkslip-check,
.inkslip .inkslip-choice,
.inkslip .inkslip-pad {
  scroll-margin-top: 16px;
  scroll-margin-bottom: 120px;
}

.inkslip .inkslip-input:focus {
  outline: none;
  border-color: var(--inkslip-accent, #2f5d50);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--inkslip-accent, #2f5d50) 22%, transparent);
}

.inkslip .inkslip-input[aria-invalid="true"],
.inkslip .is-invalid .inkslip-pad {
  border-color: var(--inkslip-error);
}

.inkslip .inkslip-other {
  margin-top: 8px;
}

.inkslip .inkslip-error {
  margin: 6px 0 0;
  color: var(--inkslip-error);
  font-size: 14px;
  font-weight: 600;
}

.inkslip .inkslip-alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--inkslip-error-bg);
  color: var(--inkslip-error);
  font-weight: 600;
  text-align: start;
}

.inkslip .inkslip-group {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.inkslip .inkslip-group > legend {
  padding: 0;
}

.inkslip .inkslip-check {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--inkslip-line);
  border-radius: 10px;
  background: var(--inkslip-card);
  cursor: pointer;
}

.inkslip .inkslip-check.is-invalid {
  border-color: var(--inkslip-error);
}

.inkslip .inkslip-check input {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--inkslip-accent, #2f5d50);
}

.inkslip .inkslip-check label {
  flex: 1 1 0;
  min-width: 0;
  font-size: 16px;
  cursor: pointer;
}

.inkslip .inkslip-check .inkslip-error {
  flex-basis: 100%;
  margin: 0;
}

.inkslip .inkslip-choices {
  display: flex;
  gap: 10px;
}

.inkslip .inkslip-choice {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 1.5px solid var(--inkslip-line);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.inkslip .inkslip-choice input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--inkslip-accent, #2f5d50);
}

.inkslip .inkslip-child {
  margin: 0 0 14px;
  padding: 14px 14px 6px;
  border: 1.5px solid var(--inkslip-line);
  border-radius: 12px;
  min-width: 0;
}

.inkslip .inkslip-child > legend {
  padding: 0 6px;
}

/* The honeypot: out of sight and out of the accessibility tree. */
.inkslip .inkslip-hp {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  inset-inline-start: -9999px;
}

/* ── buttons ─────────────────────────────────────────────────────────── */
.inkslip .inkslip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 44px;
  padding: 10px 20px;
  margin: 0;
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.inkslip .inkslip-btn:focus-visible {
  outline: 3px solid var(--inkslip-accent, #2f5d50);
  outline-offset: 2px;
}

.inkslip .inkslip-btn-primary {
  background: var(--inkslip-accent, #2f5d50);
  color: var(--inkslip-accent-ink);
}

.inkslip .inkslip-btn-primary:hover {
  filter: brightness(1.08);
}

.inkslip .inkslip-btn-primary[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.inkslip .inkslip-btn-secondary {
  background: var(--inkslip-card);
  color: var(--inkslip-ink);
  border-color: #c8cfda;
}

.inkslip .inkslip-btn-quiet {
  background: transparent;
  color: var(--inkslip-ink);
  border-color: transparent;
}

.inkslip .inkslip-btn-link {
  background: transparent;
  border: 0;
  padding: 10px 4px;
  color: var(--inkslip-accent, #2f5d50);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

/* The bar with Back and the primary button sticks to the bottom of the screen,
 * clear of the home bar. */
.inkslip .inkslip-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px -28px 0;
  padding: 14px 28px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--inkslip-card);
  border-top: 1px solid var(--inkslip-line);
  border-radius: 0 0 var(--inkslip-radius) var(--inkslip-radius);
}

.inkslip .inkslip-foot .inkslip-btn-primary {
  flex: 0 1 auto;
  min-width: 180px;
}

/* ── the signature pad ───────────────────────────────────────────────── */
.inkslip .inkslip-pad {
  position: relative;
  height: 210px;
  border: 2px dashed #b8c1cf;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.inkslip .inkslip-canvas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -ms-touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.inkslip .inkslip-pad-line {
  position: absolute;
  inset-inline: 24px;
  bottom: 52px;
  border-bottom: 1.5px solid #c8cfda;
  pointer-events: none;
}

.inkslip .inkslip-pad-hint {
  position: absolute;
  inset-inline-start: 28px;
  bottom: 60px;
  color: #98a2b3;
  font-size: 18px;
  pointer-events: none;
}

.inkslip .inkslip-pad-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 16px;
}

.inkslip .inkslip-typed-preview {
  min-height: 1.6em;
  margin: 10px 0 0;
  padding: 6px 12px 4px;
  border-bottom: 1.5px solid #c8cfda;
  font-family: "Snell Roundhand", "Segoe Script", "Bradley Hand", "Brush Script MT", "URW Chancery L", cursive;
  font-size: 30px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* ── done ────────────────────────────────────────────────────────────── */
.inkslip .inkslip-tick {
  width: 76px;
  height: 76px;
  margin: 8px auto 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--inkslip-ok) 14%, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: inkslip-pop 0.4s ease-out both;
}

.inkslip .inkslip-tick span {
  width: 22px;
  height: 38px;
  margin-top: -6px;
  border: solid var(--inkslip-ok);
  border-width: 0 6px 6px 0;
  transform: rotate(45deg);
}

.inkslip .inkslip-valid {
  display: inline-block;
  margin: 10px 0 18px;
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--inkslip-ok) 12%, #fff);
  color: var(--inkslip-ok);
  font-weight: 700;
}

.inkslip .inkslip-download {
  margin-top: 8px;
}

@keyframes inkslip-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── wide screens: the text beside the details ───────────────────────── */
.inkslip .inkslip-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.inkslip .inkslip-columns .inkslip-text {
  max-height: 62vh;
  max-height: 62dvh;
}

/* ── phones: the card fills the screen ──────────────────────────────── */
@media (max-width: 640px) {
  .inkslip-standalone {
    padding: 0;
  }

  .inkslip.inkslip-standalone .inkslip-card {
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px 18px 0;
    display: flex;
    flex-direction: column;
  }

  .inkslip.inkslip-standalone .inkslip-card .inkslip-form {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
  }

  .inkslip.inkslip-standalone .inkslip-card .inkslip-main {
    flex: 1 0 auto;
  }

  .inkslip .inkslip-card {
    padding: 20px 18px 0;
  }

  .inkslip {
    font-size: 17px;
  }

  .inkslip .inkslip-foot {
    margin: 8px -18px 0;
    padding: 12px 18px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
  }

  .inkslip .inkslip-foot .inkslip-btn-primary {
    flex: 1 1 auto;
    min-width: 0;
  }

  .inkslip .inkslip-title {
    font-size: 23px;
  }

  .inkslip .inkslip-pad {
    height: 190px;
  }
}

/* ── the counter tablet ──────────────────────────────────────────────── */
body.inkslip-kiosk-body {
  overscroll-behavior: none;
}

.inkslip-kiosk-body .inkslip .inkslip-card {
  max-width: 760px;
}

.inkslip-kiosk-body .inkslip {
  font-size: 18px;
}

.inkslip-kiosk-body .inkslip .inkslip-pad {
  height: 260px;
}

.inkslip .inkslip-attract {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  margin: 0;
  padding: 32px;
  border: 0;
  border-radius: var(--inkslip-radius);
  background: var(--inkslip-card);
  color: var(--inkslip-ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
}

.inkslip .inkslip-attract-logo {
  max-height: 120px;
  max-width: 60%;
  width: auto;
  height: auto;
}

.inkslip .inkslip-attract-business {
  font-size: 22px;
  font-weight: 600;
  color: var(--inkslip-muted);
}

.inkslip .inkslip-attract-cta {
  position: relative;
  display: inline-block;
  padding: 22px 40px;
  border-radius: 999px;
  background: var(--inkslip-accent, #2f5d50);
  color: var(--inkslip-accent-ink);
  font-size: 30px;
  font-weight: 700;
}

/* The pulse is a ring that grows and fades BEHIND the button — opacity and
 * transform only, which a tablet's compositor draws without repainting the page.
 * (A first version animated a box-shadow on the button itself: a software-drawn
 * tablet repainted the whole screen every frame and pegged its CPU.) */
.inkslip .inkslip-attract-cta::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: inherit;
  border: 3px solid var(--inkslip-accent, #2f5d50);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  animation: inkslip-ring 2.8s ease-out infinite;
}

@keyframes inkslip-ring {
  0% { transform: scale(1); opacity: 0.55; }
  70%, 100% { transform: scale(1.18); opacity: 0; }
}

.inkslip .inkslip-attract-title {
  font-size: 18px;
  color: var(--inkslip-muted);
}

.inkslip .inkslip-staff {
  position: fixed;
  inset-inline-end: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--inkslip-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--inkslip-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.inkslip .inkslip-staff.inkslip-staff-top {
  top: calc(10px + env(safe-area-inset-top, 0px));
  bottom: auto;
}

.inkslip .inkslip-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, 0.55);
}

.inkslip .inkslip-dialog {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: var(--inkslip-radius);
  background: var(--inkslip-card);
  box-shadow: 0 20px 48px rgba(16, 24, 40, 0.25);
}

.inkslip .inkslip-dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.inkslip .inkslip-staff-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inkslip .inkslip-pin {
  font-size: 28px;
  letter-spacing: 0.4em;
  text-align: center;
}

.inkslip .inkslip-countdown {
  color: var(--inkslip-muted);
  font-size: 15px;
}

/* ── dark mode (the standalone pages only — an embedded form follows its page) ── */
@media (prefers-color-scheme: dark) {
  body.inkslip-body {
    background: #0f141c;
  }

  .inkslip-body .inkslip {
    --inkslip-ink: #e8ecf3;
    --inkslip-muted: #a5afbf;
    --inkslip-line: #2b3442;
    --inkslip-soft: #171e29;
    --inkslip-card: #111824;
    --inkslip-error: #fda29b;
    --inkslip-error-bg: #3b1714;
    --inkslip-ok: #75e0a7;
  }

  .inkslip-body .inkslip .inkslip-input {
    background: #0b111a;
    border-color: #3a4556;
    color: var(--inkslip-ink);
  }

  .inkslip-body .inkslip .inkslip-pad {
    border-color: #3a4556;
  }

  .inkslip-body .inkslip .inkslip-tick,
  .inkslip-body .inkslip .inkslip-valid {
    background: #12301f;
  }

  .inkslip-body .inkslip .inkslip-staff {
    background: rgba(17, 24, 36, 0.85);
  }
}

/* ── less motion when the device asks for it ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .inkslip .inkslip-tick,
  .inkslip .inkslip-attract-cta::after,
  .inkslip .inkslip-progress-bar {
    animation: none;
    transition: none;
  }
}

/* B2 — "Initial here" at the end of a section, and the yes/no health questions. */
.inkslip .inkslip-text .inkslip-initial {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 18px;
  padding: 10px 12px;
  border: 1.5px dashed var(--inkslip-accent, #2f5d50);
  border-radius: 10px;
  background: var(--inkslip-soft);
}

.inkslip .inkslip-text .inkslip-initial.is-invalid {
  border-color: var(--inkslip-error);
  background: var(--inkslip-error-bg);
}

.inkslip .inkslip-text .inkslip-initial-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--inkslip-ink);
}

.inkslip .inkslip-text .inkslip-initial-input {
  width: 6.5em;
  min-width: 0;
  min-height: 44px;
  font-size: 18px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inkslip .inkslip-text .inkslip-initial .inkslip-error {
  flex-basis: 100%;
  margin: 0;
  text-align: right;
}

.inkslip .inkslip-details .inkslip-h3 {
  margin: 18px 0 10px;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
}

.inkslip .inkslip-health .inkslip-explain {
  margin-top: 10px;
}

.inkslip .inkslip-health .inkslip-explain[hidden] {
  display: none;
}
