/*
 * Print Material system: shared visual language + print rules for the
 * "Дидактические материалы для педагогов" section. Loaded per-article
 * (like le-test.css) via <link> inside body_html, not globally.
 *
 * Uses design tokens already defined in site.css :root (--primary, --ink,
 * --line, --radius-*, --shadow, etc.) - this file just adds material-only
 * pieces on top of them.
 */

.print-material {
  --theme-a: var(--primary);
  --theme-b: var(--primary-dark);
}

.print-material.theme-board     { --theme-a: #FF7A59; --theme-b: #FFB020; }
.print-material.theme-coloring  { --theme-a: #F472B6; --theme-b: #FF7A59; }
.print-material.theme-crossword { --theme-a: #06B6D4; --theme-b: #4C6EF5; }
.print-material.theme-holiday   { --theme-a: #E63946; --theme-b: #FFB020; }
.print-material.theme-flashcard { --theme-a: #FBBF24; --theme-b: #FF7A59; }
.print-material.theme-worksheet { --theme-a: #4C6EF5; --theme-b: #3B5BDB; }
.print-material.theme-poster    { --theme-a: #12B76A; --theme-b: #06B6D4; }
.print-material.theme-bingo     { --theme-a: #14B8A6; --theme-b: #0F766E; }
.print-material.theme-certificate { --theme-a: #D97706; --theme-b: #FBBF24; }
.print-material.theme-grammar   { --theme-a: #22A6E0; --theme-b: #3B5BDB; }
.print-material.theme-halloween { --theme-a: #FF7A59; --theme-b: #F25C54; }

/* ---------- Toolbar (screen only) ---------- */

.print-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: var(--primary-light);
  border: 2px dashed var(--theme-a, var(--primary));
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 0 0 24px;
}

.print-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--theme-a, var(--primary)), var(--theme-b, var(--primary-dark)));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 24px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.print-button:hover,
.print-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

a.print-button {
  text-decoration: none;
}

.print-button.print-button-alt {
  background: #fff;
  color: var(--theme-b, var(--primary-dark));
  box-shadow: inset 0 0 0 2px var(--theme-a, var(--primary));
}

/* ---------- Preview gallery (image-based materials: light WebP previews
   on the page, full-resolution art only inside the downloadable PDF) ---------- */

.preview-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
  margin: 0 0 28px;
}

.preview-gallery figure {
  margin: 0;
}

.preview-gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  background: var(--bg);
}

.preview-gallery figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.preview-gallery.preview-gallery-flags {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.preview-gallery.preview-gallery-flags img {
  border-radius: 6px;
}

/* One wide picture (tea cup) or one sheet (certificate). */
.preview-gallery.preview-gallery-single {
  grid-template-columns: minmax(0, 760px);
}

.preview-gallery.preview-gallery-sheet {
  grid-template-columns: minmax(0, 420px);
}

.preview-gallery.preview-gallery-bookmarks {
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  max-width: 760px;
}

/* Cut-out art with transparent background: no card frame. */
.preview-gallery.preview-gallery-cutout {
  align-items: end;
}

.preview-gallery.preview-gallery-cutout img {
  box-shadow: none;
  background: none;
  border-radius: 0;
}

.print-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1 1 220px;
}

/* ---------- Sheet ---------- */

.print-page {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 30px 20px;
  margin: 0 0 32px;
  position: relative;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--theme-a, var(--primary)), var(--theme-b, var(--primary-dark)));
  color: #fff;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin: -4px -4px 22px;
}

.sheet-header .sheet-emoji {
  font-size: 2.1rem;
  line-height: 1;
}

.sheet-header .sheet-titles {
  min-width: 0;
}

.sheet-kicker {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 800;
  margin: 0 0 2px;
}

.sheet-header h2,
.sheet-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #fff;
}

.sheet-instructions {
  background: var(--bg);
  border-left: 4px solid var(--theme-a, var(--primary));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 16px;
  margin: 0 0 20px;
  color: var(--ink);
  font-size: 0.98rem;
}

.print-watermark {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}

/* ---------- Board game (ходилка) ---------- */

.board-game {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.board-row {
  display: flex;
  gap: 6px;
}

.board-row.row-reverse {
  flex-direction: row-reverse;
}

.board-cell {
  flex: 1 1 0;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--ink);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  padding: 4px 3px;
  background: #fff;
  position: relative;
  font-size: 0.68rem;
  line-height: 1.15;
}

.board-cell .cell-number {
  position: absolute;
  top: 2px;
  left: 4px;
  font-weight: 800;
  font-size: 0.62rem;
  color: var(--muted);
}

.board-cell .cell-icon {
  font-size: 1.4rem;
}

.board-cell.cell-start,
.board-cell.cell-finish {
  background: var(--primary-light);
  font-weight: 800;
  border-color: var(--theme-a, var(--primary));
}

/* ---------- Coloring pages ---------- */

.coloring-page {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
  justify-items: center;
  margin-bottom: 8px;
}

.coloring-item {
  text-align: center;
  max-width: 220px;
}

.coloring-item svg {
  width: 100%;
  height: auto;
  max-width: 190px;
}

.coloring-item span {
  display: block;
  margin-top: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
}

/* ---------- Crossword / word search ---------- */

.crossword-wrap,
.wordsearch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.crossword-grid {
  border-collapse: collapse;
  border-spacing: 0;
  width: max-content;
}

.crossword-cell {
  width: 36px;
  height: 36px;
  padding: 0;
  box-sizing: border-box;
  position: relative;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  vertical-align: middle;
  background: #fff;
}

/* A real <table> with border-collapse:collapse, not CSS Grid - two earlier
   attempts at collapsing borders by hand (per-cell who owns this side
   logic, then a negative-margin overlap trick, then an outline-offset
   trick) each produced a measurable pixel-level defect at word
   intersections under pixel-scanning (a 2px step, a doubled line, and an
   inconsistent 3px/4px line at 150% zoom, respectively) - box-model
   checks like getBoundingClientRect can't catch any of these, since grid
   track edges stay consistent regardless of which cell paints the
   border. border-collapse is a native table feature built exactly for
   this and was verified pixel-perfect at 100/125/150/200% zoom with no
   hand-rolled offset math. */
.crossword-cell:not(.blocked) {
  border: 2px solid var(--ink);
}

.crossword-cell.blocked {
  background: #fff;
  border: none;
}

.crossword-cell .clue-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--muted);
}

.crossword-clues {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px 28px;
  width: 100%;
}

.crossword-clues h4 {
  margin: 0 0 6px;
  color: var(--theme-a, var(--primary));
}

/* 28px: with 20px the 1 of clue 10, 11, 12 was cut off (2026-10-14) */
.crossword-clues ol {
  margin: 0;
  padding-left: 28px;
}

.wordsearch-grid {
  display: grid;
  gap: 2px;
  width: max-content;
  font-family: "Courier New", monospace;
}

.wordsearch-cell {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  font-weight: 800;
  text-transform: uppercase;
  background: #fff;
}

.wordsearch-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
}

