/* sign.css - v6.24 Aventa Sign: the signing window and the saved signatures.
 *
 * Loaded right after workspace.css. New base rules stay LESS specific than the
 * hover and active states index.html and workspace.css already define (the
 * v4.1 lesson: a reset at (0,2,0) once erased the nav highlight everywhere).
 *
 * The stamp and the style cards show what is PRINTED, so they use the print
 * colours (#15803D tick and words, #14213D ink, white tiles) in every theme;
 * every other surface uses the app's tokens, and text the ink tokens.
 */

/* The two handwriting faces (three until v6.27, when the initials in Caveat
 * took Sacramento's place), self-hosted and unmodified under their SIL Open
 * Font License (frontend/fonts/<face>/OFL.txt): fetched from Google they would
 * send each colleague's address to Google. Used only to create a signature;
 * once saved, signing never needs a font again. */
@font-face {
  font-family: 'Caveat';
  src: url('../fonts/caveat/Caveat.ttf') format('truetype');
  font-weight: 400 700;
  font-display: block;
}
@font-face {
  font-family: 'Dancing Script';
  src: url('../fonts/dancingscript/DancingScript.ttf') format('truetype');
  font-weight: 400 700;
  font-display: block;
}

/* "My signature" sits beside Sign out and reads like it (.sign-out in
 * index.html); it is a button, so its default chrome goes. */
.sign-mine { border: none; background: none; padding: 0; cursor: pointer; font-family: inherit; }

/* Above the journey modal it opens from (2000), below the confirmation it asks
 * through (2050), the toast (2100) and the popover menus (2300). */
#sign-modal { z-index: 2040; }

