/* Styles for the digitised paper forms. Shared by the editor (index.html) and the print view (print.html).
   All geometry is in points (pt) so the sheets have the exact physical size of the paper originals. */

/* Typefaces of the clinic's forms, bundled so every device (tablets included) renders the forms identically.
   Now = the Letter-size forms; Carlito = Calibri-metric (Patient Information Record); Arimo = Arial-metric (Index card). */
@font-face { font-family: 'KS Now'; font-weight: 400; font-display: block; src: url(/assets/fonts/Now-Regular.otf) format('opentype'); }
@font-face { font-family: 'KS Now'; font-weight: 700; font-display: block; src: url(/assets/fonts/Now-Bold.otf) format('opentype'); }
@font-face { font-family: 'KS Carlito'; font-weight: 400; font-style: normal; font-display: block; src: url(/assets/fonts/Carlito-Regular.ttf) format('truetype'); }
@font-face { font-family: 'KS Carlito'; font-weight: 700; font-style: normal; font-display: block; src: url(/assets/fonts/Carlito-Bold.ttf) format('truetype'); }
@font-face { font-family: 'KS Carlito'; font-weight: 400; font-style: italic; font-display: block; src: url(/assets/fonts/Carlito-Italic.ttf) format('truetype'); }
@font-face { font-family: 'KS Carlito'; font-weight: 700; font-style: italic; font-display: block; src: url(/assets/fonts/Carlito-BoldItalic.ttf) format('truetype'); }
@font-face { font-family: 'KS Arimo'; font-weight: 400 700; font-display: block; src: url(/assets/fonts/Arimo.ttf) format('truetype'); }
@font-face { font-family: 'KS Script'; font-weight: 400 700; font-display: block; src: url(/assets/fonts/DancingScript.ttf) format('truetype'); }

:root {
  --ink: #000;                    /* entered information is printed in black */
  --now: 'KS Now', 'Century Gothic', sans-serif;
  --calibri: 'KS Carlito', Calibri, sans-serif;
  --arial: 'KS Arimo', Arial, Helvetica, sans-serif;
  --index-red: #d0281e;
}

