/* Sinhala / Tamil web fonts: only downloaded when such characters are actually used */
@font-face { font-family: "Noto Sans Sinhala"; src: url("fonts/noto-sans-sinhala.woff2") format("woff2"); unicode-range: U+0D80-0DFF, U+200C-200D, U+25CC; font-display: swap; }
@font-face { font-family: "Noto Sans Tamil"; src: url("fonts/noto-sans-tamil.woff2") format("woff2"); unicode-range: U+0B80-0BFF, U+200C-200D, U+25CC; font-display: swap; }

/* ============================================
   PDF EDITOR STYLES
   Theme-aware: buttons invert via --ink/--paper so they stay readable
   in light AND dark mode. The PDF pages themselves always stay white
   (they represent paper), so everything drawn ON a page uses fixed colours.
   No inline styles anywhere on the editor page - its strict
   Content-Security-Policy forbids them.
   ============================================ */
[hidden] { display: none !important; }

.editor-main { padding: 40px 0 56px; }

/* ---------- Privacy bar ---------- */
.privacy-bar {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px;
  padding: 12px 16px; margin-bottom: 22px;
  border: 1px solid var(--line-strong); border-left: 4px solid var(--teal);
  border-radius: var(--radius); background: var(--paper-raised);
  color: var(--ink); font-size: 0.88rem;
}
.link-btn {
  margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--teal); font: inherit; font-weight: 600; text-decoration: underline;
}

/* ---------- Buttons ---------- */
.btn, .tool-btn {
  padding: 9px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink);
  font-family: var(--font-display); font-weight: 600; font-size: 0.85rem;
  line-height: 1.2; cursor: pointer;
}
.tool-btn { padding: 7px 12px; font-weight: 500; }
.btn:hover, .tool-btn:hover { border-color: var(--ink); }
.btn-primary, .tool-btn.active, .tool-btn[aria-pressed="true"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.btn:disabled, .tool-btn:disabled { opacity: 0.4; cursor: default; }
.btn-danger { color: #B3291B; border-color: #B3291B; }
html[data-theme="dark"] .btn-danger { color: #FF9484; border-color: #FF9484; }

/* ---------- Drop zone ---------- */
.dropzone {
  padding: 56px 20px; text-align: center; border: 2px dashed var(--line-strong);
  border-radius: 10px; background: var(--paper-raised); color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--teal); background: var(--paper); }
.dz-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.dz-sub, .dz-note { color: var(--slate); font-size: 0.88rem; margin: 6px 0 14px; }
.dz-note { margin: 16px 0 0; }

.notice { padding: 12px 14px; margin-top: 16px; border-radius: var(--radius); font-size: 0.9rem; color: var(--ink); }
.notice-error { border: 1px solid #C0392B; background: rgba(192, 57, 43, 0.12); }

/* ---------- Toolbar ---------- */
.toolbar-wrap {
  position: sticky; top: var(--header-h, 69px); z-index: 30;
  background: var(--paper-raised); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 8px 16px; }
.tool-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.toolbar-end { margin-left: auto; }
.zoom-label, .page-indicator { font-family: var(--font-mono); font-size: 0.8rem; color: var(--slate); min-width: 3.2em; text-align: center; }
.page-indicator { min-width: 6em; }

.props-bar { min-height: 46px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--paper); }
.props-group { display: flex; align-items: center; gap: 8px; }
.props-label { font-size: 0.78rem; color: var(--slate); }
.props-input {
  padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper-raised); color: var(--ink); font-family: var(--font-display); font-size: 0.85rem;
}
.props-num { width: 4.5em; }
.props-color { width: 38px; height: 30px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-raised); cursor: pointer; }

