/* PDF editor of in-browser tools (sign-pdf). Loaded on the editor page only; colors come from brand.css. */

.editor-section {
  padding-block: 32px clamp(40px, 6vw, 72px);
  background: var(--ws-bg-subtle);
}

.editor {
  --ed-desk: #e7e9f0;
  --ed-ink: #1d1d1f;
  border: 1px solid var(--ws-border);
  border-radius: 20px;
  background: var(--ws-surface);
}

.editor > .uploader__drop {
  margin: 10px;
}

.editor__status.is-error {
  color: var(--ws-error);
}

/* Toolbar: sticks under the fixed site header */

.editor__toolbar {
  position: sticky;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--ws-border);
  border-radius: 20px 20px 0 0;
  background: var(--ws-surface);
  scrollbar-width: thin;
}

.editor .tool {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: 600 13.5px/1.2 var(--font-ui);
  color: var(--ws-heading);
  white-space: nowrap;
  cursor: pointer;
}

.editor .tool svg,
.editor__savebar .btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.editor .tool:hover {
  background: var(--ws-bg-subtle);
}

.editor .tool[aria-pressed="true"] {
  background: var(--ws-green-soft);
  color: var(--ws-green-hover);
}

.editor .tool[disabled] {
  background: transparent;
  opacity: 0.35;
  cursor: default;
}

.editor__sep {
  flex: none;
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--ws-border);
}

.editor__hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--ws-border);
  font-size: 13.5px;
  color: var(--ws-muted);
}

.editor__hint.err {
  color: var(--ws-error);
}

/* Palette and thickness: shared by the hint bar and the signature dialog */

.style-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.style-bar--stacked {
  flex-direction: column;
  align-items: flex-start;
}

.style-bar--stacked .style-sep {
  display: none;
}

.style-bar .style-sep {
  width: 1px;
  height: 22px;
  background: var(--ws-border);
}

.style-bar .swatches {
  display: flex;
  gap: 8px;
}

.style-bar .sw {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid var(--ws-surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--ws-border);
  cursor: pointer;
}

.style-bar .sw[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--ws-heading);
}

.style-bar .sw-wrap {
  position: relative;
  display: inline-flex;
}

.style-bar .sw-x {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ws-heading);
  color: var(--ws-surface);
  cursor: pointer;
}

.style-bar .sw-x svg {
  width: 7px;
  height: 7px;
}

.style-bar .sw.pick {
  position: relative;
  display: inline-block;
  overflow: hidden;
  background: conic-gradient(#e5484d, #ffd400, #12a150, #22b8cf, #1f3fa8, #c026d3, #e5484d);
}

.style-bar .sw.pick input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.style-bar .wslider {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ws-heading);
}

.style-bar .wslider svg {
  flex: none;
  width: 22px;
  height: 12px;
}

.style-bar .wslider input {
  width: 120px;
  accent-color: var(--ws-green);
  cursor: pointer;
}

.style-bar .wslider output {
  min-width: 2.2em;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ws-muted);
}

.style-bar .font-select {
  max-width: 170px;
  padding: 5px 8px;
  border: 1px solid var(--ws-border);
  border-radius: 8px;
  background: var(--ws-surface);
  font-size: 15px;
  color: var(--ws-heading);
  cursor: pointer;
}

.style-bar .font-select--size {
  font-variant-numeric: tabular-nums;
}

/* Desk and pages */

.editor__desk {
  display: grid;
  justify-items: center;
  gap: 30px;
  min-height: 360px;
  padding: 24px 12px 36px;
  background: var(--ed-desk);
}

.editor__desk.is-dragover {
  outline: 2px dashed var(--ws-green);
  outline-offset: -10px;
}

.editor .page {
  position: relative;
  width: min(100%, 780px);
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(20, 24, 40, 0.08),
    0 8px 28px rgba(20, 24, 40, 0.1);
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
}

.editor .page canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.editor .page canvas.ink {
  pointer-events: none;
}

.editor .pnum {
  position: absolute;
  right: 0;
  bottom: -22px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ws-muted);
}

.editor .layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.editor.mode-pen .page canvas.ink {
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
}

.editor.mode-place .page,
.editor.mode-draw .page {
  cursor: crosshair;
  touch-action: none;
}

.editor.mode-pen .item,
.editor.mode-place .item,
.editor.mode-draw .item {
  pointer-events: none;
}

/* Marks placed on a page */

