/* =========================================================================
   Guide Capture — printed document.

   Export is the browser's own "Print → Save as PDF". No PDF library, no
   dependency, no server. Works on iOS Safari and Android Chrome.

   RE-SKINNING: everything a customer would change (logo, accent colour,
   org name, footer text, classification wording) arrives as CSS custom
   properties / text set from js/config.js at print time. Do not hardcode
   customer branding in here.
   ========================================================================= */

@media print {

  /* Hide the application chrome; print only the generated document. */
  body > *:not(.print-root) { display: none !important; }

  html, body {
    background: #fff !important;
    font-size: 11pt;
    color: #111;
  }

  .print-root { display: block !important; }

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

  .doc { font-family: "Helvetica Neue", Arial, sans-serif; color: #111; }

  /* ------------------------------------------------------------ header -- */

  .doc-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; padding-bottom: 8px;
    border-bottom: 2.5pt solid var(--doc-accent, #12343f);
  }
  .doc-logo { max-height: 16mm; max-width: 50mm; object-fit: contain; }
  .doc-org { font-size: 13pt; font-weight: 700; color: var(--doc-accent, #12343f); }
  .doc-header-right { text-align: right; font-size: 8.5pt; color: #444; line-height: 1.5; }

  .doc-title {
    font-size: 19pt; font-weight: 700; line-height: 1.2;
    margin: 10pt 0 2pt;
  }
  .doc-subtitle { font-size: 10pt; color: #444; margin: 0 0 10pt; }

  /* ------------------------------------------- classification (crucial) -- */

  /* This block is the single most important thing on the page: it exists so
     nobody can mistake this document for a controlled work instruction.
     Reworded per customer if needed — never removed, never made subtle. */
  .doc-classification {
    border: 1.5pt solid #8a6d1f;
    border-left: 5pt solid #8a6d1f;
    background: #fdf6e4;
    padding: 8pt 10pt;
    margin-bottom: 12pt;
    page-break-inside: avoid;
  }
  .doc-classification .cls-title {
    font-size: 11.5pt; font-weight: 700; color: #6b5312; letter-spacing: .02em;
    text-transform: uppercase;
  }
  .doc-classification .cls-body { font-size: 8.5pt; color: #4a3c12; margin-top: 3pt; line-height: 1.45; }

  /* -------------------------------------------------------- metadata -- */

  /* Flex-wrap rather than a fixed grid: the optional fields (checked by,
     review date, equipment) come and go, and a part-empty grid row looks
     unfinished on a document people are meant to trust. */
  .doc-meta {
    display: flex; flex-wrap: wrap; gap: 4pt; margin-bottom: 12pt;
    page-break-inside: avoid;
  }
  .doc-meta div {
    flex: 1 1 34mm; padding: 5pt 7pt;
    border: 0.75pt solid #c9d0d2; background: #fafbfb;
  }
  .doc-meta .k { font-size: 7pt; text-transform: uppercase; letter-spacing: .06em; color: #667; }
  .doc-meta .v { font-size: 9.5pt; font-weight: 600; margin-top: 1pt; }

  .doc-linkline {
    font-size: 9pt; padding: 6pt 8pt; background: #eef2f3; border-left: 3pt solid var(--doc-accent, #12343f);
    margin-bottom: 12pt; page-break-inside: avoid;
  }

  /* -------------------------------------------------------- cautions -- */

  .doc-section-title {
    font-size: 11pt; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--doc-accent, #12343f);
    border-bottom: 1pt solid var(--doc-accent, #12343f);
    padding-bottom: 3pt; margin: 0 0 8pt;
  }
  .doc-cautions { margin-bottom: 14pt; page-break-inside: avoid; }
  .doc-caution {
    display: flex; gap: 8pt; align-items: baseline;
    padding: 6pt 8pt; margin-bottom: 4pt;
    border: 0.75pt solid #d8d2c4; border-left-width: 4pt; background: #fbfaf7;
    page-break-inside: avoid;
  }
  .doc-caution.sev-danger  { border-left-color: #a5251c; background: #fdf1ef; }
  .doc-caution.sev-warning { border-left-color: #8a5000; background: #fdf7ee; }
  .doc-caution.sev-note    { border-left-color: #12343f; background: #f2f6f7; }
  .doc-caution .lbl {
    font-size: 7.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    white-space: nowrap; min-width: 15mm;
  }
  .doc-caution.sev-danger .lbl  { color: #a5251c; }
  .doc-caution.sev-warning .lbl { color: #8a5000; }
  .doc-caution.sev-note .lbl    { color: #12343f; }
  .doc-caution .txt { font-size: 9.5pt; line-height: 1.4; }
  .doc-caution .ref { font-size: 8pt; color: #667; white-space: nowrap; }

  /* ----------------------------------------------------------- steps -- */

  .doc-step {
    display: flex; gap: 10pt; align-items: flex-start;
    padding: 8pt 0; border-bottom: 0.75pt solid #dde2e3;
    page-break-inside: avoid;
  }
  .doc-step-photo {
    width: 62mm; height: auto; max-height: 55mm; object-fit: contain;
    border: 0.75pt solid #ccd3d5; background: #fff; flex-shrink: 0;
  }
  .doc-step-photo-missing {
    width: 62mm; height: 24mm; border: 0.75pt dashed #ccd3d5; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 8pt; color: #889;
  }
  .doc-step-main { flex: 1; }
  .doc-step-n {
    font-size: 9pt; font-weight: 700; color: #fff; background: var(--doc-accent, #12343f);
    display: inline-block; min-width: 6mm; text-align: center;
    padding: 1pt 3pt; margin-bottom: 3pt;
  }
  .doc-step-text { font-size: 10.5pt; line-height: 1.45; }
  .doc-step-flag {
    display: inline-block; font-size: 7.5pt; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; padding: 1pt 4pt; margin-top: 4pt; border: 0.75pt solid;
  }
  .doc-step-flag.sev-danger  { color: #a5251c; border-color: #a5251c; }
  .doc-step-flag.sev-warning { color: #8a5000; border-color: #8a5000; }
  .doc-step-flag.sev-note    { color: #12343f; border-color: #12343f; }

  /* ---------------------------------------------------------- footer -- */

  .doc-footer {
    margin-top: 14pt; padding-top: 6pt; border-top: 1pt solid #c9d0d2;
    display: flex; justify-content: space-between; gap: 12pt;
    font-size: 8pt; color: #556;
  }
  .doc-footer .fr { text-align: right; }

  .doc-provenance {
    font-size: 7.5pt; color: #778; margin-top: 4pt; line-height: 1.4;
  }
}
