/* ============================================================================
   claudia-print.css  ·  JIS-B5 print rules for The Japanese Gengo
   Link LAST. Turns the stacked screen preview into a clean B5 print/PDF.
   In the browser print dialog: paper = B5, margins = None, Background graphics = ON.
   ========================================================================== */

@page {
  size: 182mm 257mm;   /* JIS-B5 */
  margin: 0;
}

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

  /* hide screen-only chrome */
  .screen-only { display: none !important; }

  /* each .page becomes exactly one printed sheet */
  .page {
    width: 182mm !important;
    height: 257mm !important;
    min-height: 257mm !important;
    max-height: 257mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    break-after: page;
    page-break-after: always;
    overflow: hidden !important;
  }
  .page:last-child { page-break-after: auto; }

  /* keep the brand colours/fills when printing */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* avoid awkward splits inside teaching components */
  .kanji-card, .dialogue, .quest, .cast-card, .chira-core, .chira-grammar,
  .chira-accent, .chira-bento, .turn, .haiku, .polaroid {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ============================================================================
   PRINT-FIT COMPACTION LAYER · added 2026-07-05
   Screen preview stays airy and generous; on paper the book compacts to true
   Japanese-textbook scale (body ≈ 9.5pt) so every page fits one B5 sheet.
   The PFC markers let QA tooling identify this compaction layer for measurement.
   ========================================================================== */
/*PFC-START*/
@media print {
  /* master scale: every rem-based size shrinks to 78% */
  html { font-size: 12.5px; }
  :root { --pg-pad: 8mm; --radius: 10px; }
  .page { padding: 8mm 9mm; }

  /* running furniture */
  .page__header { margin-bottom: 7px; padding-bottom: 4px; }
  .page__footer { margin-top: 7px; padding-top: 4px; }

  /* base rhythm */
  .page p { line-height: 1.5; margin: 0 0 .65em; }
  .lead { line-height: 1.45; }
  .page h3 { margin: .6em 0 .3em; }
  .jp-main { line-height: 1.4; }
  .jp-line { margin-bottom: 4px; }

  /* vendor callouts: the airy 20px/30px becomes print-tight */
  .chira-core, .chira-accent, .chira-grammar, .chira-drill {
    padding: 9px 12px !important; margin: 12px 0 !important; }
  .chira-bento { gap: 8px !important; margin: 10px 0 !important; }
  .chira-bento > div, .chira-bento .major-node { padding: 9px 12px !important; }
  .chira-bento h4 { margin-bottom: 5px !important; }
  .chira-strip { margin: 8px 0 !important; }
  .chira-strip li { padding: 5px 12px !important; gap: 8px !important; }
  .callout-title { margin-bottom: 4px; }
  .grid-2 { gap: 10px !important; }
  .hr-soft { margin: 10px 0 !important; }

  /* dialogue engine */
  .dialogue__scene { padding: 5px 10px !important; }
  .turn { padding: 6px 9px; gap: 8px; }
  .turn .av { width: 46px; height: 46px; }
  .turn .bubble { padding: 6px 10px !important; }

  /* kana & roster grids */
  .kana-grid { gap: 5px; }
  .kana-cell { padding: 5px 3px !important; }
  .roster { gap: 5px; }
  .roster-cell { padding: 5px 3px !important; }

  /* kanji story cards */
  .kanji-card__story p { line-height: 1.5; }

  /* tables */
  .verb-table th, .verb-table td, .counter-grid th, .counter-grid td { padding: 4px 6px !important; }

  /* quests & culture frames */
  .quest { padding: 9px 12px !important; margin-top: 10px !important; }
  .quest .cando li, .achieve li { padding: 2px 0; }
  .zen-frame { padding: 10px 12px !important; }

  /* mascots slightly smaller on paper */
  .mascot.sz-lg { width: 104px; height: 104px; }
  .mascot.sz-md { width: 72px; height: 72px; }
  .mascot.sz-sm { width: 52px; height: 52px; }

  /* kanji story cards — print-dense */
  .kanji-card { box-shadow: none; margin: 6px 0 0; }
  .kanji-card__top { grid-template-columns: 120px 1fr; }
  .kanji-card__glyph { padding: 8px; }
  .kanji-card__glyph .glyph { font-size: 4.6rem; }
  .kanji-card__id { padding: 8px 12px; }
  .kanji-card__name { margin: 4px 0 2px; }
  .kanji-card__meaning { margin: 0 0 5px; }
  .kanji-card__story { padding: 7px 11px; }
  .kanji-card__story p { margin: 0 0 4px; line-height: 1.45; }
  .kanji-card__story .story-h { margin-bottom: 2px; }
  .kanji-card__hook { padding-left: 8px; }
  .wild { padding: 6px 11px; gap: 5px; }
  .wild .w { padding: 4px; }
  .recruited { padding: 4px 11px; font-size: 10px; }
  .chip { padding: 2px 8px !important; font-size: 9.5px !important; }
  .chip-row { gap: 4px !important; margin-bottom: 2px !important; }
  .kanji-duo { gap: 7px; }
  .kanji-card.compact .kanji-card__top { grid-template-columns: 86px 1fr; }
  .kanji-card.compact .kanji-card__glyph .glyph { font-size: 3.2rem; }
  .kanji-card.compact .kanji-card__id { padding: 6px 10px; }
  .kanji-card.compact .kanji-card__name { font-size: 1.02rem; margin: 3px 0 1px; }
  .kanji-card.compact .kanji-card__meaning { font-size: .8rem; margin-bottom: 4px; }
  .kanji-card.compact .facts { gap: 2px 10px; }
  .kanji-card.compact .facts .f { font-size: .76rem; }
  .kanji-card.compact .kanji-card__story { padding: 6px 10px; }
  .kanji-card.compact .kanji-card__story p { font-size: .8rem; line-height: 1.42; margin-bottom: 3px; }
  .kanji-card.compact .wild .w .wjp { font-size: .95rem; }
  .kanji-card.compact .wild .w .wro { font-size: .66rem; }
  .kanji-card.compact .wild .w .wen { font-size: .7rem; }

  /* dialogues — print-dense */
  .turn { padding: 5px 8px; gap: 7px; }
  .turn .av { width: 40px; height: 40px; }
  .turn .who { margin-bottom: 1px; }
  .turn .jp-main { line-height: 1.35; }
  .turn .gloss { font-size: .85rem; }
  .turn .romaji { margin-top: 0; }
  .dialogue .jp-line { margin-bottom: 0; }
  .menu-board { padding: 8px 12px !important; margin-bottom: 8px !important; }
  .menu-item { padding: 3px 0; }
  .cando li { padding: 1px 0 !important; font-size: .85rem !important; }

  /* survival components (ch07) */
  .sos { padding: 5px 8px !important; }
  .sos-grid { gap: 5px; }
  .transit { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .transit .t { padding: 5px 6px !important; }
  .gov-form .gf-row { padding: 4px 10px !important; }
  .gov-form .gf-title { padding: 4px 10px !important; }
  .body-grid { gap: 5px; }
  .body-chip { padding: 3px 8px !important; }
  .week-grid { gap: 5px !important; }
  .week-grid .day { padding: 4px 3px !important; }

  /* compact cards: wild-word tiles flatten to single lines on paper */
  .kanji-card.compact .wild { gap: 4px; padding: 5px 10px; }
  .kanji-card.compact .wild .w { display: flex; flex-wrap: wrap; justify-content: center;
    align-items: baseline; column-gap: 6px; padding: 2px 4px; }

  /* per-page print-fit dial: <section class="page fit-95"> etc. */
  .fit-98 .page__body { zoom: .98; }
  .fit-97 .page__body { zoom: .97; }
  .fit-96 .page__body { zoom: .96; }
  .fit-95 .page__body { zoom: .95; }
  .fit-93 .page__body { zoom: .93; }
  .fit-92 .page__body { zoom: .92; }
  .fit-91 .page__body { zoom: .91; }
  .fit-90 .page__body { zoom: .90; }
  .fit-89 .page__body { zoom: .89; }
  .fit-88 .page__body { zoom: .88; }
  /* Dialogue pages with many supported lines keep readable type by tightening
     component rhythm instead of relying on a smaller whole-page scale. */
  .print-compact-dialogue .learning-signal { margin: 4px 0 6px; padding: 4px 8px; }
  .print-compact-dialogue .dialogue__scene { padding: 4px 8px !important; }
  .print-compact-dialogue .turn { padding: 3px 7px; gap: 6px; }
  .print-compact-dialogue .turn .bubble { padding: 4px 8px !important; }
  .print-compact-dialogue .turn .jp-main { font-size: 1.15rem; line-height: 1.25; }
  .print-compact-dialogue .turn .romaji { font-size: .68rem; }
  .print-compact-dialogue .turn .gloss { font-size: .78rem; line-height: 1.3; }
  .print-compact-dialogue .dialogue-recall { margin-top: 5px; padding: 5px 8px; }
  .print-compact-dialogue .quest { margin-top: 6px !important; padding: 6px 10px !important; }
  .print-compact-dialogue .cando li { padding: 0 !important; line-height: 1.25; }
  .print-compact-dialogue .page__body > .center.muted { margin-top: 5px !important; font-size: .75rem; }

  /* Book Two (N4) components */
  .bridge-hero { padding: 8px 12px !important; gap: 10px; }
  .register-dial { height: 28px; margin: 5px 0; }
  .gear-grid { gap: 7px; }
  .gear .b { padding: 6px 10px; }
  .n4-map { gap: 6px; }
  .n4-map .stop { padding: 6px 9px; }
  .twin-strip { padding: 6px 10px; gap: 10px; }

  /* culture blocks (ch06) */
  .hana-grid { gap: 5px !important; }
  .hana { padding: 4px 3px !important; }
  .page--porcelain-signal .hana { padding: 0 !important; }
  .haiku-575 { padding: 8px 12px !important; }
  .adj-grid { gap: 6px !important; }
  .adj-pair { padding: 5px 8px !important; }
  .box4 { gap: 6px !important; }
  .cbox { padding: 6px 8px !important; }
}
/*PFC-END*/
