/* ==========================================================================
   Things to keep: stamps (public/js/stamps.js) and the end-of-level certificate
   (public/js/certificate.js). On wide screens and in print the certificate is two
   real A4 pages (mm and pt); on phones the pages reflow so they stay readable.
   ========================================================================== */
.ve-stamp { display: inline-block; max-width: 100%; height: auto; overflow: visible; vertical-align: middle; }

/* ---------- certificate: the page around it ---------- */
.ct-wrap { padding-bottom: 48px; }
.ct-pages {
  --ct-paper: #FFFDF7; --ct-frame: #BFAE8C; --ct-ink-michal: #3E6E8E;
  display: grid; gap: 24px; justify-items: center; margin-top: 18px;
}
html.theme-night .ct-pages, html.theme-dark .ct-pages { --ct-paper: #2A2723; --ct-frame: #5E5546; --ct-ink-michal: #8DB3D0; }
.ct-top { display: grid; gap: 12px; grid-template-columns: 1fr; align-items: end; max-width: 210mm; margin: 0 auto; }
.ct-top h1 { margin: 6px 0 0; font-size: clamp(1.6rem, 4.6vw, 2.2rem); }
.ct-top-t p { margin: 4px 0 0; }
.ct-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-acts .btn { flex: 1 1 auto; }
.ct-hint { margin: 0; }
.ct-preview { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); border: 1px dashed rgba(var(--accent-rgb), .5); }
@media (min-width: 820px) {
  .ct-top { grid-template-columns: 1fr auto; }
  .ct-acts .btn { flex: 0 0 auto; }
  .ct-hint, .ct-preview { grid-column: 1 / -1; }
}