.wordsearch-words span {
  background: var(--bg);
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 800;
  font-size: 0.9rem;
}

/* ---------- Flashcards ---------- */

.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.flashcard {
  outline: 2px dashed var(--muted);
  outline-offset: -6px;
  border-radius: var(--radius-md);
  padding: 16px 10px;
  text-align: center;
  background: #fff;
  box-shadow: var(--shadow);
}

.flashcard .flashcard-visual {
  font-size: 3rem;
  line-height: 1;
}

.flashcard .flashcard-visual svg:not(.ui-icon) {
  width: 68px;
  height: 68px;
}

.flashcard strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
}

.flashcard small {
  color: var(--muted);
}

.flashcard.flashcard-word {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
}

.flashcard.flashcard-word strong {
  margin: 0;
  font-size: 1.35rem;
}

/* ---------- Clocks (telling the time) ---------- */

.clock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 16px;
  margin: 0 0 16px;
}

.clock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-weight: 700;
}

.clock-item span {
  min-height: 1.4em;
  width: 100%;
}

/* ---------- Counting cards (number + repeated pictures, pastel per card) ---------- */

.counting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.counting-card {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: var(--radius-lg, var(--radius-md));
  padding: 18px 20px;
  min-height: 96px;
}

.counting-card-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 76px;
}

