/* sign.css · "Sign a PDF" (tools/sign.js). Every rule is scoped under #sign. Uses the shared classes and tokens of tools.css.
   The two ink colours of a pen (black, blue) are set in sign.js; nothing else here adds a colour. */

#sign { position: relative; }
#sign .sg-private { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 14px; color: var(--ink-soft); }
#sign .sg-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--clay); box-shadow: 0 0 0 4px var(--clay-wash); }
#sign .sg-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule); }
#sign .sg-busy { margin-top: 18px; font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--ink-soft); }

/* ---------- 1. open ---------- */
#sign .sg-drop {
  margin-top: 20px; padding: 44px 20px 40px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px dashed var(--rule-strong); border-radius: 4px; background: rgba(239, 235, 226, .5);
  transition: border-color .2s, background-color .2s, transform .28s var(--ease), box-shadow .28s var(--ease);
}
#sign.is-over .sg-drop { border-color: var(--clay-deep); border-style: solid; background-color: var(--clay-wash); transform: translateY(-3px); box-shadow: 0 18px 36px -18px rgba(31, 29, 26, .35); }
#sign .sg-drop-art { width: 124px; height: auto; overflow: visible; }
#sign .sg-a-sheet { fill: var(--cream); stroke: var(--ink); stroke-width: 1.1; }
#sign .sg-a-lines { fill: none; stroke: var(--rule-strong); stroke-width: 1.1; stroke-linecap: round; }
#sign .sg-a-rule { fill: none; stroke: var(--ink); stroke-width: .9; }
#sign .sg-a-ink { fill: none; stroke: var(--clay-deep); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 120; stroke-dashoffset: 0; animation: sg-write 1.5s var(--ease) .25s both; }
@keyframes sg-write { from { stroke-dashoffset: 120; } to { stroke-dashoffset: 0; } }
#sign .sg-drop-title { margin-top: 18px; font-family: var(--serif); font-size: 26px; line-height: 1.2; }
#sign .sg-choose { margin-top: 18px; min-height: 52px; padding: 12px 34px; font-size: 17px; }
#sign .sg-drop-sub { margin-top: 14px; color: var(--ink-soft); font-size: 14px; }
#sign .sg-sample { margin-top: 6px; font-size: 14px; }

/* ---------- the bar of things to add ---------- */
#sign .sg-bar {
  position: sticky; top: 0; z-index: 20;
  margin: 18px calc(var(--pad) * -1) 0; padding: 10px var(--pad) 9px;
  background: var(--cream); border-bottom: 1px solid var(--rule-strong);
  box-shadow: 0 14px 22px -20px rgba(31, 29, 26, .5);
}
#sign .sg-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#sign .sg-add { margin-right: 4px; }
#sign .sg-tool { gap: 6px; min-height: 38px; padding: 6px 12px; font-size: 14px; }
#sign .sg-tool svg, #sign .sg-itembar svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#sign .sg-tool[data-kind="sig"] { border-color: var(--ink); font-weight: 600; }
#sign .sg-tool[aria-pressed="true"] { background: var(--ink); color: var(--cream); border-color: var(--ink); }
#sign .sg-hintrow { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 14px; margin-top: 7px; }
#sign .sg-change { flex: none; min-height: 26px; padding: 0 2px; font-size: 13px; }
#sign .sg-hint { flex: 1 1 auto; min-width: 0; font-family: var(--serif); font-style: italic; font-size: 16px; line-height: 1.3; color: var(--ink-soft); min-height: 1.3em; }
#sign.is-armed .sg-hint { color: var(--clay-deep); }

