/* ============================================================
   TUDOTYPE — Print / Save as PDF
   Loads for print only (functions.php, media "print"). The share bar's
   "Save as PDF" opens the browser's print dialog on this layout; the
   browser's own Print (Cmd/Ctrl + P) gets it too.
   - Always white: dark-mode.css is screen-only, and the page colour
     (surface-base) is paper white here.
   - Frame: the masthead (wordmark + address) heads the first page, the
     colophon (source, dates, copyright) ends the document. Both come from
     functions.php (PRINT / SAVE AS PDF) and ship hidden. In Chrome the
     page margins also carry the title, the address and "page / pages"
     (the page's own text is inline after this file).
   - Site chrome stays off the paper: menu, footer, share bar, strip,
     upsell, cross-sell, more projects, cookie banner and interactive tools.
   - Type in points; text at about 75 characters a line, in the primary ink.
   An A4 text area is about 650 CSS px wide, so the ≤ 768 px rules of
   components.css apply underneath; this file sets what paper needs.
   ============================================================ */

/* ============================================================
   PAGE — margins, running head and footer (Chrome draws margin boxes;
   other browsers print their own header and footer, if enabled)
   ============================================================ */

@page {
  margin: 16mm 18mm 18mm;

  /* Title, from the second page on; the masthead heads the first (text: tudotype_print_page_css()) */
  @top-left {
    vertical-align: bottom;
    padding-bottom: 6mm;
    font-family: var(--wp--preset--font-family--mono);
    font-size: var(--wp--preset--font-size--overline);
    color: var(--wp--preset--color--ink-muted);
  }
  /* Short address (text: tudotype_print_page_css()) and page numbers */
  @bottom-left {
    vertical-align: top;
    padding-top: 6mm;
    font-family: var(--wp--preset--font-family--mono);
    font-size: var(--wp--preset--font-size--overline);
    color: var(--wp--preset--color--ink-muted);
  }
  @bottom-right {
    content: counter(page) " / " counter(pages);
    vertical-align: top;
    padding-top: 6mm;
    font-family: var(--wp--preset--font-family--mono);
    font-size: var(--wp--preset--font-size--overline);
    color: var(--wp--preset--color--ink-muted);
  }
}

/* ============================================================
   TOKENS — paper, print type scale, text measure
   ============================================================ */

:root {
  --print-measure: 118mm; /* about 75 characters of 10.5 pt Newtal Sans */
  --print-gap: 6mm;       /* between blocks of the document */
  --print-rule: 0.5pt solid var(--wp--preset--color--surface-border);
  --pad-content: 0px;     /* the 816 px text column: the page margins do this on paper */

  --wp--preset--color--surface-base: var(--wp--preset--color--surface-white); /* paper */

  --wp--preset--font-size--display:  40pt;
  --wp--preset--font-size--h-1:      30pt;
  --wp--preset--font-size--h-2:      18pt;
  --wp--preset--font-size--h-3:      14pt;
  --wp--preset--font-size--h-4:      12pt;
  --wp--preset--font-size--body-lg:  10.5pt;
  --wp--preset--font-size--body-sm:  9pt;
  --wp--preset--font-size--button:   7.5pt;
  --wp--preset--font-size--caption:  7pt;
  --wp--preset--font-size--overline: 6.5pt;
}

/* Print what the layout shows, whatever "Background graphics" says: the paper is white, so
   only tags, buttons and cards keep a fill, and light text never lands on white paper */
