/* r18 — one shell for the three document screens (Design with AI /simple, Fill a form /fill, Sign a PDF
   /fill?sign=1). Amit, 24 Nov: "the three screens should be similar … options standardised, download with
   a download icon, sign with a sign icon, new with a plus … sticky at the top so I don't have to scroll
   up to sign … the AI editor at the bottom, sticky … the Change it button in sync with the box".
   Loaded after each page's own styles, so these win where the pages had drifted apart. */

/* one width: the summary card ("You asked" / "Your files" / "Your PDF") lines up with the document */
@media (min-width: 900px) {
  main:has(> #step-doc) { max-width: 1260px; }
  main:has(> #step-doc) > .lead, main:has(> #step-doc) > #step-files, main:has(> #step-doc) > #step-ask, main:has(> #step-doc) > #step-q { max-width: none !important; }
}

/* the toolbar: the same buttons, each with its icon, in the same order on every screen */
.doc-bar .acts .btn { display: inline-flex; align-items: center; gap: 6px; }
.doc-bar .acts .btn svg { flex: none; width: 16px; height: 16px; }
.doc-bar .acts .btn-primary svg { color: currentColor; }

/* sticky at the top while the document scrolls: the actions, and the signature bar under them */
#step-doc { overflow: visible; }
#step-doc .doc-bar {
  position: sticky; top: 0; z-index: 25;
  margin: -16px -16px 0; padding: 12px 16px;
  background: var(--so-paper-000, #fff);
  border-radius: var(--so-r-md, 12px) var(--so-r-md, 12px) 0 0;
  box-shadow: 0 1px 0 var(--so-stone-200, #e6e1d6), 0 6px 14px -8px rgba(11, 29, 50, .18);
}
#step-doc .sigrow { position: static; }   /* r22: the signature lives in the left panel, which is sticky itself */
#step-doc #doc-st:empty { display: none; }
#step-doc .view .stage { margin-left: auto; margin-right: auto; }
#step-doc .place-bar { position: sticky; top: 64px; z-index: 24; }

/* the AI box: sticky at the bottom, its button exactly as tall as the box */
#step-doc .ai-box {
  position: sticky; bottom: 0; z-index: 25;
  margin: 12px -16px -16px; padding: 10px 16px 14px;
  background: var(--so-paper-000, #fff);
  border-radius: 0 0 var(--so-r-md, 12px) var(--so-r-md, 12px);
  box-shadow: 0 -1px 0 var(--so-stone-200, #e6e1d6), 0 -8px 16px rgba(11, 29, 50, .04);
}
/* on the form page the box sits in the document's column, beside the send panel */
#step-doc .doc-main .ai-box { margin: 12px 0 -16px; padding: 10px 0 14px; border-radius: 0; box-shadow: 0 -1px 0 var(--so-stone-200, #e6e1d6); }
#step-doc .ai-box .lbl { margin-top: 0; }
#step-doc .edit-row { align-items: stretch; margin-top: 6px; }
#step-doc .edit-row .btn { align-self: stretch; min-height: 48px; height: auto; }

@media (max-width: 560px) {
  #step-doc .doc-bar { margin: -12px -12px 0; padding: 10px 12px; }
  #step-doc .doc-bar h2 { display: none; }
  /* one row on a phone: each icon with a short word under it (Amit, 26 Nov: "a viewer can't tell Save
     from Download from Sign"); data-s is the short word where the full one won't fit a quarter of 375px */
  #step-doc .doc-bar .acts { flex-wrap: nowrap; width: 100%; justify-content: space-between; gap: 6px; margin-left: 0; }
  #step-doc .doc-bar .acts .btn { flex: 1 1 0; min-width: 0; height: 52px; min-height: 52px; padding: 4px 2px; flex-direction: column; justify-content: center; gap: 3px; }
  #step-doc .doc-bar .acts .btn span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font: 600 11px/14px var(--so-font, Montserrat, "Avenir Next", system-ui); letter-spacing: .01em; }
  #step-doc .doc-bar .acts .btn span[data-s] { font-size: 0; line-height: 0; }
  #step-doc .doc-bar .acts .btn span[data-s]::after { content: attr(data-s); font-size: 11px; line-height: 14px; }
  #step-doc .doc-bar .acts .btn svg { width: 20px; height: 20px; }
  #step-doc .sigrow, #step-doc .place-bar { position: static; }
  #step-doc .ai-box { margin: 12px -12px -12px; padding: 8px 12px 12px; }
  #step-doc .doc-main .ai-box { margin: 12px 0 -12px; padding: 8px 0 12px; }
  #step-doc .edit-row { flex-direction: row; }
  #step-doc .edit-row textarea { min-height: 76px; }   /* the placeholder's lines fit */
  #step-doc .edit-row .btn { align-self: stretch; }
}

/* the cloud row under each upload box: Google Drive and Dropbox, by their marks */
.so-cloud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.so-cloud[hidden] { display: none; }
.so-cloud button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--so-stone-300, #d9d3c7); border-radius: var(--so-r-pill, 999px);
  background: var(--so-paper-000, #fff); color: var(--so-ink-900);
  font: 600 13px var(--so-font, system-ui); cursor: pointer;
}
.so-cloud button:hover { border-color: var(--so-ink-500, #6b7686); }
.so-cloud button:focus-visible { outline: 2px solid var(--so-navy-900, #0b1d32); outline-offset: 2px; }
.so-cloud svg { width: 18px; height: 18px; flex: none; }

/* r18c (site QC behind the login): the way back is the header's icon button on every page; the
   in-page "< Documents" links it replaced are hidden */
@media (max-width: 480px) { .back-docs, .sl-back { display: none !important; } }
/* the signature buttons stay on one row once a signature is placed (Add it again · Change · Remove) */
@media (max-width: 560px) {
  #step-doc .sigrow:has(#sig-rm:not([hidden])) .sw { flex: 0 0 56px; padding: 0 2px; }
  #step-doc .sigrow:has(#sig-rm:not([hidden])) .sw img { max-width: 52px; }
  #step-doc .sigrow:has(#sig-rm:not([hidden])) .btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 13px; white-space: normal; line-height: 1.15; text-align: center; }   /* r20b: "Add it again" wraps rather than clipping */
}
