/* =========================================================================
   Advoke CV — Print stylesheet
   The only place that decides what appears on paper. Every screen-only
   element is hidden; the resume document is rendered at exact page
   geometry with no scaled transforms.
   ========================================================================= */

@page {
  size: A4;
  margin: 0;
}

@page :first {
  margin: 0;
}

/* -------------------------------------------------------------------------
   Reset document to a clean sheet
   ------------------------------------------------------------------------- */

@media print {
  html,
  body {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-size: 11pt;
  }

  /* Hide everything by default */
  body > *:not(.print-root) {
    display: none !important;
  }

  .site-header,
  .site-footer,
  .skip-link,
  .toast-host,
  .modal-backdrop,
  .nav-drawer,
  .mobile-bar,
  .editor-toolbar,
  .editor-tabs,
  .editor-pane,
  .editor-mobile-bar,
  .mobile-bar,
  .no-print,
  [data-no-print] {
    display: none !important;
  }

  /* -------------------------------------------------------------------
     The print root is the single container rendered for print.
     Everything else disappears.
     ------------------------------------------------------------------- */

  .print-root {
    display: block !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    width: 100% !important;
  }

  /* -------------------------------------------------------------------
     Page geometry
     ------------------------------------------------------------------- */

  .print-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 0;
    background: #ffffff;
    position: relative;
    page-break-after: always;
    break-after: page;
    overflow: visible;
  }

  .print-page--letter {
    width: 215.9mm;
    min-height: 279.4mm;
  }

  .print-page:last-of-type {
    page-break-after: auto;
    break-after: auto;
  }

  /* -------------------------------------------------------------------
     The resume document itself
     ------------------------------------------------------------------- */

  .cv-doc {
    width: 100%;
    min-height: 100%;
    padding: 46px 54px;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    transform: none !important;
    page-break-inside: auto;
  }

  .cv-doc,
  .cv-doc * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    text-shadow: none !important;
  }

  /* -------------------------------------------------------------------
     Remove preview chrome
     ------------------------------------------------------------------- */

  .preview-stage,
  .preview-page,
  .preview-viewport,
  .cv-viewport,
  .cv-frame,
  .cv-frame__inner,
  .tpl-card__thumb-inner,
  .hero__stack,
  .hero__card {
    box-shadow: none !important;
    transform: none !important;
  }

  /* -------------------------------------------------------------------
     Links
     ------------------------------------------------------------------- */

  a,
  a:visited {
    color: inherit !important;
    text-decoration: none !important;
  }

  /* Show URLs after link text on the page. */
  .cv-doc a[href]:not([href^="#"]):not([href^="mailto:"]):not([href^="tel:"])::after {
    content: " (" attr(href) ")";
    font-size: 8.5pt;
    color: #57648a;
  }

  /* -------------------------------------------------------------------
     Page break control
     ------------------------------------------------------------------- */

  .cv-section {
    page-break-inside: auto;
    break-inside: auto;
  }

  .cv-entry,
  .cv-publication,
  .cv-block,
  .cv-skill--bar,
  .cv-stat {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .cv-section__head {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .cv-entry__head {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Prevent an orphaned single bullet at the top of a page. */
  .cv-entry__bullets li:first-child {
    page-break-before: avoid;
    break-before: avoid;
  }

  /* -------------------------------------------------------------------
     Avoid blank trailing pages
     Some browsers add a trailing page if the last element has a
     page-break-after rule. This strips it.
     ------------------------------------------------------------------- */

  .cv-doc > *:last-child,
  .cv-doc > *:last-child > *:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
    margin-bottom: 0 !important;
  }

  body::after {
    content: none !important;
    display: none !important;
  }

  /* -------------------------------------------------------------------
     US Letter overrides
     The wrapper element carries `print-page--letter` when the user picks
     Letter format; the @page rule is injected by page-setup.js at runtime.
     ------------------------------------------------------------------- */

  .print-root[data-page-format="letter"] .cv-doc {
    /* Slightly wider padding on Letter since it is a bit narrower vertically */
    padding: 40px 50px;
  }

  /* -------------------------------------------------------------------
     Photo: guarantee that the photo does not disappear
     ------------------------------------------------------------------- */

  .cv-photo {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* -------------------------------------------------------------------
     Backgrounds and borders
     ------------------------------------------------------------------- */

  * {
    background-clip: padding-box;
  }

  /* -------------------------------------------------------------------
     Hide everything inside an .editor-shell when printing from the editor
     (the print pipeline swaps in a dedicated root instead).
     ------------------------------------------------------------------- */

  #editor-root,
  #main-content > *:not(.print-root) {
    display: none !important;
  }

  #main-content > .print-root {
    display: block !important;
  }

  /* -------------------------------------------------------------------
     Remove safe-area padding that makes no sense on paper
     ------------------------------------------------------------------- */

  .safe-bottom,
  .safe-top {
    padding: 0 !important;
  }

  /* -------------------------------------------------------------------
     Ensure the resume page shows only one page marker per page
     ------------------------------------------------------------------- */

  .preview-page-break {
    display: none !important;
  }
}

/* =========================================================================
   Explicit Letter page rule — applied when the browser supports it.
   page-setup.js injects a dynamic <style> element with the correct @page
   size; this fallback is only used if script injection fails.
   ========================================================================= */

@media print and (min-resolution: 200dpi) {
  .print-root[data-page-format="letter"] .cv-doc {
    padding: 40px 50px;
  }
}