html {
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
html,
body {
  background: var(--wp--preset--color--surface-white);
}

/* ============================================================
   CHROME — what stays on screen
   ============================================================ */

.wp-site-blocks > :is(header, footer),
.skip-link,
#idle-screensaver,
.tudotype-cookie-consent.is-open,
.tudotype-share,
.tudotype-strip-highlight,
.tudotype-upsell-section,
.tudotype-section-upsell,
.tudotype-cross-sell,
.tudotype-project-next,
.tudotype-buy-panel,
.tudotype-font-tester,
.tudotype-glyphs,
.tudotype-video-toggle,
.tudotype-carousel__nav,
.tudotype-carousel__item.is-clone,
.tudotype-person-links, /* icon-only links (Faces): nothing to read on paper */
.tudotype-home-opener__bar, /* the homepage opener's typeface controls */
.tudotype-home-opener__points, /* its drawing: paper gets the H1's words */
.tudo-gazette__filter-clear,
.tudo-gazette__no-match-clear,
.tudotype-licence-bar { /* the Licensing page's price pill (fixed: it would repeat on every sheet) */
  display: none;
}

/* ============================================================
   FRAME — masthead and colophon (functions.php, PRINT / SAVE AS PDF)
   ============================================================ */

.tudotype-print-masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--print-gap);
  padding-bottom: 4mm;
  margin-bottom: 12mm;
  border-bottom: var(--print-rule);
}
.tudotype-print-masthead__wordmark {
  display: block;
  width: 24mm;
  height: auto;
}
.tudotype-print-masthead__source {
  font-family: var(--wp--preset--font-family--mono);
  font-size: var(--wp--preset--font-size--overline);
  font-weight: var(--text-ui-sm-regular-weight);
  line-height: 1;
  color: var(--wp--preset--color--ink-muted);
  text-decoration: none;
}

.tudotype-print-colophon {
  display: block;
  margin-top: 12mm;
  padding-top: 4mm;
  border-top: var(--print-rule);
  break-inside: avoid;
}
.tudotype-print-colophon__list {
  display: grid;
  grid-template-columns: 24mm minmax(0, 1fr);
  row-gap: 1.6mm;
  margin: 0;
}
.tudotype-print-colophon__row {
  display: contents;
}
/* "Retrieved" waits for print.js; without it the row stays out */
.tudotype-print-colophon__row:has(time:empty) {
  display: none;
}
.tudotype-print-colophon dt {
  font-family: var(--wp--preset--font-family--mono);
  font-size: var(--wp--preset--font-size--overline);
  font-weight: var(--text-ui-sm-weight);
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp--preset--color--ink-muted);
}
.tudotype-print-colophon dd {
  margin: 0;
  font-family: var(--wp--preset--font-family--sans);
  font-size: 8pt;
  line-height: 1.35;
  color: var(--wp--preset--color--ink-primary);
  overflow-wrap: anywhere; /* long addresses wrap instead of running off the page */
}
.tudotype-print-colophon a {
  color: inherit;
  text-decoration: none;
}
.tudotype-print-colophon__copyright {
  margin: 5mm 0 0;
  font-family: var(--wp--preset--font-family--mono);
  font-size: var(--wp--preset--font-size--overline);
  font-weight: var(--text-ui-sm-regular-weight);
  line-height: 1.6;
  color: var(--wp--preset--color--ink-muted);
}

/* ============================================================
   BASE — text, links, media, page breaks
   ============================================================ */

body {
  color: var(--wp--preset--color--ink-primary);
}
/* Running text: one size and leading (the ≤ 768 px rules shrink paragraphs for phones), in the
   primary ink — grey type prints as a halftone, ragged at text sizes */
.wp-block-post-content p,
.tudo-article__body p,
.wp-block-post-content :is(ul, ol) {
  font-size: var(--wp--preset--font-size--body-lg);
  line-height: 1.5;
  color: var(--wp--preset--color--ink-primary);
}

:is(h1, h2, h3, h4, h5, h6) {
  break-after: avoid;
}
:is(p, li, dd, blockquote) {
  orphans: 3;
  widows: 3;
}
:is(figure, img, video, blockquote, pre, tr, .tudotype-quote-card) {
  break-inside: avoid;
}

/* Links stay links in the PDF; on paper they read as text with a hairline */
main a {
  color: inherit;
  text-decoration-thickness: 0.5pt;
  text-underline-offset: 0.18em;
}

/* Media fit the page: never wider than the text area, never taller than most of a page */
main :is(img, video) {
  max-width: 100%;
  max-height: 150mm;
  width: auto;
  height: auto;
}

/* ============================================================
   SECTION TITLE — title ↘, intro, tags (articles, Gazette, Education…)
   ============================================================ */

.tudotype-section-title {
  padding: 0 0 var(--print-gap);
}
.tudotype-section-title__heading,
.tudotype-section-title__heading.has-h-1-font-size {
  font-size: var(--wp--preset--font-size--h-1);
  line-height: 1.05;
}
.tudotype-section-title .tudotype-section-title__intro {
  max-width: var(--print-measure);
  padding-top: 5mm;
  font-size: 12pt;
  line-height: 1.45;
}
.tudotype-section-title__badge {
  display: none;
}