.sheet {
  position: relative;
  background: #fff;
  color: #000;
  overflow: hidden;
  margin: 0 auto 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 8px 28px rgba(0, 0, 0, .12);
  font-family: var(--now);
  --ink-font: var(--now);         /* entered text uses the form's own typeface */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sheet *, .sheet *::before, .sheet *::after { box-sizing: border-box; }
.sheet .bg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.sheet .abs { position: absolute; }
.sheet .lbl { white-space: nowrap; line-height: 1.15; color: #111; }
.sheet .now { font-family: var(--now); font-weight: 400; }
.sheet .now-b { font-family: var(--now); font-weight: 700; }
.sheet .cal { font-family: var(--calibri); font-weight: 400; }
.sheet .cal-b { font-family: var(--calibri); font-weight: 700; }
.sheet .italic { font-style: italic; }
.sheet .hl, .sheet .vl { background: #111; }
.sheet .rule { background: #231f20; }
.sheet .rect { border: solid #111; }
.sheet .vtext { transform: rotate(-90deg); transform-origin: center; text-align: center; line-height: 1.05; white-space: normal; }

/* ---- entered data ---- */
.sheet .f-in, .sheet .fv {
  position: absolute;
  margin: 0; border: 0; padding: 0 1pt;
  background: transparent;
  color: var(--ink);
  font-family: var(--ink-font);
  white-space: pre;
  overflow: hidden;
  text-overflow: clip;
}
.sheet .f-area { white-space: pre-wrap; resize: none; overflow: hidden; }
.sheet .fv.wrap2 { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sheet .f-in { outline: none; border-radius: 1.5pt; transition: background .12s; }
.mode-edit .sheet .f-in { background: rgba(52, 120, 220, .07); }
.mode-edit .sheet .f-in:hover { background: rgba(52, 120, 220, .15); }
.mode-edit .sheet .f-in:focus { background: rgba(255, 205, 40, .28); box-shadow: 0 0 0 .8pt rgba(214, 160, 0, .7); }
.sheet .f-date::-webkit-calendar-picker-indicator { opacity: .35; margin: 0; padding: 0; width: 8pt; height: 8pt; cursor: pointer; }
.sheet .f-date { font-variant-numeric: tabular-nums; }
.sheet .f-datebox { overflow: hidden; white-space: nowrap; }
.sheet .f-datebox .f-dv { pointer-events: none; }
.sheet .f-date-native { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; margin: 0; padding: 0; border: 0; cursor: pointer; }
.sheet .f-date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.mode-edit .sheet .f-datebox:focus-within { background: rgba(255, 205, 40, .28); box-shadow: 0 0 0 .8pt rgba(214, 160, 0, .7); }
.sheet .f-date[data-empty]:not(:focus)::-webkit-datetime-edit { color: transparent; }

/* circled choice (Yes / No) */
.sheet .f-choice { position: absolute; border-radius: 50%; border: 1.1pt solid transparent; }
.sheet .f-choice.chosen { border-color: var(--ink); }
.mode-edit .sheet .f-choice.editable { cursor: pointer; }
.mode-edit .sheet .f-choice.editable:hover { background: rgba(52, 120, 220, .12); }

/* signatures */
.sheet .f-ink { position: absolute; display: flex; align-items: center; justify-content: flex-start; overflow: hidden; pointer-events: none; }
.sheet .f-ink .ink-img { max-width: 100%; max-height: 100%; object-fit: contain; object-position: left center; }
.sheet .f-sig { position: absolute; display: flex; align-items: flex-end; justify-content: center; overflow: visible; }
.sheet .f-sig .sig-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sheet .f-sig .sig-typed, .sig-typed { font-family: 'KS Script', 'Segoe Script', cursive; font-weight: 500; color: var(--ink); white-space: nowrap; line-height: 1; }
.mode-edit .sheet .f-sig.editable { cursor: pointer; border-radius: 2pt; background: rgba(52, 120, 220, .06); }
.mode-edit .sheet .f-sig.editable:empty::after { content: '✎ sign'; font: 600 7pt 'Segoe UI', Roboto, sans-serif; color: rgba(52, 100, 190, .55); align-self: center; }
.mode-edit .sheet .f-sig.editable:hover { background: rgba(52, 120, 220, .15); }

/* tooth surfaces */
.sheet .tooth-layer { pointer-events: none; overflow: visible; }
.sheet .tooth-layer .tl { fill: none; stroke: #111; stroke-width: 1.15; }
.sheet .tooth-layer .ts { fill: transparent; stroke: none; }
.sheet .tooth-layer .ts.m-red { fill: #d62b2b; }
.sheet .tooth-layer .ts.m-blue { fill: #2a5bd7; }
.sheet .tooth-layer .ts.m-black { fill: #000; }
.mode-edit .sheet .f-tooth.editable .ts { pointer-events: all; cursor: pointer; }
.mode-edit .sheet .f-tooth.editable .ts:hover { fill: rgba(52, 120, 220, .25); }
.mode-edit .sheet .f-tooth.editable .ts.m-red:hover { fill: #b51f1f; }
.mode-edit .sheet .f-tooth.editable .ts.m-blue:hover { fill: #1f47a8; }
.sheet .f-cell { font-weight: 700; }

/* free-hand annotation layer */
.sheet .f-draw { position: absolute; }
.sheet .f-draw canvas, .sheet .f-draw img { width: 100%; height: 100%; display: block; }
.mode-edit .sheet .f-draw canvas { pointer-events: none; }
.annotating .sheet .f-draw canvas { pointer-events: auto; cursor: crosshair; outline: 1.5pt dashed rgba(52, 120, 220, .6); }

/* procedure rows (click to edit) */
.sheet .proc-hit { position: absolute; cursor: pointer; border-radius: 1pt; }
.sheet .proc-hit:hover { background: rgba(52, 120, 220, .12); }
.sheet .proc-add { display: flex; align-items: center; padding-left: 6pt; background: rgba(46, 160, 90, .08); }
.sheet .proc-add span { font: 600 7pt 'Segoe UI', Roboto, sans-serif; color: #1d7a45; }
.sheet .proc-add:hover { background: rgba(46, 160, 90, .2); }

/* ---- per-form details ---- */
.f-oral .os-text { font-family: var(--now); font-size: 9.35pt; line-height: 13.05pt; text-align: justify; color: #111; }
.f-oral .os-text.nowrap { white-space: nowrap; }
.f-oral .os-text.right { text-align: right; }
.f-oral .os-list { margin: 0; padding: 0 0 0 9pt; list-style: none; counter-reset: risk; }
.f-oral .os-list li { counter-increment: risk; position: relative; text-align: left; margin-bottom: .75pt; }
.f-oral .os-list li::before { content: counter(risk) '.'; position: absolute; left: -9pt; }

.sheet.f-pir { --ink-font: var(--calibri); }
.sheet.f-index { --ink-font: var(--arial); }
.f-pir .pir-consent { font-family: var(--calibri); font-size: 7.72pt; line-height: 8.42pt; color: #111; }
.f-pir .pir-consent p { margin: 0; text-align: justify; }
.f-pir .th { display: flex; align-items: center; justify-content: center; text-align: center; white-space: normal; }
.f-pir .tbl { border-color: #111; }

.f-index .ix-lbl { font-family: var(--arial); font-weight: 700; color: var(--index-red); letter-spacing: .25pt; }
.f-index .ix-rule { background: var(--index-red); }
.f-index .ix-v { white-space: nowrap; }
.f-index .card-no { right: 8pt; bottom: 6pt; font: 600 6pt var(--arial); color: #999; }

/* ---- "data only" printing onto the clinic's pre-printed paper forms ---- */
.data-only .sheet .tpl,
.data-only .sheet .tooth-layer .tl { visibility: hidden; }
.data-only .sheet { box-shadow: none; }

/* ---- paper sizes ---- */
@page letter { size: 8.5in 11in; margin: 0; }
@page a4l { size: 297mm 210mm; margin: 0; }
@page card { size: 8in 5.5in; margin: 0; }
.sheet-letter { page: letter; }
.sheet-a4l { page: a4l; }
.sheet-card { page: card; }

@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  .sheet { margin: 0 !important; box-shadow: none !important; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .proc-add, .no-print { display: none !important; }
  .f-sig:empty::after { content: none !important; }
}
