/*
  THE TEMPERATURE LOG SHEET GENERATOR: the form, the on-screen preview and
  the printed A4 sheet (tasks P138-#238 and P138-#292). Loaded on the four
  temperature log pages (fridge and freezer, hot holding, cooking and
  reheating, deliveries), after /styles.css.

  The SHEET rules (.lsg-sheet and below) are in millimetres and are the same
  on screen and on paper; scripts/free_resources_logsheet.py prints the
  blank PDFs with this file, so the downloads and the page print alike.
*/

/* ---------------- the form ---------------- */

.lsg-layout {
  display: grid;
  gap: 40px;
  align-items: start;
}

@media (min-width: 1000px) {
  .lsg-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 56px;
  }
}

.lsg-form {
  display: grid;
  gap: 26px;
}

.lsg-form[hidden] {
  display: none;
}

.lsg-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.lsg-form legend,
.lsg-field label {
  display: block;
  font-weight: 750;
  font-size: 17px;
  margin-bottom: 8px;
  padding: 0;
}

.lsg-hint {
  margin: -2px 0 10px;
  font-size: 15px;
  color: var(--muted);
}

.lsg-row {
  display: grid;
  gap: 16px;
}

@media (min-width: 560px) {
  .lsg-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.lsg-form input[type='text'],
.lsg-form input[type='number'],
.lsg-form select {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--paper);
  border: var(--line);
  border-radius: 12px;
}

.lsg-form select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 16px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.lsg-form input:focus-visible,
.lsg-form select:focus-visible,
.lsg-form button:focus-visible {
  outline: 3px solid var(--green-800);
  outline-offset: 2px;
}

.lsg-units {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 14px;
}

.lsg-unit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: end;
  padding: 14px;
  background: var(--cream);
  border: var(--line);
  border-radius: 16px;
}

.lsg-unit-row .lsg-field--name {
  grid-column: 1 / -1;
}

@media (min-width: 560px) {
  .lsg-unit-row {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  }

  .lsg-unit-row .lsg-field--name {
    grid-column: auto;
  }
}

.lsg-unit-row label {
  font-size: 15px;
  margin-bottom: 6px;
}

.lsg-remove,
.lsg-add {
  min-height: 52px;
  min-width: 52px;
  padding: 10px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: var(--line);
  border-radius: var(--r-btn);
  cursor: pointer;
}

.lsg-remove:disabled,
.lsg-add:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lsg-count {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.lsg-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.lsg-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 18px 10px 14px;
  background: var(--paper);
  border: var(--line);
  border-radius: 14px;
  font-size: 17px;
  font-weight: 650;
  cursor: pointer;
}

.lsg-choice input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--green-800);
  flex: 0 0 auto;
}

.lsg-print-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.lsg-print-row .btn {
  min-height: 56px;
  font-size: 18px;
  cursor: pointer;
}

.lsg-status {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.lsg-intro {
  margin: 0 0 18px;
}

.lsg-privacy {
  margin: 0 0 28px;
  padding: 12px 16px;
  background: var(--mint);
  border-radius: 12px;
  font-size: 16px;
}

.lsg-nojs {
  padding: 18px 20px;
  background: var(--cream);
  border: var(--line);
  border-radius: 16px;
}

.lsg-nojs p {
  margin: 0 0 12px;
}

/* ---------------- the on-screen preview ---------------- */

.lsg-preview-wrap h3 {
  margin: 0 0 6px;
}

.lsg-preview-wrap .meta {
  margin: 0 0 14px;
}

.lsg-preview-frame {
  position: relative;
  overflow: hidden;
  border: var(--line);
  border-radius: 12px;
  background: #e9e6df;
  min-height: 200px;
}

.lsg-paper {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  background: #fff;
  box-sizing: border-box;
  padding: 8mm;
}

.lsg-paper--portrait {
  width: 210mm;
  height: 297mm;
}

.lsg-paper--landscape {
  width: 297mm;
  height: 210mm;
}

/* Before the script runs (or without it): the sample sheet as a plain image. */
.lsg-preview-frame.is-static {
  min-height: 0;
}

.lsg-preview-frame.is-static .lsg-paper {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
}

.lsg-preview-frame.is-static img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------------- the sheet (screen preview and paper) ---------------- */

.lsg-sheet {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #111;
  font-family: var(--font-sans, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif);
  font-size: 8.5pt;
  line-height: 1.25;
}

.lsg-sheet p {
  margin: 0;
}

.lsg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8mm;
  padding-bottom: 2.5mm;
  margin-bottom: 2.5mm;
  border-bottom: 0.6mm solid #111;
}

