/* ==========================================================================
   Labour Life practice system: templates.css (SPEC 7.3). Owner: templates (M3).
   Admin > Templates, the template page, Admin > Disciplinary codes and the
   Make a document screen. Class prefixes tpl- and gen-.

   This file only ADDS classes. It restates nothing from the core files and
   uses tokens only. Phone first: the base styles are the phone.

     .tpl-code                         a placeholder as it is typed in Word
     .tpl-h (--flush), .tpl-h3, .tpl-lead, .tpl-example   card headings and lead lines
     .tpl-cols, .tpl-main, .tpl-side   the template page: cards and the cheat sheet
     .tpl-problems (__list __row)      the Problems card
     .tpl-flist, .tpl-f (__ph __grid __req)   the Fields card: one row per placeholder
     .tpl-ver, .tpl-wrap, .tpl-vact, .tpl-acts   the Versions table and its row buttons
     .tpl-sheet (__g __list __row __b __l __e, .is-open), .tpl-sheet-toggle, .tpl-copy, .tpl-pre
     .tpl-code-id, .tpl-clip           the disciplinary code list
     .gen, .gen-form, .gen-h, .gen-lead, .gen-hint   Make a document
     .gen-rows, .gen-row (__head __top __t __n __code __acts)   charges and rows
     .gen-file (__n), .gen-bar (__btn) the file name, the bar with the red button
     .gen-codes (__g), .gen-code (__c) the dialog that lists the charges
     .tpl-sets (__tabs __acts __lead)  the code sets of Admin, Disciplinary codes (decision 366)
     .gen-disc (__body __acts)         the progressive discipline note (decision 367)
     .gen-list--in, .gen-again, .gen-code__s   the list at its place, "Fill it again", a charge's sanction (5 Nov 2026)
     .gen-find (__q __hint __n __none) the search box of the charges window (9 Nov 2026)
     .tpl-xl (__file __sum __keep __sec __h __list __row __head __why __tbl __f __v __same)   the codes from Excel: the check (9 Nov 2026)
   ========================================================================== */

/* ---------- shared bits ---------- */

.tpl-code {
  display: inline-block; max-width: 100%; padding: 1px var(--s2);
  border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--sunken);
  font: 400 var(--fs-sm)/1.5 var(--font-mono); color: var(--ink); overflow-wrap: anywhere;
}
.tpl-h { margin-bottom: var(--s4); font-size: var(--fs-h3); }
.tpl-h--flush { margin: 0; padding: var(--s4); }
@media (min-width: 720px) { .tpl-h--flush { padding: var(--s4) var(--s5); } }
.tpl-h3 { margin: var(--s5) 0 var(--s1); font-size: var(--fs-lg); }
.tpl-lead { margin-bottom: var(--s4); }
.tpl-h3 + .fine { margin-bottom: var(--s3); }
.tpl-example { margin: calc(var(--s2) * -1) 0 var(--s4); overflow-wrap: anywhere; }

/* ---------- the template page ---------- */

.tpl-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.tpl-cols > * { min-width: 0; }
.tpl-main { display: grid; gap: var(--s5); align-content: start; min-width: 0; }
.tpl-main > * { min-width: 0; }
.tpl-side { display: grid; gap: var(--s3); align-content: start; }

/* On a phone the cheat sheet waits behind its button. */
.tpl-sheet { display: none; }
.tpl-sheet.is-open { display: block; }
.tpl-sheet-toggle { justify-self: start; }

