/* Dhamma school certificates: the page, the editor and printing (assets/cert-kit.js, assets/cert-editor.js) */
.ck-page { position: relative; overflow: hidden; background: #fff; flex: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.ck-page .ck-border { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.ck-page .ck-item { position: absolute; margin: 0; padding: 0; transform-origin: 50% 50%; user-select: none; -webkit-user-drag: none; }
.ck-page img.ck-item { display: block; max-width: none; max-height: none; object-fit: fill; }
.ck-page .ck-text { white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: 0; }

/* thumbnails in the template list */
.ck-thumb { position: relative; width: 100%; background: repeating-conic-gradient(#f1f5f9 0% 25%, #f8fafc 0% 50%) 50% / 16px 16px; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }
.ck-thumb .ck-page { box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.ck-thumb-host { width: 100%; }

/* print: only the certificate pages */
#ck-print { display: none; }
@media print {
  body.ck-printing > *:not(#ck-print) { display: none !important; }
  body.ck-printing { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.ck-printing #ck-print { display: block !important; }
  #ck-print .ck-page { box-shadow: none !important; break-after: page; page-break-after: always; margin: 0; }
  #ck-print .ck-page:last-child { break-after: auto; page-break-after: auto; }
}
/* drawing for the PDF (under the "Making the PDF" box) */
#ck-render { position: fixed; left: 0; top: 0; z-index: 1; pointer-events: none; }
#ck-busy { position: fixed; inset: 0; z-index: 9999; background: rgba(15, 23, 42, .78); display: flex; align-items: center; justify-content: center; }
#ck-busy[hidden] { display: none; }
.ck-busy-box { background: #fff; border-radius: 16px; padding: 18px 22px; display: flex; align-items: center; gap: 12px; font-weight: 700; color: #0f172a; box-shadow: 0 20px 40px rgba(0, 0, 0, .3); }
.ck-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fde68a; border-top-color: #d97706; animation: ck-spin .8s linear infinite; }
@keyframes ck-spin { to { transform: rotate(360deg); } }

/* ---------- editor ---------- */
.ce { --ce-left: 300px; --ce-right: 290px; }
.ce-bar { position: sticky; top: 0; z-index: 40; }
.ce-body { display: grid; grid-template-columns: var(--ce-left) minmax(0, 1fr) var(--ce-right); min-height: calc(100vh - 140px); }
.ce.is-view .ce-body { grid-template-columns: minmax(0, 1fr); }
.ce.is-view .ce-left, .ce.is-view .ce-right { display: none; }
.ce-left, .ce-right { background: #fff; overflow-y: auto; max-height: calc(100vh - 120px); position: sticky; top: 64px; }
.ce-left { border-right: 1px solid #e2e8f0; }
.ce-right { border-left: 1px solid #e2e8f0; }
.ce-stage { position: relative; background: #e2e8f0; background-image: radial-gradient(#cbd5e1 1px, transparent 1px); background-size: 18px 18px; overflow: auto; padding: 28px; display: flex; justify-content: center; align-items: flex-start; }
.ce-host { position: relative; flex: none; }
.ce-host .ck-page { box-shadow: 0 10px 30px -8px rgba(15, 23, 42, .35); }
.ce:not(.is-view) .ce-host .ck-item { cursor: move; }
.ce:not(.is-view) .ce-host .ck-item.is-locked { cursor: default; }
.ce-host .ck-text[contenteditable="true"], .ce-host .ck-text[contenteditable="plaintext-only"] { cursor: text; user-select: text; outline: 2px dashed #2563eb; outline-offset: 1px; background: rgba(255, 255, 255, .6); }
.ce-sel { position: absolute; pointer-events: none; outline: 1.5px solid #2563eb; outline-offset: 0; z-index: 5; transform-origin: 50% 50%; }
.ce-sel.is-locked { outline-style: dashed; outline-color: #94a3b8; }
.ce-sel .h { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid #2563eb; border-radius: 3px; pointer-events: auto; touch-action: none; }
.ce-sel.is-locked .h, .ce-sel.no-h .h { display: none; }
.ce-sel .h[data-h=nw] { left: -6px; top: -6px; cursor: nwse-resize; } .ce-sel .h[data-h=ne] { right: -6px; top: -6px; cursor: nesw-resize; }
.ce-sel .h[data-h=sw] { left: -6px; bottom: -6px; cursor: nesw-resize; } .ce-sel .h[data-h=se] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ce-sel .h[data-h=n] { left: calc(50% - 6px); top: -6px; cursor: ns-resize; } .ce-sel .h[data-h=s] { left: calc(50% - 6px); bottom: -6px; cursor: ns-resize; }
.ce-sel .h[data-h=w] { left: -6px; top: calc(50% - 6px); cursor: ew-resize; } .ce-sel .h[data-h=e] { right: -6px; top: calc(50% - 6px); cursor: ew-resize; }
.ce-sel.is-text .h[data-h=n], .ce-sel.is-text .h[data-h=s] { display: none; }
.ce-hover { position: absolute; pointer-events: none; outline: 1px dashed #60a5fa; z-index: 4; }
.ce-guide { position: absolute; z-index: 6; pointer-events: none; background: #ec4899; }
.ce-guide.v { width: 1px; top: 0; bottom: 0; }
.ce-guide.hz { height: 1px; left: 0; right: 0; }
.ce-host.is-drop { outline: 3px dashed #2563eb; outline-offset: 6px; }

.ce-sec { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; }
.ce-sec h3 { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin: 0 0 10px; }
.ce-tabs { display: flex; gap: 4px; padding: 10px 12px 0; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; background: #fff; z-index: 2; }
.ce-tab { flex: 1; padding: 8px 6px; font-size: 12px; font-weight: 700; color: #64748b; border-bottom: 2px solid transparent; text-align: center; cursor: pointer; background: none; }
.ce-tab.is-on { color: #b45309; border-bottom-color: #d97706; }
.ce-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ce-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ce-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; font-size: 10.5px; font-weight: 600; color: #334155; cursor: pointer; text-align: center; line-height: 1.2; min-height: 72px; transition: border-color .15s, box-shadow .15s; }
.ce-tile:hover { border-color: #f59e0b; box-shadow: 0 2px 8px rgba(217, 119, 6, .15); }
.ce-tile.is-on { border-color: #d97706; box-shadow: 0 0 0 2px rgba(217, 119, 6, .35); }
.ce-tile img { width: 40px; height: 40px; object-fit: contain; }
.ce-tile.border img { width: 46px; height: 62px; border: 1px solid #f1f5f9; background: #fff; }
.ce-addtext { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; margin-bottom: 6px; cursor: pointer; color: #0f172a; }
.ce-addtext:hover { border-color: #f59e0b; }
.ce-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ce-row > label { flex: 1; min-width: 0; }
.ce-lab { display: block; font-size: 11px; font-weight: 700; color: #475569; margin-bottom: 3px; }
.ce-in { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 6px 8px; font-size: 13px; background: #fff; color: #0f172a; min-width: 0; }
.ce-in:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .15); }
textarea.ce-in { min-height: 84px; resize: vertical; font-family: "Noto Sans Sinhala", Inter, sans-serif; line-height: 1.5; }
input[type=color].ce-in { padding: 2px; height: 32px; cursor: pointer; }
input[type=range].ce-in { padding: 0; border: 0; box-shadow: none; }
.ce-seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.ce-seg button { padding: 5px 9px; font-size: 12px; font-weight: 700; color: #475569; background: #fff; border-right: 1px solid #e2e8f0; cursor: pointer; }
.ce-seg button:last-child { border-right: 0; }
.ce-seg button.is-on { background: #0f172a; color: #fff; }
.ce-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; font-size: 12px; font-weight: 700; color: #334155; cursor: pointer; white-space: nowrap; }
.ce-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.ce-btn:disabled { opacity: .45; cursor: not-allowed; }
.ce-btn.danger { color: #be123c; border-color: #fecdd3; }
.ce-btn.danger:hover { background: #fff1f2; }
.ce-swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.ce-swatches button { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(15, 23, 42, .15); cursor: pointer; }
.ce-empty { font-size: 12px; color: #64748b; text-align: center; padding: 26px 10px; }
.ce-pics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ce-pic { position: relative; border: 1px solid #e2e8f0; border-radius: 10px; background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 12px 12px; aspect-ratio: 1; cursor: pointer; overflow: hidden; }
.ce-pic img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.ce-pic:hover { border-color: #f59e0b; }
.ce-pic .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 6px; background: rgba(15, 23, 42, .75); color: #fff; font-size: 13px; line-height: 20px; text-align: center; display: none; }
.ce-pic:hover .x { display: block; }
.ce-drop { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 14px; text-align: center; font-size: 12px; color: #475569; cursor: pointer; background: #f8fafc; display: block; }
.ce-drop:hover, .ce-drop.is-over { border-color: #d97706; background: #fffbeb; }
.ce-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9998; background: #0f172a; color: #fff; font-size: 13px; font-weight: 600; padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 92vw; }
.ce-toast.err { background: #be123c; }
.ce-dlg { position: fixed; inset: 0; z-index: 9990; background: rgba(15, 23, 42, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ce-dlg[hidden] { display: none; }
.ce-dlg-box { background: #fff; border-radius: 18px; width: 100%; max-width: 480px; padding: 20px; box-shadow: 0 30px 60px rgba(0, 0, 0, .3); max-height: 90vh; overflow: auto; }
.ce-zoom { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 4px; background: #fff; border-radius: 10px; padding: 4px; box-shadow: 0 4px 14px rgba(15, 23, 42, .15); z-index: 8; }
.ce-zoom button { width: 30px; height: 28px; border-radius: 7px; font-weight: 800; color: #334155; cursor: pointer; background: none; }
.ce-zoom button:hover { background: #f1f5f9; }
.ce-zoom span { font-size: 11px; font-weight: 700; color: #64748b; align-self: center; min-width: 40px; text-align: center; }
.ce-hint { font-size: 11px; color: #64748b; line-height: 1.45; }
.ce-kbd { font-family: ui-monospace, monospace; font-size: 10px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 4px; padding: 0 4px; }

@media (max-width: 1100px) {
  .ce { --ce-left: 260px; --ce-right: 250px; }
}
@media (max-width: 900px) {
  .ce-body { grid-template-columns: minmax(0, 1fr); }
  .ce-left, .ce-right { position: static; max-height: none; border: 0; border-top: 1px solid #e2e8f0; }
  .ce-stage { order: -1; padding: 14px; min-height: 60vh; }
  .ce-right { order: 0; }
  .ce-left { order: 1; }
}
/* phones: dragging a part must not scroll the page (the empty page area still scrolls) */
.ce:not(.is-view) .ce-host .ck-item { touch-action: none; }
