/* sign_pdf: Sign a PDF (/tools/sign-pdf, marketing/office_tools/sign_pdf.html.erb,
   controllers/sign_pdf_controller.js). Prefix .ot-sign-. Shared pieces are in
   ../office_tools.css. The handwriting fonts are vendored next to this file's
   logical path (app/assets/fonts/office_tools, see LICENSES.md there) and are
   only downloaded when a typed signature style is shown. */

@font-face { font-family: "Dancing Script"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/office_tools/dancing-script-latin-600-normal-f32dca1d.woff2") format("woff2"); }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/office_tools/caveat-latin-600-normal-24c7b559.woff2") format("woff2"); }
@font-face { font-family: "Homemade Apple"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/office_tools/homemade-apple-latin-400-normal-d39d701e.woff2") format("woff2"); }

.ot-sign { display: block; }
.ot-sign [hidden] { display: none !important; }
.ot-sign-start { padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.ot-sign-drop { position: relative; min-height: 280px; justify-content: center; }
.ot-sign-drop strong { font-size: 18px; color: var(--text); }
.ot-sign-drop:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.ot-sign-pick { pointer-events: none; margin-top: 4px; }

.ot-sign-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.ot-sign-file { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.ot-sign-file svg { color: var(--danger); flex: none; }
.ot-sign-filename { font-weight: 600; color: var(--text); overflow-wrap: anywhere; min-width: 0; }
.ot-sign-filemeta { font-size: 14px; color: var(--text-secondary); }
.ot-sign-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ot-sign-download { min-height: 44px; font-size: 15px; }

.ot-sign-body { display: flex; flex-wrap: wrap; }
.ot-sign-tools { flex: 1 1 140px; max-width: 180px; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--border); box-sizing: border-box; }
.ot-sign-tools-title { margin: 0; padding: 0 8px 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.ot-sign-tool { min-height: 44px; padding: 0 12px; border-radius: var(--radius-md); border: 0; background: transparent; color: var(--gray-700); font: inherit; font-size: 15px; text-align: left; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ot-sign-tool:hover { background: var(--bg-secondary); }
.ot-sign-tool[aria-pressed="true"] { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.ot-sign-tool:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.ot-sign-viewer { flex: 999 1 460px; min-width: 0; background: var(--gray-200, #e7e5e4); padding: 24px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-sizing: border-box; }
.ot-sign-stage { position: relative; background: #ffffff; box-shadow: var(--shadow-md); max-width: 100%; }
.ot-sign-canvas { display: block; width: 100%; height: 100%; }
.ot-sign-layer { position: absolute; inset: 0; cursor: crosshair; }
.ot-sign-pager { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-700); }
.ot-sign-pagebtn { width: 44px; padding: 0; font-size: 20px; }

.ot-sign-item { position: absolute; box-sizing: border-box; border: 1px dashed transparent; border-radius: 4px; cursor: move; touch-action: none; user-select: none; -webkit-user-select: none; display: flex; align-items: center; }
.ot-sign-item:hover { border-color: rgba(41, 72, 135, 0.45); }
.ot-sign-item:focus { outline: none; }
.ot-sign-item:focus-visible, .ot-sign-item.is-selected { border: 2px dashed var(--primary); background: rgba(234, 238, 247, 0.45); }
.ot-sign-item img { width: 100%; height: 100%; display: block; pointer-events: none; }
.ot-sign-item span { font-family: Helvetica, Arial, sans-serif; white-space: nowrap; pointer-events: none; display: block; }
.ot-sign-handle { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border-radius: var(--radius-full); background: var(--primary); border: 2px solid #ffffff; cursor: nwse-resize; touch-action: none; pointer-events: auto !important; }
.ot-sign-handle::before { content: ""; position: absolute; inset: -14px; }
.ot-sign-delete { position: absolute; left: -2px; top: -34px; width: 28px; height: 28px; border-radius: var(--radius-full); border: 2px solid #ffffff; background: var(--danger); color: #ffffff; font-size: 16px; line-height: 1; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ot-sign-delete::before { content: ""; position: absolute; inset: -8px; }

.ot-sign-panel { flex: 1 1 280px; min-width: 0; max-width: 360px; padding: 20px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; box-sizing: border-box; }
.ot-sign-section { display: flex; flex-direction: column; gap: 12px; }
.ot-section .ot-sign-heading, .ot-sign-heading { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--text); }
.ot-sign-methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 4px; }
.ot-sign-method { min-height: 44px; border-radius: var(--radius-md); border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 14px; cursor: pointer; }
.ot-sign-method[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.ot-sign-method-panel { display: flex; flex-direction: column; gap: 10px; }
.ot-sign-pad { width: 100%; height: 160px; border: 1px solid var(--border-hover); border-radius: var(--radius-md); background: var(--surface) linear-gradient(to top, transparent 34px, var(--gray-400) 34px, var(--gray-400) 35px, transparent 35px); touch-action: none; cursor: crosshair; display: block; }
.ot-sign-pad-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ot-sign-style { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 12px; border: 1px solid var(--border-hover); border-radius: var(--radius-lg); cursor: pointer; overflow: hidden; }
.ot-sign-style:has(input:checked) { border: 2px solid var(--primary); background: var(--primary-light); padding: 0 11px; }
.ot-sign-style input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.ot-sign-style span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--primary-dark); }
.ot-sign-style-dancing { font-size: 26px; font-weight: 600; }
.ot-sign-style-caveat { font-size: 28px; font-weight: 600; }
.ot-sign-style-apple { font-size: 18px; }
.ot-sign-file-input { padding: 8px 12px; height: auto; }
.ot-sign-upload-preview { max-width: 100%; max-height: 90px; object-fit: contain; align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px; }
.ot-sign-form { border-top: 1px solid var(--border); padding-top: 14px; }
.ot-sign-fields { display: flex; flex-direction: column; gap: 10px; }
.ot-sign-fields .ot-check label { overflow-wrap: anywhere; }

.ot-sign-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.ot-sign-steps li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.ot-sign-steps li > span { width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--primary-light); color: var(--primary-dark); font-weight: 700; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.ot-sign-steps strong { display: block; margin-bottom: 4px; color: var(--text); }
.ot-sign-steps p { margin: 0; font-size: 15px; color: var(--text-secondary); }

/* Narrow screens: tools become a scrolling row above the page, panel below. */
@media (max-width: 860px) {
  .ot-sign-tools { flex: 1 1 100%; max-width: none; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .ot-sign-tools-title { display: none; }
  .ot-sign-tool { flex: none; }
  .ot-sign-panel { max-width: none; flex-basis: 100%; border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 600px) {
  .ot-sign-start { padding: 16px; }
  .ot-sign-bar { padding: 12px 16px; }
  .ot-sign-bar-actions { width: 100%; }
  .ot-sign-bar-actions .ot-btn { flex: 1 1 auto; }
  .ot-sign-viewer { padding: 16px 8px; }
  .ot-sign-panel { padding: 16px; }
}