/* ---------- pages ---------- */
#sign .sg-pages {
  margin: 0 calc(var(--pad) * -1); padding: 26px var(--pad) 8px;
  background: rgba(31, 29, 26, .055);
  display: grid; gap: 14px; justify-items: center;
}
#sign .sg-sheet { width: 100%; max-width: 820px; min-width: 0; }
#sign .sg-page {
  position: relative; width: 100%; background: var(--cream);
  box-shadow: 0 0 0 1px rgba(31, 29, 26, .14), 0 1px 2px rgba(31, 29, 26, .12), 0 12px 26px -14px rgba(31, 29, 26, .4);
}
@supports not (aspect-ratio: 1) { #sign .sg-page { height: 0; padding-bottom: calc(var(--ratio) * 100%); } }
#sign .sg-page:not(.is-ready) { background: repeating-linear-gradient(to bottom, transparent 0 17px, var(--rule) 17px 18px) 12% 8% / 76% 46% no-repeat, var(--cream); }
#sign .sg-page.is-failed::after { content: "This page could not be shown."; position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-soft); font-size: 14px; }
#sign .sg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#sign .sg-layer { position: absolute; inset: 0; -webkit-tap-highlight-color: transparent; }
#sign.is-armed .sg-layer { cursor: copy; }
#sign .sg-num { margin: 10px 0 12px; text-align: center; font-size: 12.5px; line-height: 1; color: var(--ink-soft); font-variant-numeric: lining-nums tabular-nums; }

/* ---------- placed items ---------- */
#sign .sg-item {
  position: absolute; z-index: 2; box-sizing: border-box; cursor: grab;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  outline: 1px dashed transparent; outline-offset: 3px;
}
#sign .sg-item:hover { outline-color: var(--rule-strong); }
#sign .sg-item.is-sel { z-index: 3; outline: 1.5px solid var(--clay-deep); }
#sign .sg-item:focus-visible { outline: 2px solid var(--clay-deep); }
#sign .sg-item.is-moving { cursor: grabbing; }
#sign .sg-item img { display: block; width: 100%; height: 100%; pointer-events: none; }
#sign .sg-text { font-family: Helvetica, Arial, "Liberation Sans", sans-serif; white-space: pre; color: #141414; font-kerning: none; font-variant-ligatures: none; letter-spacing: 0; -webkit-font-smoothing: auto; }
#sign .sg-t { position: absolute; left: 0; top: 0; display: block; width: max-content; font-size: 64px; line-height: 1.2; transform-origin: 0 0; pointer-events: none; }  /* 64px = EM in sign.js */
#sign .sg-t.is-empty { color: var(--ink-faint); }
#sign .sg-h {
  position: absolute; display: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--cream); border: 1.5px solid var(--clay-deep); touch-action: none;
}
#sign .sg-item.is-sel .sg-h { display: block; }
#sign .sg-h::after { content: ""; position: absolute; }                     /* a finger-sized target that reaches outwards, not inwards */
#sign .sg-h-nw { left: -10px; top: -10px; cursor: nwse-resize; }  #sign .sg-h-nw::after { inset: -18px -5px -5px -18px; }
#sign .sg-h-ne { right: -10px; top: -10px; cursor: nesw-resize; } #sign .sg-h-ne::after { inset: -18px -18px -5px -5px; }
#sign .sg-h-sw { left: -10px; bottom: -10px; cursor: nesw-resize; } #sign .sg-h-sw::after { inset: -5px -5px -18px -18px; }
#sign .sg-h-se { right: -10px; bottom: -10px; cursor: nwse-resize; } #sign .sg-h-se::after { inset: -5px -18px -18px -5px; }

#sign .sg-itembar {
  position: absolute; z-index: 6; display: flex; align-items: stretch; gap: 2px; padding: 3px;
  background: var(--ink); color: var(--cream); border-radius: 4px; box-shadow: 0 8px 20px -8px rgba(31, 29, 26, .6);
  cursor: default; white-space: nowrap;
}
#sign .sg-itembar button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 2px;
  background: transparent; color: inherit; font-size: 13px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#sign .sg-itembar button:hover { background: rgba(247, 244, 236, .16); }