@media (min-width: 960px) {
  .tpl-cols { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
  .tpl-sheet-toggle { display: none; }
  .tpl-side { display: block; }
  /* It stays in view while the cards on the left scroll. */
  .tpl-sheet, .tpl-sheet.is-open {
    display: block; position: sticky; top: var(--s4);
    max-height: calc(100vh - var(--top-h) - var(--s6)); overflow-y: auto; overscroll-behavior: contain;
  }
}

.tpl-problems__list { display: grid; }
.tpl-problems > .note { margin-bottom: var(--s4); }
.tpl-problems__row {
  display: grid; gap: var(--s1); justify-items: start;
  padding: var(--s3) 0; border-top: 1px solid var(--line);
}
.tpl-problems__row:first-child { border-top: 0; padding-top: 0; }
.tpl-problems__row:last-child { padding-bottom: 0; }

/* ---------- the Fields card ---------- */

.tpl-flist { display: grid; }
.tpl-f { padding: var(--s4) 0 0; border-top: 1px solid var(--line-strong); }
.tpl-f:first-child { border-top: 0; padding-top: 0; }
.tpl-f__ph { margin-bottom: var(--s2); }
.tpl-f__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--s4); }
.tpl-f__req { align-content: end; }
.tpl-fields form > .note { margin-bottom: var(--s4); }
@media (min-width: 720px) {
  .tpl-f__grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; align-items: start; }
  /* The kind of answer (5 Nov 2026) and the default value of a typed field share a line under the label. */
  .tpl-f__grid > .tpl-f__type { grid-column: 1; grid-row: 2; }
  .tpl-f__grid > .tpl-f__def { grid-column: 2 / -1; grid-row: 2; }
  .tpl-f__req { grid-column: 3; grid-row: 1; padding-top: calc(var(--fs-sm) * 1.5 + var(--s1)); }
}

/* ---------- the Versions table ---------- */

.tpl-ver { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-weight: 600; }
.tpl-wrap { overflow-wrap: anywhere; }
@media (min-width: 720px) { .tpl-wrap { max-width: 18rem; } }
/* Two buttons on a row: "Use this version" and Download. On a phone they sit under the row's values. */
.tpl-acts { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); }
@media (max-width: 719px) {
  .tbl--collapse td.tbl__act.tpl-vact { position: static; padding: var(--s2) 0 0; text-align: left; }
  .tpl-acts { justify-content: flex-start; }
  .tpl-acts .btn { min-height: var(--tap); }
}

/* ---------- the cheat sheet ---------- */

.tpl-sheet__g { margin: var(--s5) 0 var(--s2); }
.tpl-sheet__list { display: grid; }
.tpl-sheet__row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0; border-top: 1px solid var(--line);
}
.tpl-sheet__row:first-child { border-top: 0; }
.tpl-sheet__b { display: grid; gap: 2px; justify-items: start; min-width: 0; }
.tpl-sheet__l { font-size: var(--fs-sm); color: var(--ink-soft); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.tpl-sheet__e { color: var(--ink-mute); }
.tpl-copy { flex: none; }
.tpl-pre {
  margin-top: var(--s2); padding: var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--sunken); font: 400 var(--fs-sm)/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- disciplinary codes ---------- */

.tpl-code-id { font-weight: 600; white-space: nowrap; }
/* The wording in the list: two lines, then cut. */
.tpl-clip {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  max-width: 34rem; overflow: hidden; color: var(--ink-soft); font-size: var(--fs-sm);
}

/* ---------- Make a document ---------- */

.gen, .gen-form, .gen-lists { display: grid; gap: var(--s5); min-width: 0; }
.gen > *, .gen-form > *, .gen-lists > * { min-width: 0; }
.gen-lists:empty { display: none; }
.gen-pick > .field:last-child, .gen-fields > .field:last-child { margin-bottom: 0; }
.gen-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); margin-bottom: var(--s2); font-size: var(--fs-h3); }
.gen-h > .field__req { font: 400 var(--fs-sm)/1.3 var(--font-body); letter-spacing: 0; text-transform: none; }
.gen-lead { margin-bottom: var(--s4); }
.gen-hint { text-align: center; padding: var(--s4) 0; }

/* "The worker is not loaded yet": one tap, the whole row, under the worker picker. */
.gen-nowork {
  align-items: center; margin-top: var(--s2); padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg);
}
.gen-nowork:has(input:checked) { border-color: var(--info-line); background: var(--info-bg); }
/* The typed worker details. With no worker fields in the template only the line shows. */
.gen-typed__lead { margin: 0; }
.gen-typed > .gen-fields:empty { display: none; }
.gen-typed > .gen-fields:not(:empty) { margin-top: var(--s4); }

