/* "Print word cards" on the maker page (packets-print-cards.js). While the cards are open (body.pc-on) they
   take the place of the page, on screen and on paper: what the screen shows is what prints. Black on white,
   no color but the pictures. Each sheet is sized to fit inside 12 mm margins on both US Letter and A4
   (186 mm wide, 252 mm high at most): change the numbers below together. */
body.pc-on > :not(.pc) { display: none !important; }

.pc { min-height: 100vh; padding-bottom: 3rem; background: var(--bg); }
.pc-bar { width: 100%; max-width: 54rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 0.5rem; }
.pc-bar h1 { font-size: 1.75rem; }
.pc-said { margin-top: 0.5rem; font-weight: 600; color: var(--ink); }
.pc-actions { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin-top: 1rem; }
.pc-hint { margin-top: 0.6rem; font-size: 0.9375rem; color: var(--muted); }
.pc-hint:empty { display: none; }
.pc-options { margin-top: 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pc-options > summary { width: fit-content; padding: 0.75rem 0.5rem 0.75rem 0; cursor: pointer; font-weight: 600; color: var(--accent); }
.pc-options-body { padding-bottom: 1rem; }
.pc-field { margin-top: 0.75rem; }
.pc-field > legend { font-weight: 700; color: var(--ink); }
.pc-radios { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.pc-check { margin-top: 1rem; }

/* One sheet: on screen, a white page in the paper's proportions. */
.pc-sheets { padding: 0 clamp(1rem, 4vw, 2rem); }
.pc-sheet {
  display: flex; flex-direction: column; width: 100%; max-width: 46rem; aspect-ratio: 186 / 252; margin: 2.25rem auto;
  overflow: hidden; background: #ffffff; color: #000000; font-family: var(--font); line-height: 1.2;
  box-shadow: 0 0 0 0.75rem #ffffff, 0 0 0 calc(0.75rem + 1px) var(--line-strong);
}

/* The cards */
.pc-grid { display: grid; flex: 1 1 auto; min-height: 0; margin: 0; padding: 0; list-style: none; }
.pc-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pc-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pc-rows-2 { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.pc-rows-3 { grid-template-rows: repeat(3, minmax(0, 1fr)); }
.pc-rows-4 { grid-template-rows: repeat(4, minmax(0, 1fr)); }
.pc-card {
  container-type: inline-size; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3%;
  min-width: 0; min-height: 0; padding: 6%; overflow: hidden; text-align: center;
  break-inside: avoid; page-break-inside: avoid;
}
/* Cut lines: each card's dashed edge lies over its neighbor's, so there is one line between two cards. */
.pc-lines .pc-grid { gap: 0; }
.pc-lines .pc-card { margin: 0 -0.5mm -0.5mm 0; border: 0.5mm dashed #000000; }
.pc-nolines .pc-grid { gap: 4mm; }
.pc-nolines .pc-card { border: 0.3mm solid #000000; border-radius: 3mm; }

.pc-pic { display: block; flex: 1 1 auto; width: 100%; min-height: 0; max-height: 72%; object-fit: contain; }
.pc-has-pic .pc-pic:only-child { max-height: 100%; }
/* The word: as big as the card allows, and smaller for a longer word, so it never runs over the edge.
   150cqi / letters keeps a bold word inside the card's width; --word-max caps a short word. */
.pc-word {
  display: block; max-width: 100%; font-weight: 700; line-height: 1.1; color: #000000; overflow-wrap: anywhere;
  font-size: min(var(--word-max), calc(150cqi / var(--n, 6)));
}
.pc-per-4 { --word-max: 64pt; --word-max-pic: 44pt; }
.pc-per-6 { --word-max: 50pt; --word-max-pic: 34pt; }
.pc-per-12 { --word-max: 34pt; --word-max-pic: 24pt; }
.pc-has-pic .pc-word { font-size: min(var(--word-max-pic), calc(150cqi / var(--n, 6))); }
.pc-len-1 { --n: 2; } .pc-len-2 { --n: 2; } .pc-len-3 { --n: 3; } .pc-len-4 { --n: 4; } .pc-len-5 { --n: 5; } .pc-len-6 { --n: 6; }
.pc-len-7 { --n: 7; } .pc-len-8 { --n: 8; } .pc-len-9 { --n: 9; } .pc-len-10 { --n: 10; } .pc-len-11 { --n: 11; } .pc-len-12 { --n: 12; }
.pc-len-13 { --n: 13; } .pc-len-14 { --n: 14; } .pc-len-15 { --n: 15; } .pc-len-16 { --n: 16; } .pc-len-17 { --n: 17; } .pc-len-18 { --n: 18; }
.pc-len-19 { --n: 19; } .pc-len-20 { --n: 20; } .pc-len-21 { --n: 21; } .pc-len-22 { --n: 22; } .pc-len-23 { --n: 23; } .pc-len-24 { --n: 24; }

/* The line at the foot of a card page: the title, the page, and the credit of each picture set on it. */
.pc-foot { flex: none; padding-top: 2mm; font-size: 7.5pt; line-height: 1.3; color: #000000; }
.pc-foot p { margin: 0; overflow-wrap: anywhere; }
.pc-foot-title { font-weight: 700; }

/* The word list: one page */
.pc-list { padding: 2mm 0 0; }
.pc-list-title { font-size: 20pt; color: #000000; }
.pc-list-sub { margin: 1.5mm 0 5mm; font-size: 12pt; }
.pc-words { margin: 0; padding: 0 0 0 9mm; list-style: decimal; column-gap: 12mm; font-size: 17pt; line-height: 1.25; }
.pc-words li { padding: 1.2mm 0 1.2mm 1mm; border-bottom: 0.2mm solid #808080; break-inside: avoid; page-break-inside: avoid; overflow-wrap: anywhere; }
.pc-list-cols-1 { columns: 1; max-width: 110mm; }
.pc-list-cols-2 { columns: 2; }
.pc-list-cols-3 { columns: 3; font-size: 14pt; }

@media print {
  @page { margin: 12mm; }
  body.pc-on { background: #ffffff; color: #000000; }
  .pc { min-height: 0; padding: 0; background: #ffffff; }
  .pc-bar { display: none !important; }
  .pc-sheets { padding: 0; }
  .pc-sheet { width: 100%; max-width: none; height: 252mm; aspect-ratio: auto; margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .pc-sheet:last-child { break-after: auto; page-break-after: auto; }
}

@media (forced-colors: active) {
  .pc-sheet { border: 1px solid CanvasText; }
}