/* Byline tags become a line of mono text: "João Miranda · Mar 1, 2021 · 1 min read". Other tags
   (case studies) keep their fills, which print as they are */
:is(.tudo-article__meta, .tudo-gazette-card__meta) .tudotype-tag {
  height: auto;
  padding: 0;
  background: none;
  font-size: var(--wp--preset--font-size--caption);
  line-height: 1.4;
}
:is(.tudo-article__meta, .tudo-gazette-card__meta) .tudotype-tag + .tudotype-tag::before {
  content: "·";
  padding-inline: 0.6em;
  color: var(--wp--preset--color--ink-muted);
}

/* ============================================================
   ARTICLE — header, then the text at the print measure
   ============================================================ */

.tudo-article__meta {
  padding-top: 5mm;
  color: var(--wp--preset--color--ink-muted);
}
.tudo-article__header {
  margin-bottom: var(--print-gap);
  border-bottom: var(--print-rule);
}

.tudo-article__body {
  padding: 0;
  font-size: var(--wp--preset--font-size--body-lg);
  line-height: 1.5;
}
/* Text blocks keep the measure; media, tables and columns use the full width */
.tudo-article__body > :is(p, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, .wp-block-details, .wp-block-pullquote, pre) {
  max-width: var(--print-measure);
}
.tudo-article__body p {
  margin: 0 0 0.75em;
}
.tudo-article__body :is(h1, h3, h4) {
  margin: 8mm 0 3mm;
}
.tudo-article__body h1 { font-size: 20pt; }
.tudo-article__body h3 { font-size: var(--wp--preset--font-size--h-4); }
.tudo-article__body h4 { font-size: 11pt; }
/* Subtitles: the red break between sections */
.tudo-article__body h2 {
  margin: 8mm 0 3mm;
  font-size: var(--wp--preset--font-size--h-4);
  line-height: 1.2;
}
.tudo-article__body :is(ul, ol) {
  margin: 0 0 0.75em;
  padding-left: 5mm;
}
.tudo-article__body li {
  margin-bottom: 1mm;
}
.tudo-article__body :is(.wp-block-image, .wp-block-gallery, .wp-block-table, .wp-block-columns) {
  margin: var(--print-gap) 0;
}
.tudo-article__body .wp-block-image img {
  width: auto;
  border-radius: var(--radius-card);
}

/* ============================================================
   CORE BLOCKS — quotes, captions, code, tables, details, buttons
   ============================================================ */

/* Quote cards: a hairline on the left instead of the white card, at the text measure */
:is(.wp-block-quote.is-style-card, .tudo-article__body blockquote, .tudotype-quote-single__card) {
  max-width: var(--print-measure);
  margin: var(--print-gap) 0;
  padding: 0 0 0 5mm;
  border-left: 1pt solid var(--wp--preset--color--accent-amber);
  background: none;
  font-size: 11pt;
  line-height: 1.45;
  color: var(--wp--preset--color--ink-primary);
}
:is(.wp-block-quote, .tudo-article__body blockquote, .wp-block-pullquote) cite,
.tudotype-quote-single__author {
  margin-top: 2mm;
  font-size: var(--wp--preset--font-size--caption);
  letter-spacing: 0.08em;
}
.wp-block-pullquote,
.tudo-article__body .wp-block-pullquote {
  margin: var(--print-gap) 0;
}
.wp-block-pullquote blockquote p {
  font-size: var(--wp--preset--font-size--h-2);
  line-height: 1.1;
}

figcaption,
.wp-element-caption {
  font-size: var(--wp--preset--font-size--caption);
  color: var(--wp--preset--color--ink-muted);
}
.wp-block-image figcaption,
.wp-block-gallery figcaption {
  margin-top: 2mm;
}

.wp-block-gallery .wp-block-image img {
  border-radius: var(--radius-card);
}

.wp-block-code,
.tudo-article__body .wp-block-code {
  margin: var(--print-gap) 0;
  padding: 4mm 5mm;
  border: var(--print-rule);
  border-radius: var(--radius-card);
  background: var(--wp--preset--color--surface-light);
}
.wp-block-code code {
  font-size: 7.5pt;
  line-height: 1.5;
  color: var(--wp--preset--color--ink-primary);
  white-space: pre-wrap; /* paper can't scroll sideways */
}