#sign .sg-itembar button:focus-visible { outline: 2px solid var(--cream); outline-offset: -2px; }
#sign .sg-itembar.has-edit button span { display: none; }
#sign .sg-edit { width: 178px; min-height: 36px; padding: 4px 9px; border: 0; border-radius: 2px; background: var(--cream); color: var(--ink); font-size: 16px; }
#sign .sg-edit:focus-visible { outline: 2px solid var(--clay); outline-offset: 0; }

/* ---------- download bar ---------- */
#sign .sg-actions {
  position: sticky; bottom: 0; z-index: 20;
  margin: 0 calc(var(--pad) * -1); padding: 12px var(--pad) 14px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px;
  background: var(--cream); border-top: 1px solid var(--rule-strong); box-shadow: 0 -14px 26px -20px rgba(31, 29, 26, .45);
}
#sign .sg-file { min-width: 0; font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 120px; }
#sign #sign-download { min-height: 46px; padding: 10px 26px; font-size: 16px; }

/* ---------- done ---------- */
#sign .sg-done { margin-top: 22px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 20px; align-items: center; animation: rise .4s var(--ease) both; }
#sign .sg-done:focus { outline: none; }
#sign .sg-done-mark { width: 44px; height: 44px; fill: none; stroke: var(--olive); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#sign .sg-done-title { font-family: var(--serif); font-weight: 700; font-size: 32px; line-height: 1.1; }
#sign .sg-done-file { margin-top: 4px; font-family: var(--serif); font-size: 17px; overflow-wrap: anywhere; }
#sign .sg-done-file span { color: var(--ink-soft); white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
#sign .sg-done-file span::before { content: "· "; }
#sign .sg-done .note { margin-top: 4px; }
#sign .sg-done-btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--rule); }

/* ---------- 2. the signature panel ---------- */
#sign .sg-dialog {
  width: min(620px, calc(100vw - 24px)); max-width: none; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--rule-strong); border-radius: 4px; overflow: auto; overscroll-behavior: contain;
  background: var(--cream); color: var(--ink); box-shadow: 0 30px 70px -20px rgba(31, 29, 26, .6);
}
#sign .sg-dialog:not([open]) { display: none; }
#sign .sg-dialog::backdrop { background: rgba(31, 29, 26, .5); }
#sign .sg-dlg { display: grid; gap: 16px; padding: 20px 24px 22px; outline: none; }
#sign .sg-dlg .field > .seg { align-self: flex-start; }
#sign .sg-dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#sign .sg-dlg-title { font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1.1; }
#sign .sg-mode { display: grid; gap: 12px; }
#sign .sg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#sign .sg-pad-wrap { position: relative; border: 1px solid var(--rule-strong); border-radius: 3px; background: rgba(255, 255, 255, .62); overflow: hidden; }
#sign .sg-pad { display: block; width: 100%; height: clamp(170px, 32vh, 240px); touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#sign .sg-pad-line { position: absolute; left: 7%; right: 7%; bottom: 27%; border-bottom: 1px dashed var(--rule-strong); pointer-events: none; }
#sign .sg-pad-hint { position: absolute; left: 0; right: 0; bottom: calc(27% + 12px); text-align: center; font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--ink-faint); pointer-events: none; }
#sign .sg-typed { min-height: 96px; padding: 10px 12px; display: grid; place-items: center; text-align: center; border: 1px solid var(--rule-strong); border-radius: 3px; background: rgba(255, 255, 255, .62); font-family: var(--serif); font-style: italic; line-height: 1.15; overflow-wrap: anywhere; }
#sign .sg-typed.is-empty { color: var(--ink-faint) !important; }
#sign .sg-photo { padding: 12px; display: grid; place-items: center; border: 1px solid var(--rule-strong); border-radius: 3px; background: rgba(255, 255, 255, .62); }
#sign .sg-photo canvas { display: block; max-width: 100%; max-height: 170px; }
#sign .sg-range { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
#sign .sg-range input { flex: 1; min-width: 0; height: 32px; accent-color: var(--clay-deep); }
#sign .sg-swatch { align-self: center; width: 10px; height: 10px; border-radius: 50%; opacity: 1; box-shadow: 0 0 0 1px rgba(247, 244, 236, .7); }
#sign .sg-remember { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--rule); }
#sign .sg-check { display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 14px; cursor: pointer; }
#sign .sg-check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--clay-deep); }
#sign .sg-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--ink-soft); }
#sign .sg-dlg-error { padding: 9px 12px; background: var(--clay-wash); border-left: 2px solid var(--clay-deep); font-size: 14px; }
#sign .sg-dlg-foot { display: flex; justify-content: flex-end; }
#sign .sg-dlg-foot .btn { min-height: 48px; padding: 10px 28px; font-size: 16px; }

