/*
 * 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: #7C5CFC; }
.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: #7C5CFC; --theme-b: #F472B6; }

/* ---------- 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);
}

.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 {
  display: grid;
  gap: 0;
  border: 2px solid var(--ink);
  width: max-content;
}

.crossword-cell {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-weight: 800;
  font-size: 1rem;
  background: #fff;
}

.crossword-cell.blocked {
  background: var(--ink);
  border-color: var(--ink);
}

.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));
}

.crossword-clues ol {
  margin: 0;
  padding-left: 20px;
}

.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 {
  width: 68px;
  height: 68px;
}

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

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

/* ---------- 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;
}

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

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

  body {
    background: #fff !important;
  }

  .site-header,
  .primary-nav,
  .sidebar,
  .site-footer,
  .cookie-banner,
  .breadcrumb,
  .term-links,
  .level-badges,
  .post-meta,
  .related-posts,
  .widget-ad,
  .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;
  }

  .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 {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media (max-width: 640px) {
  .sheet-header {
    flex-wrap: wrap;
  }

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