/* ============================================================
   Nikita Kapitonov — print / PDF CV
   Linked with media="print". The same stylesheet drives both
   Cmd+P in the browser and deploy/build-assets.sh, which prints
   Nikita_Kapitonov_CV.pdf with headless Chrome — so what you see
   in the print preview is exactly the downloadable PDF.
   Target: A4, exactly two pages.
   ============================================================ */

@media print {

  /* ---------- page ---------- */
  @page {
    size: A4;
    margin: 13mm 14mm 14mm;

    /* declaring margin boxes (even an empty one) makes Chrome drop its own
       date/title/URL header & footer when "Headers and footers" is ticked */
    @top-center { content: ""; }
    @bottom-left {
      content: "Nikita Kapitonov \2014  Full-stack AI Product Engineer";
      font-family: 'IBM Plex Mono', ui-monospace, monospace;
      font-size: 6.4pt;
      letter-spacing: 0.08em;
      color: #6f737d;
      vertical-align: middle;
    }
    @bottom-right {
      content: "kapitonov.su  \00B7  " counter(page) " / " counter(pages);
      font-family: 'IBM Plex Mono', ui-monospace, monospace;
      font-size: 6.4pt;
      letter-spacing: 0.08em;
      color: #6f737d;
      vertical-align: middle;
    }
  }

  /* light palette: remap the screen tokens so every leftover rule adapts */
  :root {
    --bg:        #ffffff;
    --bg-2:      #ffffff;
    --surface:   #ffffff;
    --surface-2: #ffffff;
    --line:      #d7dae0;
    --line-2:    #e8eaee;

    --text:      #111214;
    --dim:       #585c66;
    --faint:     #6f737d;

    --heat:      #c8431a;
    --heat-soft: #c8431a;
    --cool:      #0b7f8a;
    --ok:        #2f9e56;

    --p-body:    #2b2d33;
    --p-rail:    30mm;   /* left meta column shared by every row */
    --p-gap:     7mm;
  }

  *, *::before, *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    animation: none !important;
    transition: none !important;
    box-shadow: none;
    text-shadow: none;
  }

  html { font-size: 9.5pt; scroll-behavior: auto; }
  body {
    background: #fff !important;
    background-image: none !important;
    color: var(--text);
    font-size: 9.5pt;
    line-height: 1.45;
    letter-spacing: 0;
    overflow: visible;
  }
  a { color: inherit; text-decoration: none; }

  /* the screen hides .reveal until JS observes it — never in print */
  .reveal, .js .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* ---------- hide the screen-only chrome ---------- */
  .skip-link,
  .grain,
  .nav,
  .hero__field,
  canvas,
  .hero__telemetry,
  .hero__kicker,
  .hero__name,
  .hero__role,
  .hero__actions,
  .panel,
  .btn,
  a[download],
  .section--contact,
  .footer,
  .courses__toggle,
  .courses__list,
  .no-print {                      /* opt-out hook for future screen-only elements */
    display: none !important;
  }

  main { position: static; z-index: auto; }

  /* ---------- print header ---------- */
  .print-only { display: block !important; }
  .print-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8mm;
    align-items: end;
    position: relative;
    padding-bottom: 4.2mm;
    margin-bottom: 4.2mm;
    border-bottom: 0.5pt solid var(--line);
  }
  /* thermal signature: a short gradient tick sitting on the rule */
  .print-head::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -0.9pt;
    width: 38mm;
    height: 1.8pt;
    border-radius: 1pt;
    background: linear-gradient(90deg, #0b8f9c, #6fb35a 45%, #e26a3a 72%, #c8431a);
  }
  .print-head__kicker {
    font-size: 7pt;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 2.4mm;
  }
  .print-head__kicker .arrow { color: var(--heat); margin: 0 0.6mm; }
  .print-head__name {
    font-family: var(--display);
    font-weight: 900;
    font-size: 31pt;
    line-height: 0.92;
    letter-spacing: -0.035em;
    color: var(--text);
  }
  /* solid heat, not the screen's gradient text: background-clip:text leaves
     seams / falls back inconsistently across PDF viewers (Preview, poppler) */
  .print-head__surname { color: var(--heat); }
  .print-head__role {
    font-family: var(--display);
    font-weight: 700;
    font-size: 13pt;
    letter-spacing: -0.012em;
    line-height: 1.2;
    color: var(--text);
    margin-top: 2mm;
  }
  .print-head__contact {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    margin-top: 2.6mm;
    font-size: 7.8pt;
    letter-spacing: 0.02em;
    color: var(--text);
  }
  .print-head__contact li + li::before {
    content: "\00B7";
    color: var(--faint);
    margin: 0 2.2mm;
  }
  .print-head__contact a { color: var(--text); }
  .print-head__photo {
    display: block;
    width: 23mm;
    height: 28.5mm;
    object-fit: cover;
    object-position: center 22%;
    border-radius: 1.6mm;
    /* no CSS filter: it would force Chrome to rasterise the photo at 300 ppi;
       unfiltered, the original JPEG is embedded as-is (sharper, smaller) */
  }

  /* ---------- hero → profile lead + highlight row ---------- */
  .hero-wrap { isolation: auto; }
  .hero {
    max-width: none;
    margin: 0;
    padding: 0;
    pointer-events: auto;
  }
  .hero__grid { display: block; }
  .hero__main { container-type: normal; }
  .hero__summary {
    max-width: none;
    margin: 0;
    font-size: 10.2pt;
    line-height: 1.5;
    color: var(--p-body);
  }
  .hero__summary strong { color: var(--text); font-weight: 600; }

  .hero__stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-top: 4mm;
    background: none;
    border: 0;
    border-top: 0.5pt solid var(--line);
    border-bottom: 0.5pt solid var(--line);
    border-radius: 0;
    overflow: visible;
    break-inside: avoid;
  }
  .hero__stats li {
    background: none;
    padding: 2.4mm 3.2mm 2.3mm;
    gap: 0.6mm;
    border-left: 0.5pt solid var(--line-2);
  }
  .hero__stats li:first-child { border-left: 0; padding-left: 0; }
  .hero__stats b,
  .hero__stats li:nth-child(n+2) b {
    font-size: 14.5pt;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text);
  }
  .hero__stats li:first-child b { color: var(--heat); }
  .hero__stats span {
    font-size: 6.9pt;
    line-height: 1.35;
    letter-spacing: 0.01em;
    color: var(--dim);
  }

  /* ---------- sections ---------- */
  .section {
    max-width: none;
    margin: 4.8mm 0 0;
    padding: 2mm 0 0;
    border-top: 0.5pt solid var(--line);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 6mm;
    align-items: baseline;
    position: relative;
  }
  .section::before {                       /* small heat tick on every section rule */
    content: "";
    position: absolute;
    left: 0;
    top: -0.9pt;
    width: 7mm;
    height: 1.4pt;
    background: var(--heat);
  }
  .section > *,
  .summary > * { grid-column: 1 / -1; }
  .summary { display: contents; }

  .section__title,
  .summary .section__title,
  .section__title--big {
    grid-column: 1;
    grid-row: 1;
    max-width: none;
    margin: 0;
    font-size: 12.5pt;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.012em;
    color: var(--text);
    break-after: avoid;
  }
  .section__label {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    gap: 2mm;
    font-size: 6.6pt;
    letter-spacing: 0.2em;
    color: var(--faint);
    break-after: avoid;
  }
  .section__num { color: var(--heat); }
  .section__label .line { flex: 0 0 6mm; height: 0.5pt; background: var(--line); }

  /* ---------- summary ---------- */
  .summary p {
    margin-top: 1.8mm;
    font-size: 9.2pt;
    line-height: 1.5;
    color: var(--p-body);
    max-width: none;
  }
  .summary p + p { margin-top: 1.4mm; }
  .summary em { color: var(--heat); }

  /* ---------- experience / flight log ---------- */
  .timeline { margin-top: 2.8mm; }
  .timeline::before {
    left: calc(var(--p-rail) + var(--p-gap) / 2);
    top: 1.6mm;
    bottom: 3mm;
    width: 0.5pt;
    background: linear-gradient(180deg, var(--heat), var(--line) 14%, var(--line));
  }
  .entry,
  .entry:last-child {
    display: grid;
    grid-template-columns: var(--p-rail) minmax(0, 1fr);
    column-gap: var(--p-gap);
    padding: 0 0 3mm;
    break-inside: avoid;
  }
  .entry:last-child { padding-bottom: 0; }
  .entry__marker {
    left: calc(var(--p-rail) + var(--p-gap) / 2 - 1.15mm);
    top: 1.1mm;
    width: 2.3mm;
    height: 2.3mm;
    border: 0.6pt solid #b9bcc4;
    background: #fff;
  }
  .entry--current .entry__marker {
    border-color: var(--heat);
    background: var(--heat);
    box-shadow: 0 0 0 0.8mm rgba(200, 67, 26, 0.16);
  }
  .entry__meta {
    grid-column: 1;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    flex-wrap: nowrap;
    gap: 0.5mm;
    margin: 0;
    padding-top: 0.5mm;
    font-size: 7pt;
    letter-spacing: 0.02em;
    line-height: 1.3;
    color: var(--faint);
  }
  .entry__date { color: var(--text); font-weight: 500; white-space: nowrap; letter-spacing: 0; }
  .entry__dur::before,
  .entry__loc::before { content: none; }
  .entry__badge {
    margin-top: 0.6mm;
    padding: 0 1.3mm;
    border: 0.5pt solid rgba(200, 67, 26, 0.55);
    border-radius: 0.8mm;
    font-size: 6pt;
    letter-spacing: 0.16em;
    line-height: 1.6;
    color: var(--heat);
  }
  .entry__body {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 2mm;
  }
  .entry__lede,
  .entry__points { flex: 0 0 100%; }
  .entry__org {
    font-size: 11.2pt;
    line-height: 1.15;
    letter-spacing: -0.012em;
    color: var(--text);
  }
  .entry__role {
    margin: 0;
    font-size: 9.1pt;
    font-weight: 500;
    color: var(--heat);
  }
  .entry__role::before { content: "/"; color: #b9bcc4; margin-right: 2mm; font-weight: 400; }
  .entry__lede { margin-top: 0.8mm; font-size: 8.6pt; color: var(--dim); }
  .entry__points { margin-top: 1mm; gap: 0.45mm; }
  .entry__points li {
    padding-left: 3.4mm;
    font-size: 8.8pt;
    line-height: 1.4;
    color: var(--p-body);
    break-inside: avoid;
  }
  .entry__points li::before {
    left: 0.4mm;
    top: 0.7em;
    width: 1.5mm;
    height: 0.6pt;
    background: #a3a7b0;
  }

  .tag,
  .metric {
    margin-left: 1.2mm;
    padding: 0 1.2mm;
    border-radius: 0.8mm;
    font-size: 6.2pt;
    letter-spacing: 0.01em;
    line-height: 1.55;
    vertical-align: 0.5pt;
  }
  .tag {
    color: var(--dim);
    background: none;
    border: 0.5pt solid #cfd2d8;
  }
  .metric {
    color: var(--cool);
    background: rgba(11, 127, 138, 0.06);
    border: 0.5pt solid rgba(11, 127, 138, 0.45);
  }
  .metric::before { font-size: 4.8pt; vertical-align: 0.6pt; }

  /* ---------- projects ---------- */
  .projects__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.6mm;
    margin-top: 3mm;
  }
  .project {
    gap: 0.9mm;
    padding: 2.3mm 3mm 2.2mm;
    border: 0.5pt solid var(--line);
    border-radius: 1.6mm;
    background: #fff;
    break-inside: avoid;
  }
  .project__top { gap: 2mm; font-size: 6.3pt; letter-spacing: 0.12em; }
  .project__kind { border: 0.5pt solid var(--line); border-radius: 0.8mm; padding: 0 1.2mm; }
  .project__date { gap: 1.2mm; }
  .project__name { font-size: 10.4pt; line-height: 1.15; color: var(--text); }
  .project__desc { font-size: 8.3pt; line-height: 1.4; color: var(--p-body); }
  .project__link {
    margin-top: 0.4mm;
    gap: 1.4mm;
    font-size: 7.6pt;
    color: var(--cool);
    word-break: normal;
  }
  .dot, .dot--sm {
    width: 1.5mm;
    height: 1.5mm;
    margin-right: 0;
    background: var(--ok);
    box-shadow: none !important;
  }

  /* ---------- skills ---------- */
  .topskills,
  .module,
  .langs {
    display: grid;
    grid-template-columns: var(--p-rail) minmax(0, 1fr);
    column-gap: var(--p-gap);
    align-items: baseline;
    margin: 0;
    padding: 1.5mm 0;
    border: 0;
    border-top: 0.5pt solid var(--line-2);
    border-radius: 0;
    background: none;
    break-inside: avoid;
  }
  .topskills { margin-top: 2.6mm; border-top: 0; padding-top: 0.4mm; }
  .modules { display: block; margin: 0; }
  .module__title,
  .topskills .module__title,
  .module--accent .module__title {
    margin: 0;
    font-weight: 500;
    font-size: 6.6pt;
    letter-spacing: 0.18em;
    line-height: 1.4;
    color: var(--faint);
  }
  .topskills .module__title { color: var(--heat); }
  .topskills__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8mm 6mm;
    margin: 0;
  }
  .topskills__list li {
    gap: 1.6mm;
    font-size: 10.4pt;
    line-height: 1.25;
    color: var(--text);
  }
  .topskills__num { font-size: 6.6pt; color: var(--heat); }

  .chips { display: flex; flex-wrap: wrap; gap: 0.2mm 0; }
  .chips li,
  .module--accent .chips li {
    display: inline;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    font-size: 8.7pt;
    line-height: 1.45;
    white-space: nowrap;
    color: var(--p-body);
  }
  .chips li:not(:last-child)::after {
    content: "\00B7";
    margin: 0 1.5mm;
    color: var(--faint);
  }

  .langs__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8mm 7mm;
  }
  .langs__list li { flex-direction: row; align-items: baseline; gap: 1.6mm; }
  .langs__name { font-size: 9.6pt; line-height: 1.3; color: var(--text); }
  .langs__level { font-size: 7.2pt; letter-spacing: 0.05em; color: var(--dim); }

  /* ---------- education ---------- */
  .edu,
  .edu + .edu,
  .edu--cert {
    grid-template-columns: var(--p-rail) minmax(0, 1fr);
    column-gap: var(--p-gap);
    margin: 0;
    padding: 1.6mm 0;
    border: 0;
    border-top: 0.5pt solid var(--line-2);
    border-radius: 0;
    background: none;
    break-inside: avoid;
  }
  .section#education .edu:first-of-type { margin-top: 2.4mm; border-top: 0; padding-top: 0.4mm; }
  .edu__years { padding-top: 0.5mm; font-size: 7pt; font-weight: 500; letter-spacing: 0.02em; color: var(--text); }
  .edu__school { font-size: 10.4pt; line-height: 1.2; color: var(--text); }
  .edu__degree { margin-top: 0.3mm; font-size: 8.9pt; color: var(--heat); }
  .edu--cert .edu__body { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 2mm; }
  .edu--cert .edu__degree { margin: 0; }
  .edu--cert .edu__degree::before { content: "/"; color: #b9bcc4; margin-right: 2mm; }
  .edu__note { margin-top: 0.6mm; max-width: none; font-size: 8.4pt; color: var(--dim); }

  .courses {
    margin: 0;
    border: 0;
    border-top: 0.5pt solid var(--line-2);
    border-radius: 0;
    background: none;
    break-inside: avoid;
  }
  .courses__summary {
    display: grid;
    grid-template-columns: var(--p-rail) minmax(0, 1fr);
    column-gap: var(--p-gap);
    align-items: baseline;
    padding: 1.6mm 0 0;
    border-radius: 0;
  }
  .courses .module__title { margin: 0; }
  .courses__meta { font-size: 8.2pt; letter-spacing: 0.02em; color: var(--dim); }

  /* ---------- typographic hygiene ---------- */
  p, li { orphans: 3; widows: 3; }
}