.sign-dialog {
  background: var(--white); border-radius: 16px;
  width: 1000px; max-width: calc(100vw - 32px);
  max-height: 94vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.sign-doc {
  font-size: 12px; color: var(--grey); margin: 0 10px;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sign-body { padding: 14px 20px 18px; overflow-y: auto; }
.sign-body h3 { font-size: 13px; margin: 14px 0 6px; color: var(--dark); }
.sign-body h3:first-child { margin-top: 0; }
.sign-note { font-size: 12.5px; color: var(--dark); line-height: 1.5; margin: 0 0 10px; }
.sign-status { min-height: 1em; font-size: 12.5px; line-height: 1.5; margin: 10px 0 0; color: var(--dark); }
.sign-status.is-error { color: var(--danger-ink); font-weight: 600; }
/* v6.24.7: the browser sign-in button after its sentence (js/sign.js setStatus). */
.sign-status .sign-signin { margin-left: 8px; font-weight: 600; }
.sign-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sign-actions .btn-rd { flex: 0 1 auto; }
.sign-link {
  border: none; background: none; padding: 0; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--accent-ink); text-decoration: underline;
}

/* ── the place pane ───────────────────────────────────────────────────────── */
.sign-place { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; }
@media (max-width: 820px) { .sign-place { grid-template-columns: minmax(0, 1fr); } }
.sign-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sign-page-label { font-size: 12.5px; color: var(--dark); }
.sign-toolbar .btn-rd { flex: 0 0 auto; padding: 6px 10px; }

/* v6.24.2 (item 17): the page zooms from half to three times the fit; zoomed
 * in, it scrolls inside this box, both ways. */
.sign-viewport { overflow: auto; max-height: 70vh; overscroll-behavior: contain; }
.sign-stage {
  position: relative; background: #fff; margin: 0 auto;
  border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  cursor: crosshair; user-select: none;
  /* A swipe that starts on the page scrolls the window (or a zoomed page) on
   * a phone; only a tap places a stamp (sign.js), and a stamp never scrolls. */
  touch-action: pan-x pan-y pinch-zoom;
}
.sign-stage > img.sign-page { display: block; width: 100%; height: 100%; pointer-events: none; }
.sign-outline { position: absolute; border: 1px dashed rgba(0, 82, 204, .55); pointer-events: none; }

/* The stamp: the server's proportions (--pad-x and the rest, set on the stage
 * from the layout's geometry) in container units of the stamp's own width, so
 * the preview and the PDF share one set of numbers. Down the stamp: the mark,
 * the green tick and "Electronically signed by Aventa Sign", the date line.
 * No border, no fill: only the mark, the tick and the words reach the page. */
.sign-stamp {
  position: absolute; container-type: inline-size; cursor: move;
  outline: none; touch-action: none;
}
.sign-stamp.is-selected { box-shadow: 0 0 0 2px var(--blue); }
.sign-stamp:focus-visible { box-shadow: 0 0 0 3px var(--accent-ink); }
.sign-stamp img.sign-mark {
  display: block; width: calc(100cqw - 2 * var(--pad-x) * 100cqw);
  margin: calc(var(--pad-top) * 100cqw) calc(var(--pad-x) * 100cqw) 0;
  pointer-events: none;
}
/* The line under the mark (v6.24.3, D10), as wide as the mark, in the
 * signer's ink. At least one pixel, so a small preview still shows it. */
.sign-stamp .sign-rule {
  height: max(1px, calc(var(--rule-stroke) * 100cqw));
  margin: calc(var(--mark-gap) * 100cqw) calc(var(--pad-x) * 100cqw) 0;
  background: #14213D; pointer-events: none;
}
/* The tick row, its height the disc's; the words in the print green, which is
 * 5.0:1 on white (WCAG AA for text). */
.sign-signed {
  display: flex; align-items: center; justify-content: center;
  height: calc(var(--tick-size) * 100cqw); margin-top: calc(var(--rule-gap) * 100cqw);
  gap: calc(var(--tick-gap) * 100cqw);
  font: 400 calc(var(--line-size) * 100cqw) / 1 Helvetica, Arial, sans-serif;
  color: #15803D; white-space: nowrap;
}
.sign-signed .sign-tick {
  flex: none; display: block;
  width: calc(var(--tick-size) * 100cqw); height: calc(var(--tick-size) * 100cqw);
}
.sign-date {
  margin-top: calc(var(--date-gap) * 100cqw); text-align: center;
  font: calc(var(--date-size) * 100cqw) / 1.2 Helvetica, Arial, sans-serif; color: #14213D;
}
.sign-grip {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: var(--blue); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize;
}

.sign-side ul { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sign-side li { font-size: 12.5px; color: var(--dark); }
.sign-side label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.sign-chosen li {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
}
.sign-chosen li.is-selected { border-color: var(--accent-ink); }
.sign-chosen select { font-family: inherit; font-size: 12.5px; padding: 4px 6px; max-width: 100%; }
.sign-hint { font-size: 11.5px; color: var(--grey); line-height: 1.5; margin: 8px 0 0; }

/* ── the saved signatures and the add pane ───────────────────────────────── */
.sign-marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.sign-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px; background: var(--white);
}
.sign-card-img {
  background: #fff; border-radius: 6px; height: 70px;
  display: flex; align-items: center; justify-content: center;
}
.sign-card-img img { max-width: 100%; max-height: 60px; }
.sign-card .meta { font-size: 11.5px; color: var(--grey); }
/* The Default label sits on the Delete button's row, as tall as the button
 * and centred in it (v6.24.2, item 8). */
.sign-card .sign-actions { align-items: stretch; flex-wrap: nowrap; }
.sign-badge {
  font-size: 11px; font-weight: 700; color: var(--accent-ink);
  display: inline-flex; align-items: center;
}

.sign-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.sign-tabs button[aria-selected="true"] { border-color: var(--accent-ink); color: var(--accent-ink); }
.sign-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12.5px; color: var(--dark); }
.sign-field input[readonly] { background: var(--surface); color: var(--dark); cursor: default; }
/* Each Add tab's controls in one box that holds its margins, so "Make it my
 * default signature" sits the same clear gap under the faces, the Clear
 * button or Choose an image (v6.24.2, item 8). */
.sign-tab-body { display: flow-root; }
.sign-tab-body > :last-child { margin-bottom: 0; }
.sign-default-opt { flex-direction: row; align-items: center; margin-top: 18px; }
.sign-size-scope { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--dark); }
/* v6.27: Smaller and Larger sat almost on the "Also write the date and time"
   box beneath them; the row keeps clear space under it, on a phone too. */
.sign-side .sign-size { margin-bottom: 14px; }
.sign-field input[type="text"] {
  font-family: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--dark);
}
.sign-styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 620px) { .sign-styles { grid-template-columns: minmax(0, 1fr); } }
.sign-style {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; background: var(--white);
}
.sign-style:has(input:checked) { border-color: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent-ink); }
.sign-style .sample {
  background: #fff; color: #14213D; border-radius: 6px; padding: 6px 8px;
  font-size: 30px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sign-style.is-unavailable { opacity: .55; cursor: default; }
.sign-pad {
  display: block; width: 100%; height: 180px; background: #fff; touch-action: none;
  border: 1px dashed var(--border); border-radius: 8px; cursor: crosshair;
}
/* v6.24.1: an uploaded signature, previewed on white as the document page
 * shows it (the print navy would vanish on the dark themes' surface). */
.sign-upload-preview {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin: 10px 0 12px; display: flex; justify-content: center;
}
.sign-upload-preview img { display: block; max-width: 100%; max-height: 120px; }

@media (prefers-reduced-motion: reduce) {
  #sign-modal .sign-dialog { animation: none; }
}