/* ---------- certificate: one page (phones: reflowing paper) ---------- */
.ct-page {
  position: relative; box-sizing: border-box; width: 100%; max-width: 210mm; aspect-ratio: 210 / 297;
  background: var(--ct-paper); color: var(--text); border: 1px solid var(--ct-frame);
  box-shadow: 0 14px 40px rgba(var(--shadow-rgb), .10);
  padding: 30px 22px 24px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.45; overflow: hidden;
}
.ct-frame { position: absolute; inset: 10px; border: 1px solid var(--ct-frame); pointer-events: none; }
.ct-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ct-teide { width: 150px; height: auto; }
.ct-brand b { font: 400 15px/1.2 var(--serif); }
.ct-brand b em { color: var(--accent); font-style: italic; }
.ct-title { text-align: center; font: 400 1.6rem/1.1 var(--serif); margin: 10px 0 0; letter-spacing: -.01em; }
.ct-title small { display: block; font: 500 var(--fs-xs)/1.3 var(--sans); color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; margin-top: 6px; }
.ct-title-2 { font-size: 1.3rem; margin-top: 4px; }
.ct-name { text-align: center; font: italic 400 1.75rem/1.2 var(--serif); margin: 14px auto 0; padding: 0 12px 6px; border-bottom: 1px solid var(--ct-frame); min-width: 60%; overflow-wrap: anywhere; }
.ct-what { text-align: center; color: var(--text-2); margin: 4px 0 0; }
.ct-what b { display: block; color: var(--text); font: 400 1.25rem/1.3 var(--serif); margin: 2px 0; }
.ct-path { width: 100%; max-width: 420px; height: auto; margin: 10px auto 0; display: block; }
.ct-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-top: 4px; }
.ct-stats b { display: block; font: 400 1.3rem/1.2 var(--serif); }
.ct-stats span { font-size: var(--fs-xs); color: var(--text-3); }
.ct-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.ct-sig { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
.ct-sig i { display: block; font: italic 400 1.6rem/1 var(--serif); color: var(--ct-ink-michal); margin-bottom: 2px; }
.ct-sig-line { display: block; width: 150px; max-width: 100%; border-top: 1px solid var(--ct-frame); margin: 2px 0 4px; }
.ct-seal { flex: 0 0 auto; width: 96px; }
.ct-seal .ve-stamp { width: 100%; height: auto; }
.ct-fine { font-size: var(--fs-xs); color: var(--text-3); text-align: center; margin: 0; }
.ct-h { margin: 8px 0 2px; font: 400 1.05rem/1.25 var(--serif); color: var(--accent-2); }
.ct-page ul { margin: 0; padding-left: 16px; display: grid; gap: 2px; font-size: 12px; }
.ct-two { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
.ct-phrases li { font-family: var(--serif); font-size: 13px; }
.ct-phrases .ct-more { font-family: var(--sans); font-size: var(--fs-xs); color: var(--text-3); list-style: none; margin-left: -16px; }
.ct-next { margin-top: auto; padding-top: 10px; }
@media (max-width: 819px) { .ct-page { aspect-ratio: auto; min-height: 140vw; } }
@media (min-width: 460px) { .ct-two { grid-template-columns: 1fr 1fr; } }

/* ---------- certificate: the A4 layout (wide screens and print) ---------- */
.ct-fixed .ct-page { width: 210mm; max-width: none; height: 297mm; aspect-ratio: auto; min-height: 0; padding: 17mm 16mm 13mm; gap: 2.4mm; font-size: 10.5pt; }
.ct-fixed .ct-frame { inset: 6mm; }
.ct-fixed .ct-brand { margin-top: 2mm; }
.ct-fixed .ct-teide { width: 46mm; }
.ct-fixed .ct-brand b { font-size: 12pt; }
.ct-fixed .ct-title { font-size: 27pt; margin-top: 9mm; }
.ct-fixed .ct-title small { font-size: 8pt; margin-top: 2.2mm; }
.ct-fixed .ct-name { font-size: 30pt; margin-top: 13mm; min-width: 70%; padding-bottom: 2mm; }
.ct-fixed .ct-what { font-size: 10.5pt; margin-top: 3mm; }
.ct-fixed .ct-what b { font-size: 19pt; margin: 1.2mm 0; }
.ct-fixed .ct-path { width: 128mm; margin: 9mm auto 2mm; }
.ct-fixed .ct-stats { margin-top: 8mm; gap: 3mm; }
.ct-fixed .ct-stats b { font-size: 20pt; }
.ct-fixed .ct-stats span { font-size: 8.5pt; }
.ct-fixed .ct-sig { font-size: 9pt; }
.ct-fixed .ct-sig i { font-size: 24pt; }
.ct-fixed .ct-sig-line { width: 62mm; }
.ct-fixed .ct-seal { width: 36mm; }
.ct-fixed .ct-fine { font-size: 7.5pt; }
.ct-fixed .ct-p1 .ct-fine { margin-top: 3mm; }
.ct-fixed .ct-title-2 { font-size: 20pt; margin-top: 2mm; }
.ct-fixed .ct-h { font-size: 13pt; margin: 3.4mm 0 .8mm; }
.ct-fixed .ct-page ul { font-size: 9.5pt; row-gap: .5mm; padding-left: 4.5mm; }
.ct-fixed .ct-can ul { display: block; columns: 2; column-gap: 9mm; }
.ct-fixed .ct-can li { break-inside: avoid; margin-bottom: .6mm; }
.ct-fixed .ct-two { grid-template-columns: 1fr 1fr; column-gap: 8mm; }
.ct-fixed .ct-phrases li { font-size: 11pt; }
.ct-fixed .ct-phrases .ct-more { font-size: 9pt; margin-left: -4.5mm; }
/* long levels: a little tighter, so page 2 stays one page */
.ct-fixed .ct-dense ul { font-size: 8.8pt; row-gap: 0; }
.ct-fixed .ct-dense .ct-h { margin-top: 2.4mm; font-size: 12pt; }
.ct-fixed .ct-denser ul { font-size: 8pt; row-gap: 0; line-height: 1.3; }
.ct-fixed .ct-denser .ct-h { margin-top: 1.8mm; font-size: 11pt; }
.ct-fixed .ct-denser .ct-phrases li { font-size: 9.5pt; }

/* ---------- certificate: not yet ---------- */
.ct-locked { text-align: center; display: grid; justify-items: center; gap: 12px; padding: 28px 20px; }
.ct-locked-h { font-size: clamp(1.3rem, 4.2vw, 1.8rem); margin: 0; max-width: 28ch; }
.ct-locked .muted { margin: 0; }
.ct-bar-prog { width: min(320px, 100%); height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.ct-bar-prog i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* ---------- profile: feedback from your tutor ---------- */
.fb-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; border: 0; padding: 0; min-width: 0; }
.fb-choice legend { padding: 0; margin-bottom: 8px; font-weight: 600; grid-column: 1 / -1; }
.fb-choice label { position: relative; display: grid; place-items: center; gap: 2px; min-height: 44px; padding: 8px 6px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; text-align: center; font-size: 14px; background: var(--surface); }
.fb-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fb-choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.fb-choice label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- print: the two pages only, light, A4 ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html.ct-on, html.ct-on body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  html.ct-on body::before, html.ct-on body::after { display: none !important; }
  html.ct-on body > *:not(#app) { display: none !important; }
  html.ct-on #app { padding: 0 !important; margin: 0 !important; min-height: 0 !important; }
  html.ct-on #app > * { padding: 0 !important; margin: 0 !important; max-width: none !important; width: auto !important; }
  html.ct-on #app > * > *:not(.ct-pages) { display: none !important; }
  html.ct-on .ct-pages, html.ct-on .ct-pages * { visibility: visible !important; }
  html.ct-on .ct-pages {
    display: block; margin: 0; gap: 0;
    --ct-paper: #FFFDF7; --ct-frame: #BFAE8C; --ct-ink-michal: #3E6E8E;
    --text: #1F1D1A; --text-2: #5E5950; --text-3: #756E63; --line-strong: #C9C2B4;
    --accent: #C86D51; --accent-2: #A0533A; --accent-soft: rgba(200, 109, 81, .12); --accent-rgb: 200, 109, 81;
  }
  html.ct-on .ct-page {
    width: 210mm !important; height: 297mm !important; max-width: none !important; aspect-ratio: auto !important; min-height: 0 !important;
    margin: 0 !important; border: 0 !important; box-shadow: none !important;
    break-after: page; page-break-after: always; break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  html.ct-on .ct-page:last-child { break-after: auto; page-break-after: auto; }
}
