/* The document views: the two-column layout, the pages and their fields, the narrow bottom bar, the menu and dialogs.
   Width decisions read the page's own width (the .sg-shell container), so a 600px side panel gets the narrow layout too. */

@font-face { font-family: "Dancing Script"; src: url(fonts/dancing-script.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(fonts/caveat.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Homemade Apple"; src: url(fonts/homemade-apple.woff2) format("woff2"); font-weight: 400; font-display: swap; }
.sg-script { font-family: "Dancing Script", cursive; }

/* wide: document left, side column right */
.sg-wrap { max-width: 64rem; margin: 0 auto; padding: 24px 24px 32px; }
.sg-cols { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 24px; align-items: start; }
.sg-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sg-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sg-back { align-self: flex-start; margin: -8px 0 12px -8px; }
.sg-msg-top { display: none; }
.sg-msg-top:empty { display: none; }
.sg-sign-card .sg-btn.wide { height: 44px; }

/* the pages tray: each page drawn at the tray's width (viewer.mjs), fields in percent of the page */
.sg-pages { background: var(--card); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sg-pagewrap { position: relative; margin: 0 auto; max-width: 100%; background: #fff; box-shadow: 0 1px 3px oklch(30% .03 60 / .14); container-type: inline-size; }
.sg-pagewrap canvas { display: block; }

/* text in a field scales with the page (1.6% of its width), so it stays inside its box at any size */
.sg-field { position: absolute; display: flex; align-items: center; justify-content: center; box-sizing: border-box; border-radius: 4px; overflow: hidden; font-size: clamp(7px, 1.6cqw, 15px); font-weight: 500; }
.sg-field.mine { border: 1.5px solid var(--brand); background: color-mix(in oklch, var(--brand) 9%, transparent); color: var(--brand); cursor: pointer; }
.sg-field.mine.next { box-shadow: 0 0 0 4px color-mix(in oklch, var(--brand) 22%, transparent); }
.sg-field.mine.filled { border-color: var(--ok-ink); background: color-mix(in oklch, var(--ok) 10%, transparent); color: var(--ok-ink); }
.sg-field.other { border: 1px dashed color-mix(in oklch, var(--ink) 30%, transparent); color: var(--muted); cursor: default; }
.sg-field input { width: 100%; height: 100%; border: 0; background: transparent; padding: 0 .4em; font-size: inherit; color: var(--ink); outline: none; }
.sg-field input:focus { background: color-mix(in oklch, var(--brand) 6%, #fff); }
.sg-field img { max-width: 100%; max-height: 100%; }
.sg-flabel { padding: 0 3px; text-align: center; pointer-events: none; }
.sg-flabel.sg-script { font-size: 2em; color: var(--ink); }
.sg-tag { position: absolute; left: 0; z-index: 2; transform: translateY(-50%); padding: 4px 8px 4px 6px; border-radius: 0 6px 6px 0; background: var(--brand); color: var(--bg); font-size: 11px; font-weight: 600; pointer-events: none; }
.sg-tag::after { content: ""; position: absolute; right: -7px; top: 0; width: 8px; height: 100%; background: var(--brand); clip-path: polygon(0 0, 100% 50%, 0 100%); }

/* field progress */
.sg-progress, [data-progress] { display: flex; flex-direction: column; gap: 6px; }
.sg-bar { height: 6px; border-radius: 999px; background: var(--card); overflow: hidden; }
.sg-bar > span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--brand); transition: width .2s ease; }

/* the narrow bottom bar: progress, details, Sign or Finish */
.sg-mbar { display: none; position: sticky; bottom: 0; z-index: 5; align-items: center; gap: 8px; padding: 12px; background: var(--panel); border-top: 1px solid var(--line); }

/* the "..." menu */
.sg-menu-wrap { position: relative; flex: none; }
.sg-menu { position: absolute; right: 0; top: 40px; z-index: 30; width: 14rem; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px -8px oklch(30% .03 60 / .25); }
.sg-menu a, .sg-menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; text-decoration: none; cursor: pointer; font-size: 14px; }
.sg-menu a:hover, .sg-menu button:hover { background: var(--card); }
.sg-menu .sg-ic { color: var(--muted); }

/* dialogs */
.sg-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; background: oklch(20% .02 60 / .4); }
.sg-dialog { width: min(28rem, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 16px; padding: 24px; background: var(--panel); border-radius: 24px; box-shadow: 0 24px 56px -8px oklch(20% .02 60 / .3); }
.sg-dialog:focus { outline: none; }
.sg-btn.sg-muted { color: var(--muted); }
.sg-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sg-dialog [hidden] { display: none; }
.tabs.sg-tabs { margin: 0; }
.sg-pad { display: block; width: 100%; height: 160px; border: 1px solid var(--line); border-radius: 14px; background: #fff; touch-action: none; cursor: crosshair; }
[data-pane] .sg-row-end { margin-top: 8px; }
.sg-hands { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sg-hand { display: flex; align-items: center; height: 56px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font-size: 26px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; }
.sg-hand[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.sg-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 160px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 12.5px; cursor: pointer; text-align: center; padding: 8px; }
.sg-drop img { max-width: 100%; max-height: 90px; }
.sg-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.sg-hint a, .sg-consent a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.sg-review-mark { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; border-radius: 14px; background: var(--card); }
.sg-review-mark[hidden] { display: none; }
.sg-mark-img { max-height: 56px; max-width: 70%; }
.sg-mark-text { font-size: 26px; }
.sg-consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.sg-consent input { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--ink); }

/* narrow (the page's own width): one column, document full width, side cards behind the bottom bar's "..." */
@container (max-width: 860px) {
  .sg-wrap { padding: 12px; }
  .sg-cols { display: flex; flex-direction: column-reverse; align-items: stretch; gap: 12px; }
  .sg-signing .sg-cols { display: block; }
  .sg-signing .sg-side { display: none; }
  .sg-side { position: static; gap: 12px; }
  .sg-signing .sg-msg-top { display: flex; flex-direction: column; gap: 12px; }
  .sg-signing .sg-msg-top:empty { display: none; }
  .sg-mbar { display: flex; }
  .sg-pages { padding: 8px; gap: 8px; border-radius: 14px; }
  .sg-with { display: none; }
  .sg-top { padding: 12px; }
  .sg-back { margin: 0 0 8px; }
}

/* Print: only the pages */
@media print {
  .sg-top, .sg-foot, .sg-side, .sg-mbar, .sg-msg-top, .sg-back, .sg-tag, .sg-overlay { display: none; }
  .sg-cols { display: block; }
  .sg-wrap { padding: 0; max-width: none; }
  .sg-pages { background: none; padding: 0; gap: 0; }
  .sg-pagewrap { box-shadow: none; break-after: page; }
}