.counting-number {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
}

.counting-word {
  margin-top: 4px;
  font-weight: 800;
  letter-spacing: 0.03em;
  font-size: 0.9rem;
  color: var(--ink);
}

.counting-card-icons {
  flex: 1;
  font-size: 1.7rem;
  line-height: 1.35;
  word-break: break-word;
}

/* ---------- Bingo / Loto ---------- */

.bingo-card {
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 0 auto 26px;
  max-width: 420px;
  background: #fff;
}

.bingo-card h4 {
  text-align: center;
  margin: 0 0 10px;
  color: var(--theme-a, var(--primary));
}

.bingo-grid {
  display: grid;
  gap: 4px;
}

.bingo-cell {
  border: 1px solid var(--line);
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  text-align: center;
  padding: 2px;
  gap: 2px;
}

.bingo-cell .bingo-icon {
  font-size: 1.3rem;
}

.caller-list {
  columns: 3;
  column-gap: 24px;
  margin: 0;
  padding-left: 18px;
}

.caller-list li {
  break-inside: avoid;
  margin-bottom: 4px;
}

/* ---------- Worksheets / tracing ---------- */

.worksheet-lines {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 33px,
      var(--line) 34px
    );
  min-height: 140px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.tracing-row {
  margin-bottom: 12px;
}

.tracing-row svg {
  width: 100%;
  height: 84px;
  display: block;
}

.worksheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.worksheet-table th,
.worksheet-table td {
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
}

.worksheet-table th {
  background: var(--primary-light);
}

/* ---------- Poster ---------- */

.poster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.poster-table th,
.poster-table td {
  border: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
}

.poster-table th {
  background: linear-gradient(135deg, var(--theme-a, var(--primary)), var(--theme-b, var(--primary-dark)));
  color: #fff;
}

.poster-table tr:nth-child(even) td {
  background: var(--bg);
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.poster-grid .poster-cell {
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  background: #fff;
}

.poster-grid .poster-cell strong {
  display: block;
  font-size: 1.3rem;
}

/* ---------- Grammar rule tables ---------- */

.rule-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 16px;
}

.rule-table {
  font-size: 0.92rem;
  line-height: 1.45;
}

.rule-table th,
.rule-table td {
  padding: 7px 10px;
  vertical-align: top;
}

.rule-table td:first-child {
  font-weight: 800;
}

.rule-table .hl,
.rule-box .hl {
  color: var(--theme-a, var(--primary));
  font-weight: 900;
}

.rule-table .nw {
  white-space: nowrap;
}

.rule-table .ex {
  font-style: italic;
  color: var(--muted);
}

.rule-heading {
  margin: 18px 0 8px;
  font-size: 1.05rem;
  color: var(--theme-b, var(--primary-dark));
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.rule-box {
  border: 2px solid var(--theme-a, var(--primary));
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  background: #fff;
}

/* stacked boxes need air between them (owner, 2026-10-07); side by side the grid gap does it */
.rule-box + .rule-box {
  margin-top: 12px;
}

.rule-grid > .rule-box + .rule-box {
  margin-top: 0;
}

.rule-box.rule-warn {
  border-color: #E63946;
}

.rule-box-title {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  color: var(--theme-a, var(--primary));
  margin: 0 0 4px;
}

.rule-box.rule-warn .rule-box-title {
  color: #E63946;
}

.rule-box ul {
  margin: 0;
  padding-left: 18px;
}

.rule-box li {
  margin: 2px 0;
}

.rule-box p {
  margin: 0 0 4px;
}

/* ---------- Certificate ---------- */

.certificate {
  border: 6px double var(--theme-a, var(--primary));
  border-radius: var(--radius-lg, var(--radius-md));
  padding: 46px 40px;
  text-align: center;
  background: linear-gradient(180deg, #fff, var(--primary-light) 220%);
}

.certificate-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 6px;
}

.certificate-title {
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--theme-a, var(--primary));
}

