/* atlas — print. Defaults to A4; Letter is switchable in Settings.
 *
 * Printing is a first-class output here, not an afterthought. The rules below
 * force a serif body at a true reading size, force light ink regardless of the
 * on-screen theme, expand URLs, and prevent orphaned headings.
 */

/* Default page geometry. Settings injects an overriding @page rule at runtime
   when Letter is chosen — @page cannot read CSS custom properties. */
@page {
  size: A4;
  margin: 18mm 16mm 20mm;
}

@media print {
  /* Always print light-on-white. Printing a dark theme wastes toner and
     reads badly. */
  :root, [data-theme="dark"] {
    --bg: #fff; --bg-raised: #fff; --bg-sunken: #fff; --bg-hover: #fff;
    --ink: #000; --ink-2: #1a1a1a; --ink-3: #3a3a3a; --ink-4: #555;
    --line: #bbb; --line-2: #999; --accent: #000; --accent-soft: #f2f2f2;
    --shadow: none;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
    font-family: var(--font-serif);
    font-size: 10.5pt;
    line-height: 1.5;
  }

  /* Hide the application chrome. */
  .topbar, .nav, .toasts, .editor-bar, .no-print,
  button, .btn, dialog, .save-state, input[type="checkbox"], .suggestion {
    display: none !important;
  }

  main { padding: 0 !important; }
  .wrap, .prose, .defs dd { max-width: none; }
  .panel { border: 0; padding: 0; background: none; }

  /* Document header printed on the page itself, since browsers won't give us
     a reliable running header. */
  .print-header {
    display: block !important;
    border-bottom: 1pt solid #000;
    padding-bottom: 4mm;
    margin-bottom: 6mm;
  }
  .print-header .doc-title { font-size: 18pt; font-weight: 700; letter-spacing: -.01em; }
  .print-header .doc-meta { font-size: 8.5pt; color: #444; margin-top: 1mm; }

  h1 { font-size: 18pt; }
  h2 { font-size: 12pt; }
  h3 { font-size: 11pt; }

  .section { margin-top: 7mm; break-inside: avoid; }
  .section > h2 {
    font-family: var(--font-sans);
    font-size: 8.5pt; letter-spacing: .12em; text-transform: uppercase;
    color: #000; border-bottom: .5pt solid #999; padding-bottom: 1.5mm;
  }

  .defs { grid-template-columns: 38mm 1fr; gap: 1.5mm 6mm; }
  .defs dt { font-family: var(--font-sans); font-size: 8.5pt; color: #333; }
  .defs dd { font-size: 10.5pt; }
  .defs dd.empty { display: none; }   /* don't print blanks */

  /* Typographic hygiene */
  h1, h2, h3, h4 { break-after: avoid-page; break-inside: avoid; }
  p, li, blockquote { orphans: 3; widows: 3; }
  .list-item, .entry, .rendered blockquote, tr, .avoid-break { break-inside: avoid; }
  .page-break { break-before: page; }

  /* Expand links so a printed page stays useful. */
  .rendered a::after, .defs a::after {
    content: " (" attr(href) ")";
    font-family: var(--font-mono); font-size: 8pt; color: #444;
    word-break: break-all;
  }
  a { color: #000; text-decoration: underline; }

  .tag, .chip { border: .5pt solid #999; background: none; color: #000; }
  .avatar { border: .5pt solid #999; }
  mark { background: none; box-shadow: inset 0 -.5em 0 #eee; }

  .entry + .entry { margin-top: 8mm; padding-top: 6mm; border-top: .5pt solid #ccc; }
  .entry-date { font-family: var(--font-sans); font-size: 8.5pt; letter-spacing: .08em; text-transform: uppercase; color: #444; }

  .print-footer {
    display: block !important; margin-top: 8mm; padding-top: 3mm;
    border-top: .5pt solid #ccc; font-size: 8pt; color: #555;
  }
}

.print-header, .print-footer { display: none; }