/* ---------- narrower screens ---------- */
@media (max-width: 720px) {
  #sign .sg-drop { padding: 30px 14px 28px; }
  #sign .sg-drop-art { width: 104px; }
  #sign .sg-drop-title { font-size: 22px; }
  #sign .sg-choose { width: 100%; max-width: 320px; }
  #sign .sg-bar { padding-top: 8px; padding-bottom: 7px; }
  #sign .sg-add, #sign .sg-wide-only { display: none; }
  #sign .sg-tools { gap: 5px; flex-wrap: nowrap; }
  #sign .sg-tool { flex: 1 1 auto; min-width: 44px; min-height: 44px; padding: 6px 7px; gap: 5px; font-size: 13.5px; }
  #sign .sg-tool[data-kind="tick"], #sign .sg-tool[data-kind="cross"] { flex: 0 1 46px; }
  #sign .sg-hintrow { align-items: center; margin-top: 3px; min-height: 44px; }
  #sign .sg-change { min-height: 44px; }
  #sign .sg-hint { font-size: 15px; }
  #sign .sg-check { min-height: 44px; }
  #sign .sg-range input { height: 44px; }
  #sign .sg-itembar button { min-height: 44px; min-width: 44px; }
  #sign .sg-edit { min-height: 44px; }
  #sign .sg-pages { padding: 12px 6px 4px; gap: 6px; }
  #sign .sg-actions { padding: 10px var(--pad) 12px; }
  #sign .sg-file { flex-basis: 100%; }
  #sign #sign-download { flex: 1 1 auto; }
  #sign .sg-itembar button span { display: none; }
  #sign .sg-itembar button { justify-content: center; }
  #sign .sg-edit { width: 150px; }
  #sign .sg-done-btns .btn { flex: 1 1 auto; }
  #sign .sg-dialog { width: 100vw; margin: auto 0 0; border-width: 1px 0 0; border-radius: 12px 12px 0 0; max-height: 96vh; max-height: 96dvh; }
  #sign .sg-dlg { gap: 13px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  #sign .sg-dlg-title { font-size: 22px; }
  #sign .sg-pad { height: clamp(170px, 30vh, 220px); }
  #sign .sg-dlg-foot .btn { width: 100%; }
}
@media (max-width: 400px) {
  #sign .sg-tool[data-kind="text"] svg, #sign .sg-tool[data-kind="date"] svg { display: none; }
}
@media (hover: none) {          /* fingers: a 44px target on each corner, reaching outwards */
  #sign .sg-h-nw::after { inset: -24px -8px -8px -24px; }
  #sign .sg-h-ne::after { inset: -24px -24px -8px -8px; }
  #sign .sg-h-sw::after { inset: -8px -8px -24px -24px; }
  #sign .sg-h-se::after { inset: -8px -24px -24px -8px; }
}
@media print {
  #sign .sg-bar, #sign .sg-actions, #sign .sg-drop, #sign .sg-itembar, #sign .sg-h { display: none; }
}