.editor .item {
  position: absolute;
  outline: 1.5px dashed transparent;
  outline-offset: 3px;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.editor .item:hover {
  outline-color: rgba(0, 186, 136, 0.45);
}

.editor .item.sel {
  outline-color: var(--ws-green);
}

.editor .item img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.editor .item svg {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.editor .item.check svg,
.editor .item.line svg,
.editor .item.arrow svg {
  height: auto;
}

/* A thin line, arrow or pen stroke is hard to grab: widen its hit area */
.editor .item.line::before,
.editor .item.arrow::before,
.editor .item.pen::before {
  content: "";
  position: absolute;
  inset: -7px;
}

.editor .item.marker {
  border-radius: 2px;
  mix-blend-mode: multiply;
}

.editor .txt {
  display: block;
  min-width: 0.6em;
  outline: none;
  font-family: var(--font-body);
  font-size: calc(var(--fs) * 100cqw);
  line-height: 1.25;
  color: var(--ed-ink);
  white-space: pre;
}

.editor .item.editing {
  cursor: text;
}

.editor .item.editing .txt {
  user-select: text;
  -webkit-user-select: text;
}

.editor .handle {
  position: absolute;
  right: -9px;
  bottom: -9px;
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--ws-green);
  border-radius: 50%;
  background: var(--ws-surface);
  cursor: nwse-resize;
  touch-action: none;
}

.editor .del {
  position: absolute;
  top: -14px;
  right: -14px;
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ws-heading);
  color: var(--ws-surface);
  cursor: pointer;
}

.editor .del svg {
  width: 12px;
  height: 12px;
}

.editor .item.sel .handle {
  display: block;
}

.editor .item.sel .del {
  display: grid;
}

.editor .item.editing .handle {
  display: none;
}

/* Bottom bar: stays in view so opening and saving never need scrolling */

.editor__savebar {
  position: sticky;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--ws-border);
  border-radius: 0 0 20px 20px;
  background: var(--ws-surface);
}

.editor__savebar .btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.editor__savebar .btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.editor__file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ws-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor-file:focus-visible ~ .uploader__drop .btn,
#editor-file:focus-visible ~ .editor__work .editor__savebar label.btn {
  outline: 2px solid var(--ws-green);
  outline-offset: 3px;
}

@media (max-width: 560px) {
  .editor__file {
    display: none;
  }

  .editor__savebar {
    justify-content: space-between;
  }
}

/* Signature dialog */

.sig-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(20, 22, 35, 0.45);
}

.sig-sheet {
  display: grid;
  gap: 16px;
  width: min(100%, 600px);
  max-height: 100%;
  padding: 22px;
  overflow: auto;
  border-radius: 20px;
  background: var(--ws-surface);
  color: var(--ws-text);
}

.sig-sheet h2 {
  font-size: 20px;
  color: var(--ws-heading);
}

.sig-panel {
  display: grid;
  gap: 12px;
}

.sig-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sig-label {
  font: 600 12px/1.3 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ws-muted);
}

.sig-saved {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sig-saved .saved-item {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.sig-saved .saved-use {
  height: 54px;
  padding: 6px 10px;
  border: 1px solid var(--ws-border);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
}

.sig-saved .saved-use:hover {
  border-color: var(--ws-green);
}

.sig-saved .saved-use img {
  width: auto;
  height: 100%;
}

.sig-saved .saved-remove {
  font-size: 12px;
}

.sig-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--ws-bg-subtle);
}

.sig-tab {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font: 600 13.5px/1.2 var(--font-ui);
  color: var(--ws-muted);
  white-space: nowrap;
  cursor: pointer;
}

.sig-tab[aria-selected="true"] {
  background: var(--ws-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  color: var(--ws-heading);
}

.sig-pad {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ws-border);
  border-radius: 14px;
  background: #ffffff;
}

.sig-pad canvas {
  display: block;
  width: 100%;
  height: auto;
}

.sig-pad canvas#sig-pad {
  cursor: crosshair;
  touch-action: none;
}

.sig-pad__line {
  position: absolute;
  right: 24px;
  bottom: 26%;
  left: 24px;
  border-bottom: 1px dashed var(--ws-border);
  pointer-events: none;
}

.sig-pad__clear {
  position: absolute;
  top: 6px;
  right: 10px;
  border-radius: 8px;
  background: var(--ws-surface);
}

.sig-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--ws-border);
  border-radius: 12px;
  background: var(--ws-surface);
  font: inherit;
  color: var(--ws-heading);
}

.sig-field:focus {
  border-color: transparent;
  outline: 2px solid var(--ws-green);
}

.sig-fonts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sig-font {
  padding: 4px 16px;
  border: 1px solid var(--ws-border);
  border-radius: var(--radius-pill);
  background: var(--ws-surface);
  font-size: 22px;
  line-height: 1.3;
  color: var(--ws-heading);
  cursor: pointer;
}

.sig-font[aria-pressed="true"] {
  border-color: var(--ws-green);
  background: var(--ws-green-soft);
}

/* Checkerboard shows that the photo background became transparent */
.sig-photo {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 170px;
  padding: 16px;
  border: 1px dashed var(--ws-border);
  border-radius: 14px;
  background: conic-gradient(#eef0f4 25%, #ffffff 0 50%, #eef0f4 0 75%, #ffffff 0) 0 0 / 16px 16px;
  font-size: 14px;
  text-align: center;
  color: var(--ws-muted);
}

.sig-photo img {
  width: auto;
  max-height: 120px;
}

.sig-error {
  margin: 0;
  font-size: 14px;
  color: var(--ws-error);
}

.sig-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.sig-remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--ws-green);
}

.sig-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