.gen-list__body { margin: var(--s3) 0 0; gap: var(--s3); }
.gen-rows { display: grid; gap: var(--s3); }
.gen-row {
  padding: var(--s3) var(--s4) 0; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg);
}
.gen-row__head { margin-bottom: var(--s2); }
.gen-row__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-width: 0; }
.gen-row__t { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); min-width: 0; }
.gen-row__n { font-weight: 700; }
.gen-row__code { font: 400 var(--fs-sm)/1.4 var(--font-mono); color: var(--ink-soft); }
.gen-row__acts { display: flex; align-items: center; flex: none; }

.gen-file { display: grid; gap: var(--s1); }
.gen-file__n { font-weight: 600; overflow-wrap: anywhere; }
.gen-end > .note { margin-top: var(--s4); }

/* The red button. On a phone it stays at the bottom of the screen, above the bottom bar. */
.gen-bar { display: flex; justify-content: flex-end; }
@media (max-width: 719px) {
  .gen-bar {
    position: sticky; bottom: 0; z-index: var(--z-sticky);
    margin: 0 calc(var(--gutter) * -1); padding: var(--s3) var(--gutter);
    background: var(--bg); border-top: 1px solid var(--line-strong);
  }
  .gen-bar__btn { flex: 1 1 100%; }
}

/* The dialog with the charges, grouped by category. */
.gen-codes { display: grid; gap: var(--s4); }
.gen-codes__g { display: grid; min-width: 0; margin: 0; padding: 0; border: 0; }
.gen-codes__g > legend { padding: 0; margin-bottom: var(--s1); }
.gen-code { border-top: 1px solid var(--line); }
.gen-codes__g > .gen-code:first-of-type { border-top: 0; }
.gen-code__c { font-weight: 700; margin-right: var(--s1); }

@media (forced-colors: active) {
  .tpl-code, .tpl-pre, .gen-row { border: 1px solid CanvasText; }
}

@media print {
  .gen-bar, .tpl-sheet-toggle, .tpl-copy { display: none !important; }
}

/* 30 Oct 2026 (decision 357): Leave out under every field of Make a document. The field stays empty in this
   document only; the box goes grey and its required mark goes. */
.gen-out { display: inline-flex; align-items: center; gap: var(--s1); margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-soft); cursor: pointer; min-height: 32px; }
.gen-out__box { width: 16px; height: 16px; margin: 0; }
.field.is-left-out .field__req { display: none; }
.field.is-left-out .input, .field.is-left-out textarea { opacity: .55; }
@media (pointer: coarse) { .gen-out { min-height: var(--tap); } }

