/*
 * tietiy.in — print-friendly stylesheet.
 *
 * Loaded via:
 *   <link rel="stylesheet" media="print" href="/styles/print.css">
 *
 * Because of media="print" the file is fetched lazily by the browser (it
 * downloads but does not block render, and it never affects the screen
 * view). This is the recommended pattern per MDN and the Google Chrome dev
 * team — keeps screen perf unchanged.
 *
 * Wired 2026-06-25 alongside ToC + ReadingProgress + reading-time chip as
 * part of the long-form UX pass. Lives under /public/styles/ (NOT src/) so
 * Astro ships it verbatim — no bundling, no fingerprinting. Stable URL means
 * print.css can be cached forever by the browser.
 *
 * Scope:
 *   1. Hide site chrome (nav, footer, ToC, progress bar, banners, ads).
 *   2. Force readable typography (black on white, 12pt serif).
 *   3. Reveal URLs after links so the printed page is self-referential.
 *   4. Avoid awkward breaks inside code blocks, tables, and figures.
 */

/* ── 1. Hide site chrome ────────────────────────────────────────────── */
header.site,
nav.site,
footer.site,
.disclaimer,
.toc-host,
.reading-progress,
#tietiy-consent-banner,
.tietiy-consent,
.tcb-manage-modal,
#tietiy-consent-manage,
.banner-wa,
.wa-float,
.wa-hero,
.ad-slot,
.adslot,
.adsbygoogle,
.medianet-unit,
.fixture-note,
.learn-prevnext,
.learn-related,
.share-row,
.share-buttons,
.story-related,
.story-related-event,
.story-sources,
.byline,
.breadcrumbs {
  display: none !important;
}

/* ── 2. Page / body ─────────────────────────────────────────────────── */
@page {
  margin: 1.6cm 1.4cm;
}

html,
body {
  background: #fff !important;
  color: #111 !important;
  font-family: Georgia, "Times New Roman", Times, serif !important;
  font-size: 12pt !important;
  line-height: 1.55 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

main {
  display: block !important;
}

.wrap {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ── 3. Typography ──────────────────────────────────────────────────── */
h1,
h2,
h3,
h4 {
  color: #000 !important;
  page-break-after: avoid;
  break-after: avoid;
  font-family: Georgia, "Times New Roman", Times, serif !important;
}
h1 { font-size: 22pt !important; margin: 0 0 6pt; }
h2 { font-size: 16pt !important; margin: 14pt 0 4pt; }
h3 { font-size: 13pt !important; margin: 10pt 0 3pt; }

p,
li {
  color: #111 !important;
  orphans: 3;
  widows: 3;
}

a {
  color: #000 !important;
  text-decoration: underline !important;
}

/* ── 4. URL after each link (RFC-style) ─────────────────────────────── */
/* Only for absolute / http links INSIDE article bodies — skip in-page
 * anchors, mailto, tel, javascript:, and the byline/breadcrumbs already
 * hidden above. */
.article-body a[href^="http"]::after,
.learn-body a[href^="http"]::after,
.story-body a[href^="http"]::after {
  content: " (" attr(href) ")";
  font-size: 9pt;
  font-style: italic;
  color: #333 !important;
  word-break: break-all;
}
/* Defensive: never duplicate a URL if the link text already IS the URL. */
.article-body a[href^="http"][data-no-print-url]::after,
.learn-body a[href^="http"][data-no-print-url]::after,
.story-body a[href^="http"][data-no-print-url]::after {
  content: "";
}

/* ── 5. Break-inside avoid for atomic blocks ────────────────────────── */
pre,
table,
figure,
blockquote {
  page-break-inside: avoid;
  break-inside: avoid;
}

pre,
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  background: #f3f3f3 !important;
  color: #111 !important;
  border: 1px solid #ddd !important;
  border-radius: 3pt !important;
}
pre {
  padding: 6pt 8pt !important;
  font-size: 10pt !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}
code {
  padding: 1pt 4pt !important;
  font-size: 10pt !important;
}

table {
  border-collapse: collapse !important;
  width: 100% !important;
  font-size: 10pt !important;
}
th,
td {
  border: 1px solid #999 !important;
  padding: 4pt 6pt !important;
  color: #111 !important;
}
th {
  background: #eee !important;
  font-weight: 700 !important;
}

img,
svg {
  max-width: 100% !important;
  height: auto !important;
}

/* ── 6. Header on first page only (printed article identity) ────────── */
/* Inject a small "tietiy.in — printed page" identity at the top so the
 * printout is recognisable when re-found in a stack of papers. We use a
 * generated content trick on body::before so we don't need any markup
 * change in the templates. */
body::before {
  content: "tietiy.in — printed page · descriptive market context, not advice";
  display: block;
  font-size: 9pt;
  color: #555 !important;
  border-bottom: 1pt solid #bbb;
  padding-bottom: 4pt;
  margin-bottom: 10pt;
}

/* ── 7. Footnote at end of print (canonical URL) ────────────────────── */
body::after {
  content: "© tietiy.in · https://tietiy.in · printed from your browser";
  display: block;
  font-size: 8.5pt;
  color: #555 !important;
  text-align: center;
  border-top: 1pt solid #bbb;
  margin-top: 18pt;
  padding-top: 4pt;
}
