/* ---------- Study: print / "Export PDF" ---------- */
/* Everything is scoped to body.study-page-active (added by study.js while the
   Study page is open), so printing any other page is unaffected. The result:
   just the note — white page, black text, headings, lists, checklists,
   callouts, tables and images kept, collapsible sections open. */

/* A zero page margin is what makes the browser leave out its own header and
   footer (date, page title, URL, page numbers). The real margins are put back
   as padding on the page content below. */
@page {
  margin: 0;
}

@media print {
  html,
  body.study-page-active {
    height: auto !important;
    overflow: visible !important;
    color: #000 !important;
    background: #fff !important;
  }

  /* app chrome */
  body.study-page-active::before,
  body.study-page-active .topbar,
  body.study-page-active .sidebar,
  body.study-page-active .sidebar-toggle,
  body.study-page-active .bottombar,
  body.study-page-active .page-header,
  body.study-page-active .study-side,
  body.study-page-active .study-tabs,
  body.study-page-active .study-crumbrow,
  body.study-page-active .study-toolbar,
  body.study-page-active .study-notice,
  body.study-page-active .study-outline,
  body.study-page-active .study-status,
  body.study-page-active .study-empty,
  body.study-page-active .study-tagbar__input,
  body.study-page-active .study-tag button,
  body.study-page-active .st-menu,
  body.study-page-active .study-pop,
  body.study-page-active .study-linkpop {
    display: none !important;
  }

  /* flatten the app layout into a normal flowing page */
  body.study-page-active .app-body,
  body.study-page-active .main,
  body.study-page-active #page-content,
  body.study-page-active .study-app,
  body.study-page-active .study-main,
  body.study-page-active .study-doc,
  body.study-page-active .study-body,
  body.study-page-active .study-scroll {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* The margins @page no longer provides. box-decoration-break: clone repeats
     the top/bottom padding on every printed page, not just the first and last. */
  body.study-page-active #page-content {
    padding: 15mm 16mm !important;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }

  body.study-page-active .study-page {
    max-width: none;
    margin: 0;
  }

  /* An UNTICKED checkbox: an empty box with a thin dark border (the dark
     colour scheme otherwise prints it as a black square). Ticked boxes keep
     their normal look. */
  body.study-page-active .study-prose input[type="checkbox"]:not(:checked) {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin: 0;
    background: #fff !important;
    border: 1.5px solid #333;
    border-radius: 3px;
  }

  body.study-page-active .study-title {
    color: #000;
    font-size: 26pt;
    margin-bottom: 6pt;
  }

  body.study-page-active .study-tagbar {
    margin-bottom: 14pt;
  }

  body.study-page-active .study-tag {
    color: #333;
    background: #eee;
    border-color: #bbb;
  }

  /* the note */
  body.study-page-active .study-prose {
    min-height: 0;
    color: #000;
    font-size: 11pt;
    line-height: 1.55;
  }

  body.study-page-active .study-prose,
  body.study-page-active .study-prose * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.study-page-active .study-prose p.is-editor-empty::before,
  body.study-page-active .study-prose summary.is-empty::before {
    content: none !important;
  }

  body.study-page-active .study-prose h1,
  body.study-page-active .study-prose h2,
  body.study-page-active .study-prose h3 {
    color: #000;
    break-after: avoid;
  }

  /* explicitly coloured text would be unreadable on white: print it black */
  body.study-page-active .study-prose span[style*="color"],
  body.study-page-active .study-prose a,
  body.study-page-active .study-prose .study-note-link {
    color: #000 !important;
  }

  body.study-page-active .study-prose a,
  body.study-page-active .study-prose .study-note-link {
    background: none;
    border: 0;
    padding: 0;
    text-decoration: underline;
  }

  body.study-page-active .study-prose .study-note-link::before {
    content: none;
  }

  body.study-page-active .study-prose blockquote {
    color: #333;
    border-left-color: #888;
  }

  body.study-page-active .study-prose hr {
    border-top-color: #999;
  }

  body.study-page-active .study-prose pre,
  body.study-page-active .study-prose code {
    color: #000;
    background: #f3f3f3;
    border-color: #ccc;
  }

  /* callouts keep their coloured edge and a light tint */
  body.study-page-active .study-callout {
    background: rgba(var(--c), 0.12);
    break-inside: avoid;
  }

  body.study-page-active .study-callout::before {
    color: #222;
  }

  /* tables */
  body.study-page-active .study-prose .tableWrapper {
    overflow: visible;
  }

  body.study-page-active .study-prose th,
  body.study-page-active .study-prose td {
    color: #000;
    border: 1px solid #888 !important;
  }

  body.study-page-active .study-prose th {
    background: #ececec;
  }

  body.study-page-active .study-prose tr {
    break-inside: avoid;
  }

  body.study-page-active .study-prose .selectedCell::after,
  body.study-page-active .study-prose .column-resize-handle {
    display: none;
  }

  /* checklists */
  body.study-page-active .study-prose ul[data-type="taskList"] li[data-checked="true"] > div {
    color: #555;
  }

  /* collapsible sections print OPEN (the saved note is not changed) */
  body.study-page-active .study-prose div[data-type="details"] {
    display: block;
    padding: 6pt 10pt;
    border: 1px solid #bbb;
    break-inside: avoid;
  }

  body.study-page-active .study-prose div[data-type="details"] > button {
    display: none;
  }

  body.study-page-active .study-prose div[data-type="details"] > div {
    display: block;
  }

  body.study-page-active .study-prose div[data-type="details"] [data-type="detailsContent"],
  body.study-page-active .study-prose div[data-type="details"] [data-type="detailsContent"][hidden] {
    display: block !important;
    content-visibility: visible !important;
  }

  /* videos: no player on paper — a clickable link to the video instead */
  body.study-page-active .study-video {
    width: auto;
    max-width: none;
    margin: 6pt 0;
    break-inside: avoid;
  }

  body.study-page-active .study-video__frame {
    display: none !important;
  }

  body.study-page-active .study-video__print {
    display: block;
    padding: 8pt 10pt;
    color: #000 !important;
    font-size: 10.5pt;
    text-decoration: underline;
    word-break: break-all;
    background: #f3f3f3;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  /* images */
  body.study-page-active .study-img {
    break-inside: avoid;
  }

  body.study-page-active .study-img img {
    outline: 0 !important;
  }

  body.study-page-active .study-img__handle,
  body.study-page-active .study-img__badge {
    display: none !important;
  }
}
