/* Comfort layer: easier on a phone and on a computer (js/comfort.js).
 * Touch targets of at least 44 px, a bottom bar with Back / Next / jump-to-the-text,
 * text size and a soft-light mode, zoom for pictures, dialogs for the overview,
 * settings and sharing. Loaded after app.css. */

button, a, .radio-opt, .tab, .ctab, .hm-tab, label { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; }

/* the progress squares became a button that opens the overview */
button.progress { display: flex; align-items: center; gap: 4px; padding: 3px 4px; margin: 0; background: none; border: 0; border-radius: 4px; color: inherit; font: inherit; cursor: pointer; }
button.progress:hover { background: rgba(255, 255, 255, 0.18); }
.prog-text { display: none; padding: 0 12px; height: 34px; line-height: 34px; font-size: 15px; font-weight: 700; color: #fff; background: rgba(255, 255, 255, 0.24); border-radius: 999px; white-space: nowrap; }

/* ---- text size and soft light (settings) ---- */
html[data-size="1"] .cba-body { zoom: 1.12; }
html[data-size="2"] .cba-body { zoom: 1.28; }
html[data-soft="1"] .cba-body { background: #f3ead2; }
html[data-soft="1"] .panel { background: #fbf4e2; }
html[data-soft="1"] .cba-body { filter: sepia(0.14) brightness(0.97); }
html[data-soft="1"] .cba-window { background: #6f9fc0; }

/* ---- the bottom bar (phones) ---- */
.cm-dock { display: none; }
@media (max-width: 860px) {
  .cba-top { position: sticky; top: 0; z-index: 30; height: 56px; gap: 6px; background: var(--chrome); }
  .progress .sq { display: none; }
  .prog-text { display: inline-block; }
  .tb-btn { width: 44px; height: 44px; border-radius: 8px; }
  .tb-btn svg { width: 28px; height: 28px; }
  .tb-back, .tb-next, .step-nav { display: none; }
  .mode-tag { padding: 0 9px; font-size: 12px; }
  .cm-dock { display: flex; position: sticky; bottom: 0; z-index: 25; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 3px solid var(--chrome-dk); box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.16); }
  .cm-dock button { flex: 1 1 0; min-height: 50px; padding: 0 8px; font: 700 17px var(--font); border-radius: 10px; cursor: pointer; border: 2px solid var(--prog-edge); }
  .cm-next { flex: 1.5 1 0; color: #fff; background: var(--prog); }
  .cm-prev { color: var(--prog-edge); background: #fff; }
  .cm-jump { color: #1f4f7a; background: #e6f0f8; border-color: #4a9ad0 !important; }
  .cm-dock button:active { filter: brightness(0.93); }
  .has-dock .lt { bottom: var(--dock-h, 66px); }
  .panel { scroll-margin-top: 62px; }
  /* typing: 16 px stops iOS zooming into the box; big, thumb-sized keys in one scrolling row */
  .resp-input, .resp-text, .hm input, .hm select { font-size: 16px; }
  .resp-input { min-height: 46px; padding: 8px 12px; }
  .resp-text { padding: 10px 12px; }
  .mathbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 5px; gap: 6px; }
  .mathbar::-webkit-scrollbar { display: none; }
  .mk { flex: none; min-width: 46px; height: 46px; font-size: 19px; border-radius: 8px; }
  .calc { top: auto; left: 8px !important; right: 8px !important; bottom: calc(var(--dock-h, 66px) + 8px); width: auto; }
  .calc-keys { gap: 8px; }
  .ck { padding: 13px 0; font-size: 19px; }
  .calc-head { padding: 5px 10px; }
  .calc-x { font-size: 28px; padding: 0 8px; }
  .clock-pop { left: 8px; top: 58px; }
}
@media (max-width: 520px) {
  .tb-clock, .mode-tag { display: none; }
}

/* ---- touch targets on any touch screen or narrow window ---- */
@media (pointer: coarse), (max-width: 860px) {
  .radio-opt { min-height: 46px; padding: 8px 10px; gap: 12px; }
  .radio-opt:active { background: #e3f0fa; }
  input[type='radio'], input[type='checkbox'] { width: 24px; height: 24px; margin: 3px 0 0; }
  .cell-hit { min-height: 48px; }
  .cell-hit input { margin: 0; }
  .tab { padding: 10px 16px; font-size: 15px; }
  .sort-btn { width: 36px; height: 36px; }
  .slot { min-height: 44px; line-height: 40px; }
  .tcell.drop { min-width: 44px; }
  .dnd-src { min-height: 40px; }
  .lt-head { min-height: 48px; }
  .lt-btn { min-height: 44px; }
  .dlg .btn, .dlg-btns .btn { min-height: 46px; padding: 8px 20px; font-size: 16px; }
  .step-btn { min-height: 48px; }
  .hm .hm-btn, .hm .hm-tab, .hm .hm-link { min-height: 44px; }
  .hm .hm-unit { min-height: 52px; }
  .hm .hm-unit input { width: 24px; height: 24px; }
}

/* ---- pictures can be opened large and pinched ---- */
.cm-zoomable { cursor: zoom-in; }
.cm-zoom-badge { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 6px; padding: 3px 12px; font: 600 13px var(--font); color: #1f4f7a; background: #e6f0f8; border: 1px solid #9bb7cf; border-radius: 999px; cursor: pointer; }
.cm-zoom-back { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: rgba(12, 20, 30, 0.88); }
.cm-zoom-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; color: #fff; font-size: 14px; }
.cm-zoom-bar button { min-height: 44px; padding: 0 18px; font: 700 16px var(--font); border: 0; border-radius: 8px; background: #fff; color: #17365d; cursor: pointer; }
.cm-zoom-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; text-align: center; padding: 8px; }
.cm-zoom-body > * { background: #fff; border-radius: 6px; padding: 8px; max-width: none; }
.cm-zoom-body img, .cm-zoom-body svg { width: max(100%, 900px); height: auto; }

/* ---- toasts: saved, offline ---- */
.cm-toast { position: fixed; left: 50%; bottom: calc(var(--dock-h, 0px) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px); z-index: 60; max-width: calc(100% - 28px); padding: 7px 16px; font: 600 14px var(--font); line-height: 1.5; color: #fff; background: rgba(23, 54, 93, 0.94); border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; text-align: center; }
.cm-toast.on { opacity: 1; transform: translateX(-50%); }
.cm-toast.warn { background: rgba(138, 74, 0, 0.96); border-radius: 12px; }
.cm-toast.small { font-size: 13px; padding: 4px 12px; background: rgba(47, 106, 31, 0.92); }

/* ---- settings, overview, share dialogs ---- */
.cm-dlg { max-height: 88vh; overflow: auto; }
.cm-dlg h3 { margin: 0 0 10px; }
.cm-dlg h4 { margin: 14px 0 6px; font-size: 15px; color: #1f4f7a; }
.cm-seg { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-seg button { min-width: 64px; min-height: 44px; padding: 0 14px; font-family: var(--font); background: #fff; color: #1f4f7a; border: 2px solid #9bb7cf; border-radius: 8px; cursor: pointer; }
.cm-seg button[aria-pressed='true'] { color: #fff; background: #2c76b0; border-color: #2c76b0; }
.cm-check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.cm-check input { margin: 0; }
.cm-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cm-keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.cm-keys td { padding: 3px 6px; border-bottom: 1px solid #e3e9ee; }
.cm-keys kbd { display: inline-block; min-width: 22px; padding: 0 6px; font: 600 13px Arial, sans-serif; text-align: center; background: #f3f6f9; border: 1px solid #aab4bd; border-bottom-width: 2px; border-radius: 4px; }
.cm-note { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.cm-ov-unit { margin: 6px 0 4px; padding: 6px 0; min-height: 40px; font-weight: 700; font-size: 15px; cursor: pointer; }
.cm-ov-unit small { font-weight: 400; color: var(--muted); }
.cm-ov-d { border-bottom: 1px solid #e3e9ee; padding-bottom: 6px; }
.cm-ov-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-chip { min-width: 46px; min-height: 46px; padding: 0 8px; display: inline-grid; place-items: center; font: 700 16px var(--font); color: #444; background: #fff; border: 2px solid #aab4bd; border-radius: 8px; }
button.cm-chip { cursor: pointer; }
.cm-chip.done { color: #1e5a1e; background: #e9f5e3; border-color: #5b9a45; }
.cm-chip.blank { color: #84540f; background: #fff7e6; border-color: #d9a040; }
.cm-chip.now { color: #fff; background: #2c76b0; border-color: #1f5f94; }
.cm-chip.later { color: #8a959d; background: #f3f6f9; border-style: dashed; }
.cm-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.cm-legend i { display: inline-block; width: 14px; height: 14px; margin-right: 5px; vertical-align: -2px; border: 2px solid; border-radius: 4px; }
.cm-url { display: flex; gap: 8px; margin: 6px 0; }
.cm-url input { flex: 1; min-width: 0; min-height: 44px; padding: 0 10px; font: 14px Arial, sans-serif; border: 1.5px solid #9bb7cf; border-radius: 8px; }
.cm-qr { display: grid; place-items: center; margin: 10px auto; padding: 10px; width: 232px; max-width: 100%; background: #fff; border: 1px solid #d6e2ec; border-radius: 8px; }
.cm-qr svg { width: 100%; height: auto; display: block; }

/* ---- results: name for the certificate, sharing ---- */
.cm-name, .cm-sharebar { margin: 14px 0; padding: 12px 14px; background: #fff8e7; border: 1px solid #f0d9a8; border-radius: 10px; }
.cm-sharebar { background: #eef6fb; border-color: #cfe1ee; }
.cm-name label { display: block; margin-bottom: 6px; font-weight: 700; }
.cm-name .cm-url input { font-family: inherit; font-size: 16px; }
.cm-sharebar .cm-quick { margin-top: 0; }

/* ---- home: install, share, collapsed parts ---- */
.hm .hm-unit { grid-template-columns: 22px 92px 1fr auto auto; }
@media (max-width: 820px) { .hm .hm-unit { grid-template-columns: 24px 1fr auto auto; } }
.hm-install { margin: 12px 0 0; padding: 12px 14px; background: #eaf6f2; border: 1px solid #b9ddd2; border-radius: 12px; font-size: 15.5px; line-height: 1.7; }
.hm-install[hidden] { display: none; }
.hm-install button { margin-top: 6px; }
.hm-share { flex: none; align-self: center; min-width: 40px; min-height: 40px; padding: 0 10px; font: 600 14px var(--font); color: #1f6f5e; background: transparent; border: 1.5px solid #b9ddd2; border-radius: 999px; cursor: pointer; }
.hm-share:hover { background: #eaf6f2; }
.hm .hm-fold { margin: 14px 0 6px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.hm .hm-fold > summary { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 10px 18px; font-weight: 700; font-size: 16.5px; cursor: pointer; list-style: none; }
.hm .hm-fold > summary::-webkit-details-marker { display: none; }
.hm .hm-fold > summary::after { content: '▾'; margin-left: auto; color: var(--ink-3); }
.hm .hm-fold[open] > summary::after { content: '▴'; }
.hm .hm-fold > summary small { font-weight: 400; color: var(--ink-3); }
.hm .hm-fold > .hm-fold-in { padding: 0 18px 16px; }
.hm .hm-fold .hm-who, .hm .hm-fold .hm-how { margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
.hm .hm-go { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }
.hm .hm-go .hm-btn { flex: 1 1 220px; min-height: 52px; font-size: 17px; }
@media (max-width: 820px) {
  .hm .hm-intro { padding: 16px 0 4px; }
  .hm .hm-eyebrow { margin-bottom: 8px; font-size: 13px; }
  .hm .hm-intro h1 { font-size: 26px; margin: 0 0 6px; }
  .hm .hm-lead { font-size: 16px; line-height: 1.7; margin: 6px 0; }
  .hm .hm-facts { font-size: 13px; line-height: 1.6; }
  .hm .hm-bar-start { position: sticky; bottom: 0; }
}

@media (prefers-reduced-motion: reduce) { .cm-toast { transition: none; } }
@media print { .cm-dock, .cm-toast, .cm-zoom-back { display: none !important; } }

/* ---- the certificate: Khmer M1 / Khmer OS Battambang / Times New Roman, in the gold ornamental frame ---- */
@font-face { font-family: 'Khmer M1'; src: url('../fonts/KhmerM1.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'Khmer OS Battambang'; src: url('../fonts/KhmerOSBattambang.woff') format('woff'); font-display: swap; }
@font-face { font-family: 'Tinos'; font-style: normal; font-weight: 400; src: url('../fonts/tinos-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Tinos'; font-style: italic; font-weight: 400; src: url('../fonts/tinos-latin-400-italic.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Tinos'; font-style: normal; font-weight: 700; src: url('../fonts/tinos-latin-700-normal.woff2') format('woff2'); font-display: swap; }

.pisa-cert-wrap { display: block; overflow: visible; padding: 4px; margin: 24px auto; max-width: 1000px; container-type: inline-size; }
.cert2 { position: relative; width: 100%; aspect-ratio: 2400 / 1696; overflow: hidden; background: #fff url('../assets/img/frame-certificate.png') center / 100% 100% no-repeat; color: #2a1f14; font-size: 9px; --u: 9px; font-size: 1cqw; --u: 1cqw; line-height: 1.3; box-shadow: 0 14px 36px rgba(60, 20, 10, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06); text-align: center; }
.cert2 * { box-sizing: border-box; }
.cert2 .m1 { font-family: 'Khmer M1', 'Khmer OS Muol Light', 'Noto Sans Khmer Local', serif; font-weight: 400; }
.cert2 .kh { font-family: 'Khmer OS Battambang', 'Noto Sans Khmer Local', 'Khmer Sangam MN', serif; }
.cert2 .en { font-family: 'Times New Roman', Tinos, 'Liberation Serif', Times, serif; }
.cert2 b.en, .cert2 .en b { font-weight: 700; }
.c2-stage { position: absolute; inset: 0; transform: scale(0.9); transform-origin: 50% calc(var(--u) * 8.4); }
.c2-stage > * { position: absolute; left: 0; right: 0; margin: 0; padding: 0; }
.c2-title { top: calc(var(--u) * 9.4); font-size: 3.25em; line-height: 1.5; color: #a4201a; letter-spacing: 0.02em; }
.c2-sub { top: calc(var(--u) * 14.6); font-size: 2.9em; line-height: 1.2; color: #3b2a1a; }
.c2-pres { top: calc(var(--u) * 19.2); font-size: 2.4em; line-height: 1.6; color: #3b2a1a; }
.c2-pres2 { top: calc(var(--u) * 23); font-size: 2.3em; line-height: 1.25; color: #3b2a1a; }
.c2-name { top: calc(var(--u) * 26.6); line-height: 1.7; color: #8a5412; white-space: nowrap; }
.c2-rule { top: calc(var(--u) * 35.4); left: calc(var(--u) * 28) !important; right: calc(var(--u) * 28) !important; height: calc(var(--u) * 0.18); background: linear-gradient(90deg, transparent, #b7893a 14%, #b7893a 86%, transparent); }
.c2-rule i { position: absolute; left: 50%; top: 50%; width: calc(var(--u) * 1.1); height: calc(var(--u) * 1.1); background: #b7893a; transform: translate(-50%, -50%) rotate(45deg); box-shadow: 0 0 0 calc(var(--u) * 0.35) #fff; }
.c2-who { top: calc(var(--u) * 36.4); left: calc(var(--u) * 30) !important; right: calc(var(--u) * 30) !important; font-size: 1.95em; line-height: 1.55; color: #5a4632; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c2-body { top: calc(var(--u) * 40.4); left: calc(var(--u) * 13) !important; right: calc(var(--u) * 13) !important; font-size: 2.05em; line-height: 1.75; color: #2a1f14; }
.c2-body b { font-weight: 700; color: #a4201a; }
.c2-topics { top: calc(var(--u) * 47.8); left: calc(var(--u) * 13) !important; right: calc(var(--u) * 13) !important; font-size: 1.8em; line-height: 1.65; color: #5a4632; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c2-body2 { top: calc(var(--u) * 51); left: calc(var(--u) * 12) !important; right: calc(var(--u) * 12) !important; font-size: 1.9em; line-height: 1.3; color: #4a3a2a; }
.c2-body2 b { font-weight: 700; }
.c2-seal { top: calc(var(--u) * 54.6); left: calc(var(--u) * 45) !important; right: calc(var(--u) * 45) !important; height: calc(var(--u) * 10); }
.c2-seal svg { display: block; width: calc(var(--u) * 10); height: calc(var(--u) * 10); margin: 0 auto; filter: drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.3) rgba(80, 50, 10, 0.35)); }
.c2-sign, .c2-date { display: flex; flex-direction: column; align-items: center; top: calc(var(--u) * 59.4); }
.c2-sign { left: calc(var(--u) * 15) !important; right: auto !important; width: calc(var(--u) * 26); }
.c2-date { right: calc(var(--u) * 15) !important; left: auto !important; width: calc(var(--u) * 26); }
.c2-line { width: 100%; height: calc(var(--u) * 0.15); background: #8b7a62; margin-bottom: calc(var(--u) * 0.45); }
.c2-sign b, .c2-date b { font-size: 2.1em; line-height: 1.45; color: #2a1f14; font-weight: 700; white-space: nowrap; }
.c2-sign span, .c2-date span { font-size: 1.65em; line-height: 1.3; color: #4a3a2a; white-space: nowrap; }
.c2-foot { top: calc(var(--u) * 65.9); font-size: 1.35em; line-height: 1.5; color: #7a6a58; }
.c2-stage > .c2-side { top: calc(var(--u) * 8.8); width: calc(var(--u) * 16); left: auto; right: auto; display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.25); }
.c2-left { left: calc(var(--u) * 8.5) !important; }
.c2-right { right: calc(var(--u) * 8.5) !important; }
.c2-left img { width: calc(var(--u) * 9); height: calc(var(--u) * 9); object-fit: contain; margin-bottom: calc(var(--u) * 0.4); }
.c2-left b { font-size: 2.1em; line-height: 1.45; color: #1a7f6b; }
.c2-side .kh { font-size: 1.75em; line-height: 1.5; color: #a4201a; white-space: nowrap; }
.c2-side .en { font-size: 1.6em; line-height: 1.3; color: #4a3a2a; white-space: nowrap; }
.c2-badge { width: calc(var(--u) * 9); height: calc(var(--u) * 9); margin-bottom: calc(var(--u) * 0.4); border-radius: 50%; border: calc(var(--u) * 0.45) solid #1a7f6b; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; box-shadow: inset 0 0 0 calc(var(--u) * 0.22) #d9a441; }
.c2-badge b { font: 700 2.6em/1 'Times New Roman', Tinos, serif; color: #1a7f6b; }
.c2-badge i { font: italic 700 1.9em/1.1 'Times New Roman', Tinos, serif; color: #a4201a; }
@media print {
  /* «បោះពុម្ពវិញ្ញាបនបត្រ»: the certificate alone, whatever else the results page holds. It fills the printable width
     (A4 landscape, margins None: 297 x 210 mm; with the browser's default margins it is simply a little smaller). */
  @page { size: 297mm 210mm; margin: 0; }
  body.print-cert-only .results > :not(.res-sec) { display: none !important; }
  body.print-cert-only .res-sec-h { display: none !important; }
  body.print-cert-only, body.print-cert-only #app, body.print-cert-only .km-res-main { background: #fff !important; padding: 0 !important; }
  body.print-cert-only .km-wrap { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  body.print-cert-only, html:has(body.print-cert-only) { width: auto !important; height: auto !important; }
  .pisa-cert-wrap { width: 100% !important; height: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; display: block !important; }
  .cert2 { width: 100% !important; height: auto !important; min-width: 0 !important; aspect-ratio: 2400 / 1696 !important; box-shadow: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; page-break-inside: avoid; }
}

/* the certificate opened large on a phone */
.c2-zoom { display: none; }
@media (max-width: 700px) { .c2-zoom { display: inline-flex; } .pisa-cert-wrap { text-align: center; } }
.cm-zoom-body > .pisa-cert-wrap { width: 1000px; max-width: none; margin: 0 auto; padding: 0; background: transparent; }
.cm-zoom-body .c2-zoom { display: none; }
@media (max-width: 860px) { .res-unit, .km .rv-card { overflow-x: auto; } }
@media print { .c2-zoom { display: none !important; } }

.c2-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0 0; }
@media print { .c2-acts { display: none !important; } }