.lsg-kicker {
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lsg-business {
  font-size: 15pt;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.lsg-site {
  font-size: 10pt;
  font-weight: 600;
}

.lsg-month {
  font-size: 13pt;
  font-weight: 800;
  white-space: nowrap;
}

.lsg-line {
  display: inline-block;
  width: 55mm;
  border-bottom: 0.3mm solid #111;
  height: 1em;
  vertical-align: baseline;
}

.lsg-month .lsg-line {
  width: 32mm;
}

.lsg-month .lsg-line--short,
.lsg-line--short {
  width: 14mm;
}

.lsg-th-unit .lsg-line {
  width: 100%;
  display: block;
  margin-top: 1mm;
}

.lsg-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  flex: 1 1 auto;
}

.lsg-table th,
.lsg-table td {
  border: 0.25mm solid #111;
  padding: 0.6mm 1mm;
  text-align: center;
  vertical-align: middle;
}

.lsg-table thead th {
  background: #eef5ec;
  font-weight: 700;
  font-size: 7.5pt;
  line-height: 1.15;
  overflow-wrap: anywhere;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.lsg-th-check span {
  font-weight: 600;
}

.lsg-unit {
  display: block;
}

.lsg-type {
  display: block;
  font-weight: 500;
  font-size: 6.5pt;
}

.lsg-col-day {
  width: 9mm;
}

.lsg-col-time {
  width: 11mm;
}

.lsg-col-init {
  width: 11mm;
}

.lsg-table thead th.lsg-th-init,
.lsg-table thead th.lsg-th-time,
.lsg-table thead th.lsg-th-reading {
  font-size: 6.5pt;
  overflow-wrap: normal;
  padding-left: 0.3mm;
  padding-right: 0.3mm;
}

.lsg-th-time,
.lsg-th-reading {
  font-weight: 600 !important;
}

.lsg-deg {
  display: block;
  font-weight: 600;
  font-size: 6.5pt;
}

.lsg-sheet--portrait .lsg-col-action {
  width: 38mm;
}

.lsg-sheet--landscape .lsg-col-action {
  width: 50mm;
}

.lsg-table tbody th {
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  font-size: 7.5pt;
}

.lsg-sheet--portrait .lsg-day {
  height: 6.1mm;
}

.lsg-sheet--landscape .lsg-day {
  height: 4mm;
}

.lsg-sheet--landscape .lsg-table tbody th,
.lsg-sheet--landscape .lsg-table tbody td {
  font-size: 7pt;
  line-height: 1.05;
  padding-top: 0.2mm;
  padding-bottom: 0.2mm;
}

/* Every other day shaded lightly, so a row is easy to follow across the sheet. */
.lsg-day:nth-child(even) th,
.lsg-day:nth-child(even) td {
  background: #f6f6f4;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.lsg-init,
.lsg-th-init {
  border-right-width: 0.6mm !important;
}

.lsg-legend {
  margin-top: 2.5mm;
  font-size: 7.5pt;
}

.lsg-legend ul {
  margin: 0;
  padding-left: 4mm;
}

.lsg-legend li {
  margin: 0 0 0.4mm;
}

.lsg-sheet--landscape .lsg-legend ul {
  columns: 2;
  column-gap: 8mm;
}

.lsg-sources {
  margin-top: 1mm !important;
  font-size: 6.5pt;
  color: #333;
}

/* ---------------- printing ---------------- */

#lsg-print {
  display: none;
}

@media print {
  html,
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Only on a page that has a sheet to print (the four log pages): the
     sign page loads this file for the form styles and prints normally. */
  body:has(> #lsg-print) > *:not(#lsg-print) {
    display: none !important;
  }

  #lsg-print {
    display: block !important;
  }

  /* The page less its 8 mm margins, less 1 mm. min-height, not height: a
     sheet that ever grew too tall would run onto a second page (which the
     tests count) rather than be cut off without a word. */
  #lsg-print .lsg-sheet--portrait {
    min-height: 280mm;
    min-width: 193mm;
  }

  #lsg-print .lsg-sheet--landscape {
    min-height: 193mm;
    min-width: 280mm;
  }
}
