/* ==========================================================================
   Kartuli — print. A set printed from the browser becomes a worksheet.
   Load LAST, with media="print":
     <link rel="stylesheet" href="/static/css/print.css" media="print">
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 16mm 14mm;
}

@media print {

  /* --- Ground: black on white, no theme, no washes --------------------- */
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #fff;
    --ink: #000; --ink-soft: #333; --ink-faint: #555;
    --line: #999; --line-strong: #666;
    --shadow-1: none; --shadow-2: none; --shadow-3: none; --shadow-inset: none;
  }
  html, body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.45;
  }
  * { box-shadow: none !important; text-shadow: none !important; }

  /* --- Hide the chrome -------------------------------------------------- */
  .topbar, .footer, .toasts, .action-bar, .skip-link, .tabs,
  .menu, .scrim, .g-hud, .g-cheer, .btn, .g-btn, .no-print,
  .page-head__actions, .empty__actions, .modal__foot, .modal__close {
    display: none !important;
  }
  dialog:not([open]) { display: none !important; }

  /* --- Layout ----------------------------------------------------------- */
  .container, .container-wide, .container-prose {
    max-width: none;
    padding: 0;
    margin: 0;
  }
  .app-main { padding: 0; }
  .card, .list, .table-wrap, .g-card, .set-card {
    border: 1px solid #999 !important;
    border-radius: 0;
    background: #fff !important;
  }
  .card__foot, .table thead th { background: #fff !important; }

  /* --- Worksheet ---------------------------------------------------------
     Markup a template can rely on:
       .sheet            one printable worksheet
       .sheet__head      title + student + date line
       .sheet__rows      numbered word rows with a writing line
       .sheet__cut       forced page break before
     ---------------------------------------------------------------------- */
  .sheet { page-break-after: always; break-after: page; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }

  .sheet__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8mm;
    padding-bottom: 3mm;
    margin-bottom: 6mm;
    border-bottom: 1.5pt solid #000;
  }
  .sheet__title { font-size: 16pt; font-weight: 700; }
  .sheet__meta  { font-size: 10pt; color: #333; }
  /* Name/date rule the student fills in by hand */
  .sheet__fill { display: inline-block; min-width: 45mm; border-bottom: .75pt solid #000; }

  .sheet__rows { list-style: none; padding: 0; margin: 0; counter-reset: kt-row; }
  .sheet__rows > li {
    display: grid;
    grid-template-columns: 8mm 1fr 1fr;
    align-items: end;
    gap: 4mm;
    padding: 3.5mm 0;
    border-bottom: .5pt dotted #666;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .sheet__rows > li::before {
    counter-increment: kt-row;
    content: counter(kt-row) ".";
    color: #555;
    font-size: 10pt;
  }
  .sheet__term { font-size: 13pt; }
  .sheet__answer { border-bottom: .75pt solid #000; min-height: 7mm; }

  /* Two-column worksheet body for short word lists */
  .sheet--2col .sheet__rows { columns: 2; column-gap: 10mm; }
  .sheet--2col .sheet__rows > li { break-inside: avoid; }

  /* Letter grids print as a real grid — still one glyph per cell. */
  .g-grid, .g-slots, .g-bank {
    letter-spacing: normal !important;
    gap: 0;
  }
  .g-cell {
    border: .5pt solid #666 !important;
    border-radius: 0;
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    min-height: 8mm;
  }
  .g-cell--blank { border: 0 !important; border-bottom: 1pt solid #000 !important; }

  /* --- Typography & flow ------------------------------------------------ */
  h1, h2, h3, h4 { page-break-after: avoid; break-after: avoid-page; }
  p, li, tr, .pair, .list__item { page-break-inside: avoid; break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  img, svg, .g-card { page-break-inside: avoid; break-inside: avoid; }

  /* Links: show the target, but not for in-page or JS anchors. */
  a { color: #000 !important; text-decoration: none; }
  .sheet a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8.5pt;
    color: #555;
    word-break: break-all;
  }

  /* Georgian keeps its font and never gets tracked or case-folded. */
  .ka { font-family: var(--font-ka); letter-spacing: normal !important; text-transform: none !important; }

  /* Force a break where the template asks for one. */
  .sheet__cut { page-break-before: always; break-before: page; }
  .print-only { display: revert !important; }
}

/* `.print-only { display: none }` for screen lives in base.css — this sheet is
   loaded with media="print" and would never apply it. */