.status { min-height: 1.6em; padding: 6px 16px; font-size: 0.85rem; color: var(--slate); }
.status.ok { color: var(--teal); }
.status.err { color: #B3291B; }
html[data-theme="dark"] .status.err { color: #FF9484; }

/* ---------- Pages ---------- */
.pages-wrap { padding: 20px 8px 40px; background: var(--line); }
html[data-theme="dark"] .pages-wrap { background: #0C0F14; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.page { position: relative; flex: none; background: #fff; box-shadow: 0 1px 8px rgba(0, 0, 0, 0.3); }
.page canvas { display: block; }
.layer { position: absolute; left: 0; top: 0; right: 0; bottom: 0; }
.anno-layer { pointer-events: none; }
.draft-rect { position: absolute; border: 1px dashed #2b7de9; background: rgba(43, 125, 233, 0.12); pointer-events: none; }

.tool-text .page, .tool-date .page { cursor: text; }
.tool-check .page, .tool-cross .page, .placing .page { cursor: copy; }
.tool-whiteout .page { cursor: crosshair; touch-action: none; }

/* ---------- Annotations (drawn on the white page: fixed colours) ---------- */
.anno { position: absolute; box-sizing: border-box; pointer-events: auto; }
.anno:hover { outline: 1px dashed rgba(43, 125, 233, 0.7); }
.anno.selected { outline: 2px solid #2b7de9; }
.anno-text { min-width: 14px; }
.anno-textarea {
  display: block; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; white-space: pre; line-height: 1.2; font-family: inherit; color: inherit; min-width: 1ch;
}
.anno-img img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.anno-whiteout { background: #fff; touch-action: none; cursor: move; }
.anno-mark, .anno-img { touch-action: none; cursor: move; }
.anno-mark svg { display: block; width: 100%; height: 100%; pointer-events: none; }

.anno-move, .anno-del, .anno-resize { display: none; position: absolute; z-index: 5; color: #fff; text-align: center; user-select: none; touch-action: none; }
.anno.selected .anno-move, .anno.selected .anno-del, .anno.selected .anno-resize { display: block; }
.anno-move { left: -2px; top: -22px; width: 24px; height: 22px; line-height: 22px; border-radius: 4px 4px 0 0; background: #2b7de9; cursor: move; font-size: 13px; }
.anno-del { right: -2px; top: -22px; width: 24px; height: 22px; line-height: 21px; border-radius: 4px 4px 0 0; background: #B3291B; cursor: pointer; font-size: 15px; }
.anno-resize { right: -8px; bottom: -8px; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: #2b7de9; cursor: nwse-resize; }

/* ---------- Form fields (detected in the PDF) ---------- */
.field {
  position: absolute; box-sizing: border-box; margin: 0; padding: 0 3px;
  background: rgba(60, 130, 255, 0.16); border: 1px solid rgba(40, 100, 220, 0.55); border-radius: 2px;
  color: #000; font-family: Helvetica, Arial, sans-serif; pointer-events: auto;
}
.field:focus { outline: 2px solid #2b7de9; background: rgba(255, 255, 255, 0.94); }
.field-multi { padding: 2px 3px; resize: none; line-height: 1.2; }
.field-box { position: absolute; pointer-events: auto; }
.field-box input { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.field-box span { position: absolute; left: 0; top: 0; right: 0; bottom: 0; box-sizing: border-box; background: rgba(60, 130, 255, 0.16); border: 1px solid rgba(40, 100, 220, 0.55); pointer-events: none; }
.field-radio span { border-radius: 50%; }
.field-box input:focus-visible + span { outline: 2px solid #2b7de9; }
.field-box input:checked + span::after { content: ""; position: absolute; left: 28%; top: 6%; width: 32%; height: 62%; border: solid #000; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.field-radio input:checked + span::after { left: 28%; top: 28%; width: 44%; height: 44%; border: 0; border-radius: 50%; background: #000; transform: none; }

/* ---------- Dialogs ---------- */
dialog.dialog { width: min(680px, 94vw); padding: 20px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper-raised); color: var(--ink); }
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-title { font-size: 1.15rem; margin-bottom: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-note { margin-top: 12px; font-size: 0.85rem; color: var(--slate); }
.verify-steps { margin: 12px 0 0 20px; font-size: 0.92rem; line-height: 1.6; }
.verify-steps li { margin-bottom: 8px; }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper); font-family: var(--font-mono); font-size: 0.8em; }

.tabs { display: flex; gap: 6px; margin: 10px 0 14px; }
.tab {
  padding: 7px 16px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 0.88rem; cursor: pointer;
}
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sig-canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--line-strong); border-radius: 6px; touch-action: none; }
.sig-tools, .sig-style-row, .check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 0.88rem; }
.sig-text-input { width: 100%; margin-bottom: 8px; }
.ink-dot { width: 26px; height: 26px; border: 2px solid var(--line-strong); border-radius: 50%; cursor: pointer; }
.ink-dot.active { outline: 2px solid var(--teal); outline-offset: 2px; }
.ink-black { background: #111; }
.ink-blue { background: #1a3d8f; }
.sig-style.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

dialog.dialog { margin: auto; max-height: 92vh; overflow: auto; }

@media (max-width: 720px) {
  /* On phones the site header stops being sticky on this page, so the toolbar
     can sit at the very top and leave most of the screen for the document. */
  .editor-page .site-header { position: static; }
  .editor-main { padding-top: 20px; }
  .toolbar-wrap { top: 0; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 6px 8px; gap: 8px; -webkit-overflow-scrolling: touch; }
  .tool-group { flex: none; flex-wrap: nowrap; }
  .toolbar-end { margin-left: 0; order: -1; }   /* Download always visible, first in the row */
  #close-btn { display: none; }                 /* reload the page to open another file on phones */
  .tool-btn, .btn { padding: 7px 10px; }
  .page-indicator { display: none; }
  .props-bar { flex-wrap: nowrap; overflow-x: auto; padding: 6px 8px; min-height: 42px; gap: 6px 14px; }
  .props-group { flex: none; }
  .props-empty { white-space: normal; }
  .pages-wrap { padding: 12px 0 32px; }
}
