/*
 * The resume and CV, on screen and on paper. Loaded only by /resume and /cv,
 * after tufte.css and custom.css, and overriding both where an essay's
 * defaults don't suit a document.
 *
 * Three parts: the document layout (applies everywhere), the print rules that
 * shape the PDF, and a single-column fallback for narrow screens. Keeps the
 * two-column label/content structure of the original Google Docs resume.
 */

.doc {
  max-width: 52rem;
  margin-block: 2.5rem;
  font-size: 1.1rem;
  line-height: 1.5;
}

/* tufte widths `section > p` to 55% to leave a margin for sidenotes, and sets
   a 2rem line-height meant for essays. Neither suits a document. */
.doc p {
  width: auto;
  line-height: 1.5;
}

/*
 * Name and contacts on the left, location and the summary on the right, in a
 * 2x2 grid. The column split is the same 13rem + 2rem the sections below use,
 * so the summary starts on the same vertical line as every section's content
 * and the contacts sit under the name in the label gutter.
 */
.doc-head {
  display: grid;
  grid-template-columns: 13rem 1fr;
  column-gap: 2rem;
  row-gap: 1.35rem;
  align-items: start;
  margin-bottom: 2.5rem;
}

.doc-head .doc-name {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.1;
  white-space: nowrap;
}

.doc-head .where {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.doc-head address {
  grid-column: 1;
  grid-row: 2;
  font-style: normal;
  font-size: 0.95rem;
  line-height: 1.6;
}

.doc-head .headline {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.45;
}

/*
 * The section label sits in a left column, but the content must stay in
 * normal block flow: Chromium fragments a grid container badly across printed
 * pages, pushing whole rows to the next sheet and costing a page. Absolutely
 * positioning the label into a reserved gutter paginates correctly, and has
 * the right behaviour when a section does span two pages — the label stays
 * with the section's start rather than repeating.
 */
.doc-section {
  position: relative;
  padding-top: 1.25rem;
  padding-left: 15rem;
  border-top: 2px solid currentColor;
  margin-bottom: 2rem;
}

.doc-section > h2 {
  position: absolute;
  top: 1.25rem;
  left: 0;
  width: 13rem;
  margin: 0;
  font-size: 1.2rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
}

.entry + .entry {
  margin-top: 1.5rem;
}

.entry-long + .entry-long {
  margin-top: 2.25rem;
}

.entry h3 {
  margin: 0;
  font-size: 1.15rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.3;
}

.entry p {
  margin: 0.4rem 0 0;
  font-size: 1rem;
}

.doc .meta {
  font-size: 0.9rem;
  opacity: 0.65;
}

.entry-long p {
  margin-top: 0.85rem;
  line-height: 1.55;
}

.role-projects {
  margin-top: 1.1rem;
  padding-left: 0.9rem;
  border-left: 2px solid rgba(17, 17, 17, 0.15);
}

.projects-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

.project {
  font-size: 0.95rem;
  margin-top: 0.55rem;
}

.note {
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.75;
}

.skill-row,
.award {
  margin: 0.3rem 0 0;
  font-size: 1rem;
}

/* --- print / PDF ------------------------------------------------------- */

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

@media print {
  /* The PDF is the document alone: no wordmark, site nav, page title or
     download links. The header and download list are named outright because
     custom.css gives them rules that would otherwise win on specificity and
     bring `display` back: `.site-header` is a flex row, and `ul.top-links`
     is reset with `all: revert`. */
  body > :not(article),
  .site-header,
  article > h1,
  .top-links.doc-actions {
    display: none;
  }

  /* Astro injects the bundled tufte.css after this file, so a bare `body` or
     `article` selector here would lose to tufte's on source order (its 12.5%
     body indent survived into the PDF). The extra element wins on
     specificity instead. */
  html body {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  body article {
    padding: 0;
  }

  .doc {
    max-width: none;
    margin-block: 0;
    font-size: 9.5pt;
    line-height: 1.4;
  }

  /* The screen layout is airy on purpose; paper is not. These tighten the
     vertical rhythm enough to keep the resume to two pages. */
  .doc-head {
    grid-template-columns: 10rem 1fr;
    column-gap: 1.5rem;
    row-gap: 1rem;
    margin-bottom: 1.6rem;
  }

  .doc-head .doc-name {
    font-size: 19pt;
  }

  .doc-head .headline,
  .doc-head .where,
  .doc-head address {
    font-size: 9.5pt;
    line-height: 1.5;
  }

  .doc-section {
    padding-top: 0.7rem;
    padding-left: 11.5rem;
    margin-bottom: 1rem;
  }

  .doc-section > h2 {
    top: 0.7rem;
    width: 10rem;
    font-size: 10.5pt;
  }

  .entry + .entry {
    margin-top: 0.75rem;
  }

  .entry-long + .entry-long {
    margin-top: 1.5rem;
  }

  .entry h3 {
    font-size: 10.5pt;
  }

  .entry p,
  .skill-row,
  .award {
    margin-top: 0.15rem;
    font-size: 9.5pt;
    line-height: 1.45;
  }

  .entry-long p {
    margin-top: 0.6rem;
  }

  .role-projects {
    margin-top: 0.8rem;
  }

  .project {
    margin-top: 0.4rem;
  }

  /* Never strand a heading at the foot of a page. */
  .doc-section > h2,
  .entry h3,
  .projects-label {
    break-after: avoid;
  }

  /* Keep a resume entry whole where it fits on one page. A CV role's prose
     may span pages, but an individual paragraph torn across a sheet is hard
     to read — and so is a Selected-projects block. Keep each of those whole. */
  .entry,
  .entry-long p,
  .role-projects,
  .note {
    break-inside: avoid;
  }

  .entry-long {
    break-inside: auto;
  }

  /* Links print as plain text — the URL is dead weight on paper, and the
     addresses in the header already carry the contact details. */
  .doc a {
    color: inherit;
    text-decoration: none;
    background: none;
    text-shadow: none;
  }
}

/* --- narrow screens ---------------------------------------------------- */

@media screen and (max-width: 760px) {
  .doc-head {
    grid-template-columns: 1fr;
    row-gap: 0.75rem;
  }

  /* One column: drop the explicit placement so the header falls back to DOM
     order (name, location, contacts, summary). */
  .doc-head > * {
    grid-column: 1;
    grid-row: auto;
  }

  .doc-head .doc-name {
    white-space: normal;
  }

  .doc-section {
    padding-left: 0;
  }

  .doc-section > h2 {
    position: static;
    width: auto;
    margin-bottom: 0.75rem;
  }
}