/* 30 Oct 2026 (decision 359): Make documents for many employees (components/make-many.js). */
.gen-many { display: grid; gap: var(--s3); }
.gen-many__h { margin: var(--s2) 0 0; }
.gen-many__outs { display: grid; gap: 2px; }
.gen-many__n { margin: 0; font-weight: 600; }
.gen-many__bar { height: 8px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.gen-many__bar > span { display: block; height: 100%; width: 0; background: var(--success); transition: width var(--dur-2) var(--ease-out); }
.gen-many__fails { margin: 0; padding-left: var(--s4); display: grid; gap: var(--s1); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .gen-many__bar > span { transition: none; } }

/* 2 Nov 2026 (decision 368): different values per employee, from a sheet (components/make-many.js). */
.gen-sheet { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.gen-sheet p { margin: 0; }
.gen-sheet__result { display: grid; gap: var(--s2); }
.gen-sheet__busy { display: flex; align-items: center; gap: var(--s2); color: var(--ink-soft); font-size: var(--fs-sm); }
.gen-sheet__list { margin: var(--s2) 0 0; padding-left: var(--s4); max-height: 240px; overflow: auto; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.gen-sheet__ready summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
@media (pointer: coarse) { .gen-sheet__ready summary { min-height: var(--tap); } }

/* 2 Nov 2026 (decision 366): the code sets of Admin, Disciplinary codes, as tabs, with New set and the
   More menu of the open set beside them. On a phone the tabs scroll sideways and the buttons wrap under. */
.tpl-sets { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s3); margin-bottom: var(--s2); }
.tpl-sets__tabs { flex: 1 1 16rem; min-width: 0; }
.tpl-sets__acts { display: flex; gap: var(--s2); align-items: center; padding-bottom: var(--s1); }
.tpl-sets__lead { margin: 0 0 var(--s4); }

/* 5 Nov 2026: the form follows the document. A list (the charges) sits at its place among the fields, in
   their card, set off by a line above and below; the progressive discipline note right under it. */
.gen-list--in { margin: var(--s2) 0 var(--s4); padding: var(--s4) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gen-list--in > .gen-h { font-size: var(--fs-lg); margin: 0; }
.gen-fields > .gen-disc { margin: 0 0 var(--s4); }
/* "Fill it from the charges again" under a prescribed standard changed by hand. */
.gen-again { display: inline-flex; align-items: center; min-height: 32px; margin-left: var(--s3); font-size: var(--fs-sm); }
@media (pointer: coarse) { .gen-again { min-height: var(--tap); } }
/* The sanction of a charge in the charges window. */
.gen-code__s { display: block; color: var(--ink-soft); overflow-wrap: anywhere; }

/* 2 Nov 2026 (decision 367): progressive discipline on Make a document, the note under the charges. */
.gen-disc__body { display: grid; gap: var(--s3); }
.gen-disc__body > .gen-h { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.gen-disc__body > p { margin: 0; }
.gen-disc__acts { margin: 0; }

/* 9 Nov 2026 (Jose: "When doing warnings etc can we add a search function"): the search box at the top of
   the charges window. The line under it counts the ticked charges, also the ones the search hides. */
.gen-find { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
.gen-find__hint, .gen-find__n { margin: 0; }
.gen-find__n:empty { display: none; }
.gen-find__none { padding: var(--s3) 0; }

/* 9 Nov 2026: the codes from Excel, the check before anything is saved (components/codes-excel.js). */
.tpl-xl { display: grid; gap: var(--s3); min-width: 0; }
.tpl-xl > * { min-width: 0; margin: 0; }
.tpl-xl__sum { gap: var(--s2); }
.tpl-xl__keep > p { margin: 0; }
.tpl-xl__keep > p + p { margin-top: var(--s1); }
.tpl-xl__sec { display: grid; gap: var(--s2); min-width: 0; padding-top: var(--s3); border-top: 1px solid var(--line); }
.tpl-xl__h { margin: 0; font-size: var(--fs-lg); }
.tpl-xl__list { display: grid; gap: var(--s4); margin: 0; padding: 0; list-style: none; }
.tpl-xl__list--plain { gap: var(--s1); padding-top: var(--s2); }
.tpl-xl__row { display: grid; gap: var(--s2); min-width: 0; }
.tpl-xl__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); margin: 0; overflow-wrap: anywhere; }
.tpl-xl__why { margin: 0; color: var(--danger-ink); }
.tpl-xl__tbl { table-layout: fixed; }
.tpl-xl__tbl th, .tpl-xl__tbl td { padding: var(--s2); }
.tpl-xl__f { width: 9rem; text-align: left; vertical-align: top; }
.tpl-xl__tbl tbody th {
  background: transparent; border-bottom: 1px solid var(--line); color: var(--ink);
  font: 600 var(--fs-sm)/1.4 var(--font-body); letter-spacing: 0; text-transform: none; white-space: normal;
}
.tpl-xl__tbl tbody tr:last-child th { border-bottom: 0; }
.tpl-xl__v { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.tpl-xl__same summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
@media (pointer: coarse) { .tpl-xl__same summary { min-height: var(--tap); } }
@media (max-width: 559px) { .tpl-xl__f { width: 6.5rem; } }

/* 12 Nov 2026 (decisions 468 and 469). The charges of Make documents, the same for everyone
   (components/make-many.js), and the line under the Employee field of Make a document that points there. */
.gen-many__charges { display: grid; gap: var(--s2); }
.gen-many__charges p { margin: 0; }
.gen-many__chargelist { margin: 0; padding-left: var(--s5); display: grid; gap: var(--s1); overflow-wrap: anywhere; }
.gen-many__charges > .field { margin: 0; }
.gen-many__charges > .gen-disc { margin: 0; }
.gen-manyline { margin: var(--s2) 0 0; }
