/* ==========================================================================
   print.css: print-to-résumé (owner E12; spec §8.4). Linked with media="print".
   Ctrl/⌘P, action:print and every "Résumé" control print article#resume and
   nothing else: one page on Letter or A4, black on white.
   Box: 186 mm wide (the A4 text width, so Letter breaks lines identically).
   Measured (Chrome, Safari/WebKit, Firefox agree within 0.4 mm): the text ends
   22 mm above the foot of a Letter sheet and 30 mm on A4; 18 mm on Letter
   when the web fonts are blocked and the metric-matched fallbacks set it.
   ========================================================================== */

@media print {
  /* The 12 mm margin is padding on #resume, not a page margin: an empty page
     margin is where browsers print their date / title / URL header lines.
     Top padding only: the foot of the sheet stays clear because the text ends
     well above it, and a browser that adds its own margins (or a heavier
     fallback font) eats into that air before it could push a second page.
     box-decoration-break repeats the top padding should a page ever break. */
  @page { margin: 0; }

  html,
  body {
    color-scheme: light;
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    display: block !important;
    transform: none !important;
    filter: none !important;
  }
  html::before, html::after,
  body::before, body::after { content: none !important; display: none !important; } /* grain, overlays */
  body > :not(#resume) { display: none !important; }
  /* Open dialogs and popovers live in the top layer, outside their parents' display. */
  dialog, [popover], ::backdrop { display: none !important; }

  /* ---- The sheet: isolated from every screen rule, then set afresh ---- */
  #resume {
    all: initial;
    display: block !important; /* beats the UA [hidden] rule */
    box-sizing: border-box;
    width: 186mm;
    max-width: 100%; /* custom print-dialog margins narrower than the box: reflow, never clip */
    margin: 0 auto;
    padding: 12mm 0 0;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    color: #000;
    font: 400 9.5pt/1.32 "Geist", "LT Sans Fallback", system-ui, sans-serif;
    font-kerning: normal;
    font-variant-ligatures: common-ligatures;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    orphans: 2;
    widows: 2;
    /* Vertical rhythm (Letter); A4 gets 17.6 mm more paper, below */
    --sec: 12.5pt;    /* above a section head */
    --sec-in: 4pt;    /* below its rule */
    --role: 6pt;      /* between roles */
    --item: 3pt;      /* between projects */
  }
  /* Print media queries see the sheet (Chrome: 279.4 mm Letter, 297 mm A4, whatever the
     margins). A4 spends part of its extra height on air, capped so the sheet would still
     fit Letter if a browser applied this there. */
  @media (min-height: 290mm) {
    #resume { --sec: 15pt; --sec-in: 5pt; --role: 8pt; --item: 4pt; }
  }
  #resume * { all: revert; box-sizing: border-box; }
  /* C++23 is wrapped in span.nowrap: no box (it would be its own grid item in .resume-skills), kept whole */
  #resume .nowrap { display: contents; white-space: nowrap; }
  #resume a { color: inherit; text-decoration: none; }
  #resume strong, #resume b { font-weight: 600; }
  #resume p, #resume li { margin: 0; text-wrap: pretty; }
  #resume ul { list-style: none; margin: 0; padding: 0; }

  /* ---- Header: the name left; contact and availability right, on its baseline ---- */
  #resume .resume-head {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12pt;
    align-items: end;
  }
  #resume .resume-name {
    grid-row: 1 / span 2;
    align-self: last baseline;
    margin: 0;
    font: 400 22pt/1 "Instrument Serif", "LT Serif Fallback", Georgia, serif;
    letter-spacing: -.005em;
  }
  #resume .resume-contact,
  #resume .resume-seeking { grid-column: 2; text-align: right; }
  #resume .resume-contact { font-size: 8.5pt; }
  #resume .resume-seeking { align-self: last baseline; font-weight: 500; }

  /* ---- Section heads: mono caps over a 0.5 pt rule ---- */
  #resume h3 {
    margin: var(--sec) 0 var(--sec-in);
    padding: 0 0 2pt;
    border-bottom: .5pt solid #000;
    font: 500 7.5pt/1.2 "JetBrains Mono", "LT Mono Fallback", ui-monospace, Menlo, monospace;
    letter-spacing: .12em;
    text-transform: uppercase;
  }

  /* ---- Experience: title left, dates right on the same baseline ---- */
  #resume .resume-role { break-inside: avoid; }
  #resume .resume-role + .resume-role { margin-top: var(--role); }
  #resume .resume-role h4 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 9pt;
    margin: 0 0 .5pt;
    font: 600 9.5pt/1.32 "Geist", "LT Sans Fallback", system-ui, sans-serif;
  }
  #resume .resume-role-title { letter-spacing: -.01em; }
  /* "<strong>Role</strong> — organisation": the role carries the weight. */
  #resume .resume-role-title:has(strong) { font-weight: 400; }
  #resume .resume-dates {
    flex: none;
    font: 500 7.5pt/1 "JetBrains Mono", "LT Mono Fallback", ui-monospace, Menlo, monospace;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  /* Bullets: an en dash hung in the indent (a glyph renders evenly at any zoom). */
  #resume .resume-role li,
  #resume .resume-projects li,
  #resume .resume-activities li { position: relative; padding-left: 9pt; }
  #resume .resume-role li::before,
  #resume .resume-projects li::before,
  #resume .resume-activities li::before {
    content: "\2013";
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 400;
  }

  /* ---- Projects, awards & activities, skills, languages ---- */
  #resume .resume-projects li + li,
  #resume .resume-activities li + li { margin-top: var(--item); }
  /* Skills: group labels in one column as wide as the longest ("Systems & performance:"), lists aligned */
  #resume .resume-skills { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .5pt 6pt; }
  #resume .resume-skills li { display: contents; }

  /* ---- Footer ---- */
  #resume .resume-foot {
    margin: calc(var(--sec) + 1pt) 0 0;
    font: 400 7pt/1.3 "JetBrains Mono", "LT Mono Fallback", ui-monospace, Menlo, monospace;
    letter-spacing: .04em;
  }
}