/* Tables stay tables on paper (the ≤ 768 px rules stack them for phones): hairlines under rows */
.wp-block-table table {
  display: table;
  font-size: 9pt;
  line-height: 1.35;
  color: var(--wp--preset--color--ink-primary);
}
.wp-block-table thead {
  display: table-header-group;
  border: 0;
}
.wp-block-table tbody { display: table-row-group; }
.wp-block-table tr { display: table-row; }
.wp-block-table thead th,
.wp-block-table tbody td,
.wp-block-table tbody td:first-child,
.wp-block-table tbody td:last-child,
.wp-block-table tbody tr:last-child td {
  display: table-cell;
  width: auto;
  padding: 2mm 4mm 2mm 0;
  border: 0;
  border-bottom: var(--print-rule);
  vertical-align: top;
}
.wp-block-table thead th {
  background: none;
  font-size: var(--wp--preset--font-size--overline);
  letter-spacing: 0.08em;
  border-bottom-color: var(--wp--preset--color--ink-muted);
}
.wp-block-table tbody td:first-child {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
}

/* Accordions print open (print.js opens them); the summary becomes a small heading */
.wp-block-details summary {
  padding: 2mm 0 1mm;
  font-size: var(--wp--preset--font-size--body-lg);
  font-weight: var(--text-heading-md-weight);
}
.wp-block-details summary::after {
  display: none;
}
.wp-block-details > :not(summary) {
  padding-bottom: 2mm;
}
.wp-block-details,
.tudo-article__body .wp-block-details {
  border-bottom: var(--print-rule);
}

/* Buttons are links: outlined, so they read on white paper */
.wp-block-button__link {
  padding: 1.5mm 4mm;
  border: 0.5pt solid var(--wp--preset--color--ink-primary);
  background: none;
  font-size: var(--wp--preset--font-size--button);
  color: var(--wp--preset--color--ink-primary);
}

/* ============================================================
   GAZETTE — the cards as an index: topics, title, excerpt, byline
   ============================================================ */

.tudo-gazette {
  min-height: 0;
}
.tudo-gazette__list {
  padding: 0;
}
.tudo-gazette__cards {
  display: block;
  border-top: var(--print-rule);
}
.tudo-gazette-card {
  display: block;
  padding: 4mm 0;
  border-bottom: var(--print-rule);
  break-inside: avoid;
}
.tudo-gazette-card__box,
.tudo-gazette-card--highlight .tudo-gazette-card__box {
  display: block;
  padding: 0;
  background: none;
  color: var(--wp--preset--color--ink-primary);
}
.tudo-gazette-card__media,
.tudo-gazette-card__media[data-initial] {
  display: none;
}
.tudo-gazette-card__head {
  gap: 1.5mm;
}
.tudo-gazette-card__topics {
  font-size: var(--wp--preset--font-size--overline);
  color: var(--wp--preset--color--ink-muted);
}
.tudo-gazette-card__title,
.tudo-gazette-card--highlight .tudo-gazette-card__title {
  font-size: 14pt;
  font-weight: var(--text-heading-sm-weight);
  line-height: 1.15;
  color: var(--wp--preset--color--ink-primary);
}
.tudo-gazette-card__link {
  text-decoration: none;
}
.tudo-gazette-card__excerpt,
.tudo-gazette-card--highlight .tudo-gazette-card__excerpt {
  max-width: var(--print-measure);
  padding-top: 1.5mm;
  font-size: 9pt;
  font-weight: var(--text-body-sm-weight);
  font-feature-settings: normal;
  line-height: 1.4;
}
.tudo-gazette-card__meta {
  padding-top: 2mm;
  color: var(--wp--preset--color--ink-muted);
}
.tudo-gazette-card__author {
  flex: 0 0 auto;
}

/* A filtered Gazette says so: the field prints as an outlined box with the words, then "2 of 5" */
.tudo-gazette__filter {
  padding-top: 4mm;
}
.tudo-gazette__filter:has(.tudo-gazette__filter-input:placeholder-shown) {
  display: none;
}
.tudo-gazette__filter-field {
  width: auto;
}
.tudo-gazette__filter-field::after {
  display: none;
}
.tudo-gazette__filter-input {
  height: auto;
  padding: 1mm 3mm;
  border: var(--print-rule);
  background: none;
  font-size: var(--wp--preset--font-size--caption);
}
.tudo-gazette__filter-count {
  font-size: var(--wp--preset--font-size--caption);
  color: var(--wp--preset--color--ink-muted);
}

