/* Signing: email code card, document reading view, sign and decline sheets,
   and the public record check. */

.sign-shell {
  --sign-ink: #14213d;
  --sign-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

.sign-brand {
  min-height: 28px;
}

.sign-brand-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
}

.sign-brand .brand-word {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-card .gate-meta {
  border-bottom: 1px solid var(--line);
}

.sign-prompt {
  font-size: 13.5px;
}

.sign-live:empty,
.sign-code-status:empty,
.sign-check:empty {
  display: none;
}

.sign-code-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sign-code-form .label {
  font-size: 13px;
  line-height: 1.5;
}

.sign-code-input {
  height: 64px;
  padding: 0 8px 0 calc(8px + 0.32em);
  border-radius: 14px;
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-align: center;
}

.sign-code-input::placeholder {
  color: #d0d5dd;
  font-weight: 500;
}

.sign-code-status {
  min-height: 20px;
}

.sign-code-note {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.sign-link {
  align-self: flex-start;
  min-height: 44px;
  margin: -6px 0 -8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-dark);
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
}

.sign-link:disabled {
  color: var(--muted-light);
  font-weight: 500;
}

.sign-tone-green {
  background: var(--green-soft);
  color: var(--green);
}

.sign-state-doc {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Document view */

.sign-doc {
  --sign-ink: #14213d;
  --sign-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  min-height: 100vh;
  min-height: 100dvh;
  background: #eef1f6;
}

.sign-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(9px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 9px
    max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(1.4) blur(10px);
}

.sign-top-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.sign-top-org {
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-top-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 620;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-top-page {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
}

.sign-column {
  display: flex;
  width: 100%;
  max-width: 860px;
  flex-direction: column;
  gap: 14px;
  margin: 0 auto;
  padding: 16px max(12px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.sign-column.has-bar {
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

.sign-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow-wrap: anywhere;
  animation: gate-rise 220ms var(--ease-out) both;
}

.sign-panel-lead {
  color: var(--ink);
  font-size: 15px;
  font-weight: 550;
  line-height: 1.45;
}

.sign-panel-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sign-message {
  margin: 0;
  padding: 10px 14px;
  border-left: 3px solid #c7d7fe;
  border-radius: 4px 10px 10px 4px;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.sign-panel-hint,
.sign-panel-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.sign-panel-hint svg,
.sign-panel-note svg {
  flex: none;
  margin-top: 2px;
  color: var(--muted-light);
}

.sign-inline-link {
  color: var(--brand-dark);
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sign-done-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sign-done-head h2 {
  font-size: 19px;
  letter-spacing: -0.015em;
}

.sign-done-icon {
  display: flex;
  width: 40px;
  height: 40px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}

.sign-download {
  height: 48px;
  font-size: 15px;
}

/* Signers */

.sign-parties {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  list-style: none;
}

.sign-party {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px 12px;
}

.sign-party + .sign-party {
  border-top: 1px solid var(--line);
}

.sign-party-avatar {
  display: flex;
  width: 30px;
  height: 30px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.sign-party.is-signed .sign-party-avatar {
  background: var(--green-soft);
  color: var(--green);
}

.sign-party.is-declined .sign-party-avatar {
  background: var(--red-soft);
  color: var(--red-ink);
}

.sign-party-text {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.sign-party-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.sign-party-you {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 600;
}

.sign-party-title {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.sign-party-status {
  flex: none;
  max-width: 46%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-align: right;
}

.sign-party.is-signed .sign-party-status {
  color: var(--green-ink);
}

.sign-party.is-declined .sign-party-status {
  color: var(--red-ink);
}

/* Rendered pages */

.sign-pdf {
  display: flex;
  flex-direction: column;
}

.sign-pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sign-pdf-page {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.07);
}

.sign-pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sign-pdf-page.is-failed::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  content: "This page could not be shown.";
}

.sign-pdf-wait {
  display: flex;
  min-height: 46vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.07);
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.sign-pdf-wait p {
  max-width: 320px;
}

/* Sticky action bar */

.sign-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(1.4) blur(10px);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, 0.06);
}

.sign-bar-inner {
  display: flex;
  max-width: 836px;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
}

.sign-bar .btn {
  height: 50px;
  border-radius: 13px;
  font-size: 16px;
}

.sign-bar-decline {
  flex: none;
  padding: 0 16px;
  color: var(--ink-soft);
  font-weight: 500;
}

.sign-bar-sign {
  flex: 1;
  font-weight: 600;
}

/* Sheets */

.sign-sheet .modal {
  max-width: 540px;
}

.sign-sheet .modal-header h2 {
  font-size: 17px;
}

.sign-sheet .modal-body {
  gap: 18px;
}

.sign-sheet-copy {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.sign-sheet-foot .btn {
  height: 48px;
  font-size: 15px;
}

.sign-submit {
  min-width: 170px;
}

.sign-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sign-modes {
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-tint);
}

.sign-mode {
  min-width: 68px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.sign-mode.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.sign-pad {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  color: var(--sign-ink, #14213d);
}

.sign-pad-host {
  position: absolute;
  inset: 0;
}

.sign-pad-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.sign-pad-line {
  position: absolute;
  right: 7%;
  bottom: 24%;
  left: 7%;
  height: 1px;
  background: var(--line-hover);
  pointer-events: none;
}

.sign-pad-hint {
  position: absolute;
  bottom: calc(24% + 7px);
  left: 7%;
  color: var(--placeholder);
  font-size: 13px;
  pointer-events: none;
}

.sign-pad-typed {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7%;
}

.sign-typed {
  max-width: 100%;
  overflow: hidden;
  padding: 0 4px 6%;
  font-family: var(--sign-serif, Georgia, serif);
  font-size: clamp(24px, 7.6vw, 42px);
  font-style: italic;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-pad-tools {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: -2px;
}

.sign-pad-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sign-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.55;
  cursor: pointer;
}

.sign-consent input {
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  accent-color: var(--brand);
}

.sign-consent:has(input:checked) {
  border-color: #b2ccff;
  background: var(--brand-soft);
}

.sign-consent:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Signature as recorded */

.sign-mark {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 3 / 1;
  border-bottom: 1px solid var(--line-hover);
  color: var(--sign-ink, #14213d);
}

.sign-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sign-mark-typed {
  display: flex;
  align-items: flex-end;
  padding: 0 6px 8px;
  overflow: hidden;
  font-family: var(--sign-serif, Georgia, serif);
  font-size: 30px;
  font-style: italic;
  line-height: 1.15;
}

.sign-mark-typed span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fingerprint */

.sign-hash {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.sign-hash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sign-hash-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.4;
}

.sign-hash-value {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  user-select: all;
}

/* Public record */

.sign-record {
  display: flex;
  max-width: 580px;
  flex-direction: column;
  gap: 16px;
  overflow-wrap: anywhere;
}

.sign-record-status {
  margin-top: 10px;
}

.sign-facts {
  display: flex;
  flex-direction: column;
  margin: 0;
  border-top: 1px solid var(--line);
}

.sign-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.sign-facts dt {
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.sign-facts dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-align: right;
}

.sign-facts-id {
  font-size: 12px;
  font-weight: 400;
}

.sign-section-title {
  margin-top: 6px;
  font-size: 15px;
}

.sign-section-copy {
  margin-top: -10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.sign-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  white-space: nowrap;
}

.sign-drop {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 18px;
  border: 1.5px dashed var(--line-hover);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.sign-drop svg {
  margin-bottom: 4px;
  color: var(--brand);
}

.sign-drop-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.sign-drop-sub {
  font-size: 12.5px;
}

.sign-drop.is-over {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.sign-file-input:focus-visible + .sign-drop {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sign-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: gate-rise 200ms var(--ease-out) both;
}

.sign-result-icon {
  display: flex;
  width: 34px;
  height: 34px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.sign-result-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  line-height: 1.5;
}

.sign-result-text strong {
  font-size: 14.5px;
  font-weight: 620;
}

.sign-result-file {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.sign-result-hash {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sign-result.is-match {
  border-color: #abefc6;
  background: var(--green-soft);
  color: var(--green-ink);
}

.sign-result.is-match .sign-result-icon {
  background: #d1fadf;
  color: var(--green);
}

.sign-result.is-original {
  border-color: #fedf89;
  background: var(--amber-soft);
  color: #93370d;
}

.sign-result.is-original .sign-result-icon {
  background: #fef0c7;
  color: var(--amber);
}

.sign-result.is-different {
  border-color: #fecdca;
  background: var(--red-soft);
  color: var(--red-ink);
}

.sign-result.is-different .sign-result-icon {
  background: #fee4e2;
  color: var(--red);
}

@media (hover: hover) and (pointer: fine) {
  .sign-link:hover:not(:disabled),
  .sign-inline-link:hover {
    color: var(--brand-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .sign-mode:hover:not(.is-on) {
    color: var(--ink);
  }

  .sign-drop:hover {
    border-color: var(--brand);
  }

  .sign-bar-decline:hover {
    background: var(--surface-tint);
  }
}

@media (min-width: 720px) {
  .sign-top {
    padding-right: 24px;
    padding-left: 24px;
  }

  .sign-column {
    gap: 18px;
    padding-top: 22px;
  }

  .sign-panel {
    padding: 22px 24px;
  }

  .sign-pdf-pages {
    gap: 16px;
  }

  .sign-bar-inner {
    justify-content: flex-end;
  }

  .sign-bar-sign {
    max-width: 260px;
  }
}

@media (max-width: 640px) {
  .sign-sheet .modal-backdrop {
    align-items: flex-end;
    padding: env(safe-area-inset-top) 0 0;
  }

  .sign-sheet .modal {
    max-width: none;
    max-height: 94dvh;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
  }

  .sign-sheet .modal-header {
    padding: 16px 16px 12px;
  }

  .sign-sheet .modal-body {
    padding: 16px;
  }

  .sign-sheet-foot {
    flex-wrap: nowrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .sign-sheet-foot .btn {
    flex: 1;
  }

  .sign-sheet-foot .sign-submit,
  .sign-sheet-foot .btn-danger {
    flex: 1.6;
    min-width: 0;
  }

  .sign-mode {
    height: 40px;
    min-width: 74px;
  }

  .sign-facts > div {
    flex-direction: column;
    gap: 1px;
  }

  .sign-facts dd {
    text-align: left;
  }

  .sign-party-status {
    max-width: 40%;
  }

  @starting-style {
    .sign-sheet .modal {
      opacity: 1;
      transform: translateY(48px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .sign-panel,
  .sign-result {
    animation: none;
  }

  .sign-mode,
  .sign-drop {
    transition: none;
  }

  @starting-style {
    .sign-sheet .modal {
      transform: none;
    }
  }
}
