/* Add signature: signature panel + a large page with draggable signature boxes.
   Uses stamp.css for the form bits (.seg, .opt, .stamp-check, .stamp-input). Colours only from style.css variables. */

.sign-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); grid-template-areas: "view panel"; gap: 24px; align-items: start; }
.sign-panel { grid-area: panel; display: grid; gap: 16px; min-width: 0; }
.sign-view { grid-area: view; min-width: 0; }

.sign-block { display: grid; gap: 10px; min-width: 0; }
.sign-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sign-modes label { flex: 1 1 auto; }

/* Drawing pad: a white sheet (painted by the script) with a guide line */
.sign-padwrap { position: relative; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.sign-pad { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.sign-padline { position: absolute; left: 8%; right: 8%; bottom: 30%; border-bottom: 1px dashed var(--line-strong); pointer-events: none; }
.sign-padhint { position: absolute; left: 8%; bottom: calc(30% + 8px); font-size: 14px; color: var(--muted); pointer-events: none; }

/* Font choice: each option shows the name in that font */
.sign-fonts { display: grid; gap: 6px; }
.sign-fonts label { justify-content: flex-start; min-height: 54px; padding: 0 16px; overflow: hidden; }
.sign-fontname { font-size: 26px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sign-fonts input:checked + label { font-weight: 400; }

.sign-samplewrap { border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.sign-sample { display: block; width: 100%; height: 110px; }

.sign-place { width: 100%; border-color: var(--accent); color: var(--accent); }
.sign-place:hover { background: var(--accent-soft); border-color: var(--accent); }

.sign-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sign-list li { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.sign-list li > span { flex: 1; min-width: 0; }
.sign-show { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* Page viewer */
.sign-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.sign-pagelabel { min-width: 9em; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sign-stage { display: grid; place-items: center; padding: 16px; border-radius: 12px; background: var(--soft); }
.sign-sheet { position: relative; width: 100%; background: var(--card); box-shadow: var(--shadow); }
.sign-sheet > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sign-sheet > .spin { position: absolute; left: 50%; top: 50%; margin: -11px 0 0 -11px; }
.sign-layer { position: absolute; inset: 0; }
.sign-hint { margin-top: 8px; text-align: center; }

/* A placed signature */
.sign-box { position: absolute; touch-action: none; cursor: move; outline: 1.5px dashed var(--accent); border-radius: 2px; -webkit-user-select: none; user-select: none; }
.sign-box img { display: block; width: 100%; height: 100%; pointer-events: none; }
.sign-box:focus-visible, .sign-box.moving, .sign-box:focus { outline: 2px solid var(--accent); outline-offset: 0; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.sign-handle { position: absolute; right: -16px; bottom: -16px; width: 32px; height: 32px; display: grid; place-items: center; cursor: nwse-resize; touch-action: none; }
.sign-handle::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); box-shadow: var(--shadow); }
.sign-del { position: absolute; right: -14px; top: -14px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--card); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
.sign-del svg { width: 14px; height: 14px; }
.sign-del:hover { color: var(--danger); background: var(--danger-soft); }

@media (pointer: coarse) {
  .sign-handle { right: -22px; bottom: -22px; width: 44px; height: 44px; }
  .sign-handle::before { width: 18px; height: 18px; }
  .sign-del { width: 34px; height: 34px; right: -17px; top: -17px; }
}

@media (max-width: 860px) {
  .sign-grid { grid-template-columns: 1fr; grid-template-areas: "panel" "view"; gap: 20px; }
  .sign-stage { padding: 10px; }
}