.certificate-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin-top: 4px;
}

.certificate-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 26px;
}

.certificate-line {
  max-width: 480px;
  margin: 8px auto 0;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  min-height: 1.4em;
}

.certificate-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 44px;
  font-size: 0.92rem;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ---------- Print rules ---------- */

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff !important;
  }

  /* the article card's shadow printed as a grey bar under the last sheet */
  article.article {
    box-shadow: none !important;
  }

  /* cut-out cards: a shadow on paper is a grey smudge outside the cutting line (2026-10-10) */
  .flashcard {
    box-shadow: none !important;
  }

  .site-header,
  .primary-nav,
  .sidebar,
  .site-footer,
  .cookie-banner,
  .breadcrumb,
  .term-links,
  .level-badges,
  .post-meta,
  .related-posts,
  .widget-ad,
  .thanks-widget,
  .no-print,
  .print-toolbar {
    display: none !important;
  }

  #content.site-layout {
    display: block !important;
    width: 100% !important;
  }

  .print-page {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-after: always;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  /* Grammar rule sheets are dense reference pages - tighter spacing on
     paper so each sheet fits one A4 page. */
  .rule-table-wrap {
    overflow: visible;
    margin-bottom: 8px;
  }

  .rule-table {
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .rule-table th,
  .rule-table td {
    padding: 4px 8px;
  }

  .rule-heading {
    margin: 8px 0 4px;
    font-size: 0.92rem;
  }

  .rule-grid {
    gap: 8px;
    margin-bottom: 6px;
  }

  .rule-box {
    font-size: 0.76rem;
    line-height: 1.35;
    padding: 6px 10px;
  }

  .theme-grammar .sheet-header {
    padding: 8px 14px;
  }

  .theme-grammar .sheet-header .sheet-emoji {
    font-size: 1.5rem;
  }

  .theme-grammar .sheet-header h2 {
    font-size: 1.1rem;
  }

  .theme-grammar .sheet-instructions {
    padding: 5px 12px;
    margin-bottom: 8px;
    font-size: 0.82rem;
  }

  .theme-grammar .print-watermark {
    margin-top: 8px;
    padding-top: 6px;
  }

  /* Keep each repeating block (card, grid, row) whole on one page instead
     of letting the browser cut it in half at a page boundary (owner report
     2026-09-22: Loto cards were splitting across pages when printed). */
  .bingo-card,
  .flashcard,
  .counting-card,
  .coloring-item,
  .clock-item,
  .certificate,
  .crossword-wrap,
  .wordsearch-wrap,
  .board-row,
  .poster-grid .poster-cell,
  .worksheet-table tr,
  .poster-table tr,
  .rule-box {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .sheet-header {
    margin: 0 0 14px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .poster-table th,
  .board-cell.cell-start,
  .board-cell.cell-finish,
  .crossword-cell.blocked,
  .counting-card,
  .certificate,
  .rule-box {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media (max-width: 640px) {
  /* Word-search grids, board games, bingo cards and worksheet tables have
     a fixed minimum width wider than a phone; let each sheet scroll
     sideways on its own instead of the whole page. */
  .print-page {
    overflow-x: auto;
    padding: 18px 14px 14px;
  }

  .sheet-header {
    flex-wrap: wrap;
  }

  .crossword-cell,
  .wordsearch-cell {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
}

/* ---------- Word search levels (2026-10-02, ops/wordsearch-levels.php) ---------- */
.ws-levels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.ws-levels-label {
  font-weight: 800;
}

.ws-level-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ws-level-btn.is-active {
  border-color: #3B5BDB;
  background: #EEF2FF;
  color: #1E3A8A;
}

.ws-levels-note {
  flex-basis: 100%;
  font-size: 0.85rem;
  color: #64748B;
}

.ws-easy .wordsearch-cell {
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
}

.ws-medium .wordsearch-cell {
  width: 30px;
  height: 30px;
  font-size: 1.05rem;
}

.ws-answer-grid .wordsearch-cell {
  width: 22px !important;
  height: 22px !important;
  font-size: 0.8rem !important;
}

.wordsearch-cell.ws-hit {
  background: #FFE58A;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

@media (max-width: 640px) {
  .ws-easy .wordsearch-cell {
    width: 30px;
    height: 30px;
  }

  .ws-medium .wordsearch-cell {
    width: 26px;
    height: 26px;
  }
}

/* Phones (owner 2026-10-12: rows were further apart than columns and the grid
   ran past the sheet). The column width is inline in px (repeat(N, 30px)) and
   the cells were narrower than it; here the N columns share the sheet width and
   every cell is a square, so both gaps are the same 2px. N comes from the
   inline style, so old bodies need no change. Font follows the cell (cqi =
   1% of the grid width). */
@media (max-width: 640px) {
  .wordsearch-wrap .wordsearch-grid {
    --n: 15;
    container-type: inline-size;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr)) !important;
    width: 100%;
    max-width: calc(var(--n) * 34px);
    gap: 2px;
  }

  .wordsearch-wrap .wordsearch-grid[style*="repeat(10,"] { --n: 10; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(11,"] { --n: 11; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(12,"] { --n: 12; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(13,"] { --n: 13; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(14,"] { --n: 14; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(16,"] { --n: 16; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(17,"] { --n: 17; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(18,"] { --n: 18; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(19,"] { --n: 19; }
  .wordsearch-wrap .wordsearch-grid[style*="repeat(20,"] { --n: 20; }

  .wordsearch-wrap .wordsearch-grid .wordsearch-cell {
    width: auto !important;
    height: auto !important;
    aspect-ratio: 1;
    min-width: 0;
    font-size: calc(60cqi / var(--n)) !important;
    line-height: 1;
  }
}

.ws-places {
  columns: 2;
  column-gap: 32px;
  margin: 0;
  padding-left: 22px;
  font-size: 0.85rem;
}

/* ---------- Task cards, magic letters, drawing boxes (2026-10-03, Halloween block) ---------- */

.task-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.task-card {
  outline: 2px dashed var(--muted);
  outline-offset: -6px;
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  break-inside: avoid;
  page-break-inside: avoid;
}

.task-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--theme-b, var(--primary-dark));
}

.task-card-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.task-card p {
  margin: 8px 0 0;
  font-size: 1rem;
  line-height: 1.45;
}

.task-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.letter-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.letter-card {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  outline: 2px dashed var(--muted);
  outline-offset: -6px;
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 5rem;
  font-weight: 900;
  color: var(--theme-a, var(--primary));
  break-inside: avoid;
}

.letter-slots {
  display: flex;
  gap: 10px;
  margin: 6px 0 10px;
}

.letter-slots span {
  width: 52px;
  height: 52px;
  border: 2px solid var(--line);
  border-radius: 10px;
}

.draw-box {
  min-height: 150px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  margin: 6px 0 12px;
}

.draw-box-big {
  min-height: 300px;
}

@media print {
  .task-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .task-card {
    box-shadow: none;
    padding: 12px 12px 10px;
  }

  .task-card p {
    font-size: 0.86rem;
  }

  .draw-box {
    min-height: 100px;
    margin: 4px 0 8px;
  }

  .draw-box-big {
    min-height: 260px;
  }

  .letter-slots span {
    width: 40px;
    height: 40px;
  }

  .letter-card {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* quest «Our Spell Book»: the monster is drawn by the whole team (owner, 2026-10-19: the box was too small) */
  .draw-box-monster {
    min-height: 62mm;
  }
}

@media (max-width: 640px) {
  .letter-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .letter-slots span {
    width: 36px;
    height: 36px;
  }
}

/* ---------- Illustrated flashcards and quest art (2026-10-03, owner watercolour) ---------- */

.flashcard .flashcard-visual img {
  display: block;
  width: 100%;
  max-width: 140px;
  height: auto;
  margin: 0 auto;
}

.sheet-art {
  float: right;
  width: 34%;
  max-width: 240px;
  height: auto;
  margin: 0 0 10px 16px;
}

.sheet-art-wide {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 12px auto 0;
  border-radius: var(--radius-md);
}

@media print {
  .flashcard .flashcard-visual img {
    max-width: 92px;
  }

  /* the teacher's sheet prints without the picture (it is for showing on screen) */
  .sheet-art {
    display: none;
  }
}

/* ---------- Download pack (PM::downloadPack, 2026-10-06) ----------
   One collage of everything in the PDF + one big button, like a product
   card in a shop. The compact card sits in the intro, the full block
   (#...-download) after the sheets. */
.dl-pack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin: 34px 0 10px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fff 0%, #FFF7ED 100%);
  box-shadow: inset 0 0 0 2px var(--theme-a, var(--primary)), var(--shadow);
  scroll-margin-top: 90px;
}

.dl-pack-collage {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.dl-pack h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  line-height: 1.25;
}

.dl-pack-meta {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.dl-pack-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.dl-pack-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0 7px 26px;
  border-bottom: 1px dashed var(--line);
  position: relative;
}

.dl-pack-list li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  top: 7px;
  color: var(--theme-a, var(--primary));
  font-weight: 900;
}

.dl-pack-copies {
  flex: none;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.dl-pack .dl-pack-button {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  font-size: 1.08rem;
  padding: 15px 22px;
}

.dl-pack-sub {
  margin: 18px 0 6px;
  font-weight: 800;
  font-size: 0.9rem;
}

.dl-pack-extras {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dl-pack-extras li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.dl-pack .dl-pack-extra {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.dl-pack-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* compact card in the intro */
.dl-pack.dl-pack-compact {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 16px 22px;
  margin: 22px 0 26px;
  padding: 16px;
}

.dl-pack-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.dl-pack-title {
  margin: 0 0 4px;
  font-weight: 800;
  font-size: 1.15rem;
}

.dl-pack-compact .dl-pack-meta {
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.dl-pack-compact .dl-pack-button {
  width: auto;
  font-size: 1rem;
  padding: 13px 22px;
}

.dl-pack-more {
  display: block;
  margin-top: 10px;
  font-size: 0.9rem;
}

.sheets-lead {
  margin: 30px 0 18px;
}

.sheets-lead h2 {
  margin: 0 0 4px;
}

.sheets-lead p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .dl-pack,
  .dl-pack.dl-pack-compact {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .dl-pack-thumb {
    max-width: 360px;
  }

  .dl-pack .dl-pack-button,
  .dl-pack-compact .dl-pack-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    padding: 14px 12px;
    font-size: 0.95rem;
    border-radius: 18px;
    text-align: center;
  }

  .dl-pack-list li {
    flex-direction: column;
    gap: 2px;
  }
}

/* ---------- Paid material (2026-10-06): price, buy button, locked sheets ---------- */
.dl-pack-price {
  margin: 4px 0 12px;
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
  color: var(--ink, #1A1F36);
}

.dl-pack-compact .dl-pack-price {
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.dl-pack-buy-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.locked-sheets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 26px 0 8px;
}

.locked-sheet {
  position: relative;
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

.locked-sheet img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.85;
}

.locked-sheet-badge {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(26, 31, 54, 0.82);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.locked-sheet-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.96) 35%);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.25;
}

.locked-sheet-caption small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.locked-sheet:hover .locked-sheet-badge,
.locked-sheet:focus-visible .locked-sheet-badge {
  background: var(--theme-a, var(--primary));
}

.locked-sheets-cta {
  margin: 14px 0 0;
  text-align: center;
}

@media (max-width: 760px) {
  .locked-sheets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

/* Sheet header: line icon instead of the emoji (UiIcon::buttonsIn, 2026-10-06) */
.sheet-header .sheet-emoji.sheet-icon {
  display: flex;
  flex: none;
  line-height: 0;
}

.sheet-header .sheet-icon .ui-icon {
  width: 2.1rem;
  height: 2.1rem;
  stroke-width: 1.75;
  color: #fff;
}

@media print {
  .theme-grammar .sheet-header .sheet-icon .ui-icon {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* Task-card heads and certificates: line icon instead of the emoji (2026-10-06) */
.task-card-icon .ui-icon {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--theme-a, var(--primary));
}

.certificate-icon .ui-icon {
  display: inline-block;
  width: 3rem;
  height: 3rem;
  stroke-width: 1.5;
  color: var(--theme-a, var(--primary));
}

/* ---------- Kindergarten worksheets (halloween-kids-content.php, 2026-10-06) ----------
   Big pictures, almost no text; every sheet fits one A4. */
.kg-pic {
  display: block;
  width: 100%;
  height: auto;
}

.kg-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.kg-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 10px 16px;
  border: 2px solid #FFE1D6;
  border-radius: 18px;
  text-align: center;
  break-inside: avoid;
}

.kg-card .kg-pic {
  max-width: 190px;
}

.kg-word {
  margin-top: 4px;
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1.1;
  color: #E8541F;
}

.kg-ru {
  font-size: 0.85rem;
  color: var(--muted);
}

.kg-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px dashed #E1E5EF;
  break-inside: avoid;
}

.kg-row:last-child {
  border-bottom: 0;
}

.kg-pics {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.kg-pics .kg-pic {
  width: 78px;
}

.kg-pics-four {
  justify-content: space-around;
}

.kg-pics-four .kg-pic {
  width: 150px;
}

.kg-pics-seq .kg-pic {
  width: 76px;
}

.kg-row.kg-row-tall {
  padding: 30px 0;
}

.kg-numbers {
  display: flex;
  flex: none;
  gap: 8px;
  padding-right: 2px;
}

.kg-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid #CBD2E1;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 800;
  color: #1A1F36;
}

.kg-task {
  margin: 12px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.kg-row-size {
  justify-content: space-around;
  align-items: flex-end;
}

.kg-row-size {
  padding: 6px 0;
}

.kg-row-size .kg-big {
  width: 150px;
}

.kg-row-size .kg-small {
  width: 70px;
}

.kg-match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 110px;
  padding: 6px 10px;
}

.kg-match-col {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.kg-match-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kg-match-right {
  justify-content: flex-end;
}

.kg-match-item .kg-pic {
  width: 160px;
}

.kg-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1A1F36;
}

.kg-q {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border: 2px dashed #FF7A59;
  border-radius: 12px;
  font-size: 2rem;
  font-weight: 900;
  color: #FF7A59;
}

.kg-or {
  display: flex;
  flex: none;
  gap: 8px;
  margin-left: 6px;
  padding-left: 14px;
  border-left: 2px solid #E1E5EF;
}

.kg-or .kg-pic {
  width: 62px;
  padding: 3px;
  border: 2px solid #E1E5EF;
  border-radius: 12px;
}

.kg-row-trace .kg-pic-end {
  flex: none;
  width: 120px;
}

.kg-trace {
  flex: 1;
  height: 120px;
  min-width: 0;
}

.kg-boxes {
  display: flex;
  flex: none;
  gap: 6px;
}

.kg-boxes i {
  width: 42px;
  height: 42px;
  border: 2px solid #1A1F36;
  border-radius: 6px;
}

@media (max-width: 640px) {
  /* phones: numbers, boxes and answer choices go under the pictures */
  .kg-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .kg-row .kg-pics {
    flex: 1 1 100%;
  }

  .kg-row-size .kg-pics,
  .kg-row-trace .kg-pics {
    flex: 1;
  }

  .kg-row-trace {
    flex-wrap: nowrap;
  }

  .kg-row-trace .kg-pic-end {
    width: 58px;
  }

  .kg-trace {
    height: 80px;
  }

  .kg-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kg-pics .kg-pic,
  .kg-pics-seq .kg-pic {
    width: 44px;
  }

  .kg-pics-four .kg-pic {
    width: 64px;
  }

  .kg-number {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }

  .kg-match {
    gap: 0 40px;
  }

  .kg-match-item .kg-pic {
    width: 80px;
  }

  .kg-boxes i {
    width: 24px;
    height: 24px;
  }
}

/* Board game cells with pictures instead of emoji (hodilka-haunted-house, 2026-10-06) */
.board-cell .cell-icon:has(img) {
  display: flex;
  justify-content: center;
  width: 100%;
}

.board-cell .cell-pic {
  display: block;
  width: 60%;
  max-width: 78px;
  height: auto;
}

.board-cell .cell-pics {
  display: flex;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.board-cell .cell-pics .cell-pic {
  width: 44%;
}

.board-cell .cell-pic-wide {
  width: 92%;
}

/* white picture backgrounds vanish on the coloured start/finish cells */
.board-cell .cell-pic {
  mix-blend-mode: multiply;
}

/* one A4 sheet preview under its download button (stickers, 2026-10-06) */
.preview-gallery.preview-gallery-sheet {
  grid-template-columns: minmax(0, 300px);
}

/* Halloween Bingo (2026-10-06): the landscape card sheet wide, the two portrait sheets next to it */
.preview-gallery.preview-gallery-sheet.preview-gallery-bingo {
  grid-template-columns: 2fr 1fr 1fr;
  align-items: start;
}

@media (max-width: 640px) {
  .preview-gallery.preview-gallery-sheet.preview-gallery-bingo {
    grid-template-columns: 1fr 1fr;
  }

  .preview-gallery.preview-gallery-sheet.preview-gallery-bingo figure:first-child {
    grid-column: 1 / -1;
  }
}

/* Halloween Memory (2026-10-07): three portrait sheets in a row */
.preview-gallery.preview-gallery-sheet.preview-gallery-memory {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

/* Halloween board flags (2026-10-09): full-width previews right under their
   download button (-sheet: no second button from preview-download.js) */
.preview-gallery.preview-gallery-sheet.preview-gallery-wide {
  grid-template-columns: minmax(0, 760px);
}

/* Transcription on flashcards (owner, 2026-10-10: «добавь транскрипции во флешкарты для уровней А1») */
.flashcard .flashcard-ipa {
  display: block;
  margin-top: 2px;
  font-family: 'Segoe UI', 'Noto Sans', 'DejaVu Sans', Arial, sans-serif; /* the site font has no IPA letters */
  font-size: 0.85rem;
  line-height: 1.25;
  color: #6B7280;
}

@media print {
  .flashcard .flashcard-ipa {
    font-size: 0.72rem;
    margin-top: 0;
  }

  /* the extra line must not push the last row of cards onto a new sheet */
  .flashcard:has(.flashcard-ipa) {
    padding-top: 12px;
    padding-bottom: 10px;
  }

  .flashcard:has(.flashcard-ipa) strong {
    margin-top: 4px;
  }
}

/* three pictures in one board cell (hodilka-autumn-walk, 2026-10-10) */
.board-cell .cell-pics-3 .cell-pic {
  width: 31%;
}

/* the same toolbar repeated under the last sheet (print-bottom.js, 2026-10-11) */
.print-toolbar.print-toolbar--bottom {
  margin: 8px 0 28px;
}
