/* Certificate Maker (Batch 1, tool three). The certificates' own styles are /certificates/certificates.css. */

/* ---------- the design picker ---------- */
.cm-design-groups { display: grid; gap: 14px; }
.cm-design-group__h { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--slate); }
.cm-design-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cm-design { position: relative; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.cm-design input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cm-thumb { position: relative; display: block; width: 100%; aspect-ratio: 1123 / 794; overflow: hidden; border-radius: 8px; border: 2px solid var(--silver); background: var(--white); }
.cm-thumb .cert { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--cm-thumb, 0.13)); pointer-events: none; }
/* A small picture: in the house face, so opening the page never loads all sixteen design faces. */
.cm-thumb .cert, .cm-thumb .cert * { font-family: "Instrument Sans", sans-serif !important; }
.cm-design input:checked + .cm-thumb { border-color: var(--graphite); box-shadow: 0 0 0 2px var(--graphite); }
.cm-design input:focus-visible + .cm-thumb { outline: 3px solid var(--graphite); outline-offset: 2px; }
.cm-design__name { font-size: 14px; line-height: 1.25; }

/* ---------- colour ---------- */
.cm-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cm-swatch { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; cursor: pointer; font-size: 15px; }
.cm-swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cm-swatch__dot { display: block; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--silver); }
.cm-swatch__dot--custom { border-style: dashed; border-color: var(--slate); }
.cm-swatch__dot--mono { background: linear-gradient(135deg, var(--graphite) 50%, var(--white) 50%); }
.cm-swatch input:checked + .cm-swatch__dot { box-shadow: 0 0 0 3px var(--graphite); }
.cm-swatch input:focus-visible + .cm-swatch__dot { outline: 3px solid var(--graphite); outline-offset: 3px; }
.cm-custom { margin-top: 12px; }
.cm-custom > label { display: block; font-weight: 600; }
.cm-custom__row { display: flex; gap: 10px; align-items: center; }
.cm-picker { width: 52px; height: 44px; padding: 0; border: 1px solid var(--silver); border-radius: 8px; background: none; }
.cm-hex { max-width: 9em; text-transform: uppercase; }
.cm-colour-note { margin: 8px 0 0; font-size: 15px; }
.cm-colour-note.is-warn { color: var(--graphite); }
.cm-colour-note .btn { margin-top: 6px; }

/* ---------- names, the table, held details, problems ---------- */
.cm-status { margin: 6px 0 0; font-size: 14px; color: var(--slate); }
.cm-status.is-over { color: var(--graphite); font-weight: 600; }
.cm-table-wrap { margin-top: 10px; overflow-x: auto; }
.cm-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.cm-table th, .cm-table td { padding: 6px 4px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--mist); }
.cm-table thead th { font-size: 13px; font-weight: 600; color: var(--slate); }
.cm-table__n { width: 2em; color: var(--slate); }
.cm-table__name { font-weight: 600; min-width: 7em; }
.cm-table .input { width: 100%; min-width: 8em; min-height: 40px; font-size: 15px; }
.cm-table textarea.input { resize: vertical; }
.cm-table-empty { margin: 6px 0 0; color: var(--slate); }
.cm-held { margin: 0 0 16px; padding: 14px; border: 2px solid var(--graphite); border-radius: 10px; }
.cm-held__h { margin: 0 0 4px; font-size: 17px; }
.cm-held__intro { margin: 0 0 10px; font-size: 15px; }
.cm-held__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.cm-held__why { margin: 0; font-weight: 600; }
.cm-held__what { margin: 2px 0 0; font-size: 15px; }
.cm-held__do { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cm-held__to { flex: 1 1 12em; min-height: 44px; }
.cm-problems { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--mist); color: var(--graphite); font-size: 15px; }
.cm-problems__list { margin: 0; padding: 0 0 0 18px; display: grid; gap: 8px; }
.cm-problem__go { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; text-decoration: underline; cursor: pointer; }
.cm-problem__act { margin: 4px 6px 0 0; min-height: 36px; }
.cm-problems__more { margin: 8px 0 0; }

/* ---------- the preview: one certificate at a time, scaled to fit ---------- */
.cm-nav { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.cm-nav__label { flex: 1; margin: 0; font-size: 15px; text-align: center; color: var(--slate); }
.cm-stage { --cm-scale: .5; position: relative; width: 100%; }
@media screen {
  .cm-stage { height: calc(794px * var(--cm-scale)); overflow: hidden; border-radius: 6px; box-shadow: 0 2px 16px rgba(0, 0, 0, .14); background: var(--white); }
  /* The preview: a copy of the certificate being looked at, scaled to fit. */
  .cm-view { position: relative; width: 1123px; height: 794px; transform: scale(var(--cm-scale)); transform-origin: 0 0; }
  /* Every certificate, laid out at full size off screen: fitted and checked there, printed and put in the PDF from
     there. Nothing is ever shown by un-hiding it. */
  .cm-sheets { position: absolute; left: -40000px; top: 0; width: 1123px; pointer-events: none; }
}

/* ---------- paper: every certificate, one per A4 landscape sheet, edge to edge ---------- */
@page { size: A4 landscape; margin: 0; }
@page :first { margin: 0; }
@media print {
  .cm-nav, .cm-stage, template { display: none !important; }
  .cm-sheets { position: static !important; left: auto !important; width: auto !important; }
  #sheet.cm-sheet { margin: 0 !important; padding: 0 !important; }
}

/* ---------- phones: each person's row becomes a small card ---------- */
@media screen and (max-width: 640px) {
  .cm-table thead { display: none; }
  .cm-table, .cm-table tbody { display: block; width: 100%; }
  .cm-table tr { display: grid; grid-template-columns: 2em minmax(0, 1fr) 44px; grid-template-areas: "n name clear" ". award award" ". msg msg"; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--mist); }
  .cm-table th, .cm-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .cm-table__n { grid-area: n; } .cm-table__name { grid-area: name; align-self: center; }
  .cm-table td:nth-child(3) { grid-area: award; } .cm-table td:nth-child(4) { grid-area: msg; } .cm-table td:nth-child(5) { grid-area: clear; }
  .cm-table .input { min-width: 0; }
}
.cm-own, .cm-table-wrap { min-width: 0; max-width: 100%; }
