/* Print / PDF stylesheet for howxranks.
 * Loaded with media="print", so it never touches the screen rendering.
 * Interactive tools (calculator, simulation, planner) are dropped: they cannot work on paper. */

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

/* Always print the light palette with real colour, whatever theme the visitor picked. */
:root,
:root[data-theme="dark"] {
  color-scheme: light;
  --surround: #ffffff;
  --paper: #ffffff;
  --panel: #f3f6fa;
  --wash: #eaf0f8;
  --tint: #eef3fb;
  --note: #fafcfe;
  --field: #ffffff;
  --ink: #11181f;
  --ink-hover: #27384a;
  --muted: #4e5861;
  --faint: #5c6670;
  --rule: #bcc8d4;
  --grid: #dde5ee;
  --hair: #93a3b4;
  --draft: #16409f;
  --draft-hover: #16409f;
  --gain: #0b6b45;
  --gain-on-ink: #0b6b45;
  --loss: #b3261e;
  --warn: #7d4f06;
  --on-ink: #ffffff;
  --on-draft: #ffffff;
  --highlight: #fcf2d2;
  --loss-wash: #fdeceb;
  --gain-wash: #e8f5ed;
}

*, *::before, *::after {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

html, body {
  background: #fff !important;
  font-size: 10.5pt;
  line-height: 1.5;
}

/* Graph paper is a screen texture; on paper it is just toner. */
body.sheet, .plate { background-image: none !important; border: 0 !important; max-width: none !important; }

/* Screen chrome that means nothing on paper. */
header.sticky,
#site-nav,
#theme-toggle,
#menu-toggle,
.print-hide {
  display: none !important;
}

/* Interactive tools are excluded from the PDF. */
#calculator,
#simulation,
#plan {
  display: none !important;
}

/* The masthead only exists in print. */
.print-only { display: block !important; }

.print-masthead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.6rem;
  margin-bottom: 1.6rem;
}
.print-masthead .pm-title { font-size: 13pt; font-weight: 700; letter-spacing: -0.01em; }
.print-masthead .pm-meta {
  font-family: 'Fragment Mono', ui-monospace, monospace;
  font-size: 8pt;
  color: var(--muted);
  margin-top: 0.25rem;
}
.print-note {
  border: 1px solid var(--rule);
  background: var(--wash);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-size: 8.5pt;
  color: var(--muted);
  margin: 0 0 1.4rem;
}

/* Links read as text; the URL is already on the masthead.
 * Colour is deliberately NOT forced: elements that set their own (a button on an
 * ink background, a gain/loss figure) must keep it or they print invisibly. */
a { text-decoration: none !important; }

/* Keep blocks whole across page breaks. */
h1, h2, h3, h4 { break-after: avoid-page; page-break-after: avoid; }
tr, li, dd, figure { break-inside: avoid; page-break-inside: avoid; }
thead { display: table-header-group; }
table { break-inside: auto; }
section { break-inside: auto; }
/* A what's-new entry is a page in itself; keeping it whole leaves half a sheet
   blank nine times over. Let the entry break, hold the worked example together. */
.wn-list > li { break-inside: auto; page-break-inside: auto; }
.wn-calc, .wn-parts dd { break-inside: avoid; page-break-inside: avoid; }

/* Trim the generous screen rhythm so a page holds more. */
section { padding-top: 1.1rem !important; padding-bottom: 1.1rem !important; }
footer { padding-top: 1rem !important; padding-bottom: 0 !important; }

/* Drawings and framed panels keep their rules, but lose the screen fills. */
.fig, .panel { border: 1px solid var(--rule); background: #fff; }
.figcap, .phd { background: var(--panel); border-bottom: 1px solid var(--rule); }
.figbody { overflow: visible !important; }
.figbody svg.wide { min-width: 0 !important; }
.plot { max-width: 100%; }
.pnote { background: #fff; }
.seccode { background: var(--ink) !important; color: #fff !important; }
.revlog { font-size: 8pt; }
.ptab th { background: var(--panel); }