/* ============================================================
   EDITORIAL MODULES — Education, Faces and other post content
   ============================================================ */

/* Every module sits on the page margins; spacing between them is the document gap */
:is(.tudotype-section-subtitle, .tudotype-section-highlight, .tudotype-quote-grid, .tudotype-image-center, .tudotype-quote-single, .tudotype-carousel) {
  padding: 0 0 var(--print-gap);
  background: none;
}

.tudotype-section-subtitle {
  padding-top: 4mm;
  overflow: visible;
}
.tudotype-section-subtitle__heading,
.tudotype-section-subtitle__heading.has-h-2-font-size {
  font-size: var(--wp--preset--font-size--h-2);
  line-height: 1.1;
}
.tudotype-section-subtitle__text {
  max-width: var(--print-measure);
  font-size: var(--wp--preset--font-size--body-lg);
  line-height: 1.5;
}
.tudotype-section-subtitle__text p + p {
  padding-top: 0.75em;
}
.tudotype-section-subtitle__image {
  margin: var(--print-gap) 0 0;
}

.tudotype-section-highlight__text {
  max-width: var(--print-measure);
  font-size: var(--wp--preset--font-size--h-4);
  line-height: 1.2;
}

/* Quote grid: the cards wrap in rows, outlined */
.tudotype-quote-grid {
  flex-wrap: wrap;
  overflow: visible;
  gap: 3mm;
}
.tudotype-quote-card {
  flex: 0 0 calc((100% - 6mm) / 3);
  max-width: none;
  min-height: 0;
  padding: 4mm;
  border: var(--print-rule);
  box-sizing: border-box;
}
.tudotype-quote-card__title {
  font-size: 9pt;
  color: var(--wp--preset--color--ink-primary);
}
.tudotype-quote-card__meta {
  font-size: var(--wp--preset--font-size--overline);
}

/* Carousels: every slide, in a grid, at its own ratio (a row wider than the paper would make
   the browser shrink the whole printout to fit it) */
.tudotype-carousel .tudotype-carousel__track {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4mm;
  overflow: visible;
}
.tudotype-carousel--portrait .tudotype-carousel__track {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tudotype-carousel__item {
  width: auto;
  gap: 2mm;
}
.tudotype-carousel .tudotype-carousel__item :is(img, video),
.tudotype-carousel--mix .tudotype-carousel__item :is(img, video) {
  width: 100%;
  height: auto;
  max-height: none;
}
.tudotype-carousel__item :is(figcaption, .wp-element-caption) {
  text-align: start;
}

.tudotype-image-center figcaption,
.tudotype-image-center .wp-element-caption {
  padding-top: 2mm;
}

/* ============================================================
   CASE STUDIES, HEROES — the cover stays a picture, not a screen
   ============================================================ */

.tudotype-hero-image {
  position: static;
  aspect-ratio: auto;
  max-height: 110mm;
  margin-bottom: var(--print-gap);
  border-radius: var(--radius-card);
}
.tudotype-hero-image :is(img, video) {
  width: 100%;
  height: auto;
  max-height: 110mm;
  object-fit: cover;
}
/* The homepage opener (HOME in components.css): its H1 as a title, not a screen. The screen's
   fitted size and family (set by home-opener.js) give way to the title's */
.tudotype-home-opener {
  min-height: 0;
  padding: 0 0 var(--print-gap);
}
.tudotype-home-opener__stage {
  padding-top: 0;
}
.tudotype-home-opener__title {
  font-family: var(--wp--preset--font-family--sans);
  font-size: var(--wp--preset--font-size--h-1);
  font-weight: var(--text-heading-xl-weight);
  line-height: 1.05;
}

/* ============================================================
   LICENSING — the page as a quote (inc/licensing.php): the answers
   chosen and their prices, not the choices left out
   ============================================================ */

.tudotype-licence .tudotype-choice--card:not(:has(:checked)),
.tudotype-licence .tudotype-choice--chip:not(:has(:checked)) {
  display: none;
}
