/* ============================================================
   PRINT / PDF STYLES — theme-independent
   Both the authenticated Nutrient Report and the public Shared
   Day page wrap printable content in #detailed-micro-report.
   NOTE: .print-only { display: none } lives in layout.css because
   this stylesheet is media="print" and would never apply on screen.
   ============================================================ */

@media print {

  /* ── Page setup ── */
  @page {
    size: letter portrait;
    margin: 0.75in 0.7in;
    /* Suppress browser default URL/title headers in print renderers that support
       CSS Paged Media margin boxes (e.g. Prince, Antenna House). Chrome and Firefox
       ignore these — users must uncheck "Headers and footers" in the print dialog. */
    @top-left   { content: ""; }
    @top-center { content: ""; }
    @top-right  { content: ""; }
    @bottom-left   { content: ""; }
    @bottom-center { content: ""; }
    @bottom-right  { content: ""; }
  }

  /* ── Show print-only elements ── */
  .print-only { display: block !important; }

  /* ── Unlock scroll containers so all content prints ── */
  /* .view has height:100%;overflow-y:auto in both themes — clips content. */
  html,
  body,
  .view,
  .view.no-dock {
    height: auto !important;
    overflow: visible !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* ── Hide browser chrome and non-print elements ── */
  .appbar,
  .dock,
  .footer,
  button,
  .btn,
  .pill,
  .app-actions,
  .theme-toggle-switch,
  .no-print,
  .nutrient-toggle,
  .nutrient-food-breakdown,
  .help-modal-overlay { display: none !important; }

  /* ── Base page reset ── */
  body {
    background: white !important;
    color: #111 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 8.5pt;
    line-height: 1.4;
  }

  .container,
  .content-container,
  main.shell {
    display: block !important;
    border: none !important;
    height: auto !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: white !important;
  }

  .section {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
  }

  /* ── Report wrapper ── */
  #detailed-micro-report {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    /* Flex layout enables ordering of sections for public_day's two-page structure */
    display: flex !important;
    flex-direction: column !important;
  }

  /* Suppress any theme card decorative pseudo-elements on the wrapper itself */
  #detailed-micro-report::before,
  #detailed-micro-report::after { display: none !important; }

  /* ── Print header — real HTML element (.print-only .print-header) ── */
  /* Layout: [left: MetaboLog brand/CTA] [right: report title + date] */
  .print-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
    border-bottom: 2pt solid #000 !important;
    margin: 0 0 8pt 0 !important;
    padding: 0 0 5pt 0 !important;
    order: 0;
    break-after: avoid;
  }

  .print-header-brand {
    font-family: "JetBrains Mono", "Courier New", monospace;
    font-size: 9pt !important;
    font-weight: 700 !important;
    color: #000 !important;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.2;
  }

  .print-header-brand .print-header-sub {
    display: block !important;
    font-weight: 400 !important;
    font-size: 6.5pt !important;
    text-transform: none;
    letter-spacing: 0;
    color: #666 !important;
    margin-top: 1pt;
  }

  .print-header-title {
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    font-size: 11pt !important;
    font-weight: 700 !important;
    color: #000 !important;
    text-align: right !important;
    line-height: 1.2;
  }

  .print-header-title .print-header-date {
    display: block !important;
    font-size: 7.5pt !important;
    font-weight: 400 !important;
    font-style: italic;
    color: #555 !important;
    margin-top: 1pt;
  }

  /* ── Section ordering — public_day.rs uses print-sec-* classes ── */
  /* Page 1: Key Ratios → Minerals → Vitamins */
  #detailed-micro-report > .print-sec-ratios   { order: 1; }
  #detailed-micro-report > .print-sec-minerals { order: 2; }
  #detailed-micro-report > .print-sec-vitamins { order: 3; }
  /* Page 2: food log, then macros, then fatty acids */
  #detailed-micro-report > .print-sec-foodlog  { order: 10; break-before: page !important; }
  #detailed-micro-report > .print-sec-macros   { order: 11; }
  #detailed-micro-report > .print-sec-fatty    { order: 12; }

  /* ── Section articles (public_day uses direct <article> children) ── */
  #detailed-micro-report > article {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 8pt 0 0 0 !important;
    background: white !important;
  }

  /* ── Section divs (detailed_micro_report uses .mt-4 divs) ── */
  #detailed-micro-report .mt-4 { margin-top: 8pt !important; }
  #detailed-micro-report .mt-3 { margin-top: 6pt !important; }

  /* ── Hide non-printable elements inside report ── */
  #detailed-micro-report > .row                          { display: none !important; }
  #detailed-micro-report > .meta,
  #detailed-micro-report > p.meta                        { display: none !important; }
  /* info footer card at bottom of detailed_micro_report */
  #detailed-micro-report > .mt-4.card[style*="background"] { display: none !important; }

  /* ── Section headings ── */
  #detailed-micro-report h3 {
    font-family: "JetBrains Mono", "Courier New", monospace;
    font-size: 6.5pt !important;
    font-weight: 700 !important;
    color: #fff !important;
    background: #222 !important;
    border: none !important;
    box-shadow: none !important;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding: 2pt 5pt !important;
    margin: 0 0 4pt 0 !important;
    break-after: avoid;
  }

  /* Hide sub-descriptions that follow section headings */
  #detailed-micro-report h3 + .meta,
  #detailed-micro-report h3 + p.meta { display: none !important; }

  /* ── Two-column grid ── */
  #detailed-micro-report .grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 3pt !important;
    break-inside: auto; /* remove constraint that prevented long grids from breaking across pages */
  }

  /* ── Cards ── */
  #detailed-micro-report .card {
    border: 0.5pt solid #666 !important;
    box-shadow: none !important;
    padding: 3pt 5pt !important;
    background: white !important;
    margin: 0 !important;
    break-inside: avoid;
  }

  /* Suppress theme decorative pseudo-elements on all nested cards */
  #detailed-micro-report .card::before,
  #detailed-micro-report .card::after { display: none !important; }

  #detailed-micro-report .card strong {
    font-family: "JetBrains Mono", "Courier New", monospace;
    font-size: 7pt !important;
  }

  #detailed-micro-report .card span:not(.chip):not([style*="width"]) {
    font-size: 7pt !important;
  }

  #detailed-micro-report .card .meta {
    font-size: 6.5pt !important;
    color: #555 !important;
    margin: 1.5pt 0 0 0 !important;
    line-height: 1.2;
  }

  #detailed-micro-report .card .row { margin-bottom: 1.5pt !important; }

  /* ── Chips / badges ── */
  #detailed-micro-report .chip {
    font-family: "JetBrains Mono", "Courier New", monospace;
    font-size: 6.5pt !important;
    padding: 0.5pt 3pt !important;
    background: #f0f0f0 !important;
    border: 0.5pt solid #666 !important;
    box-shadow: none !important;
  }

  /* ── Progress bars ── */
  #detailed-micro-report .bar {
    height: 4pt !important;
    margin: 1.5pt 0 !important;
    border: 0.5pt solid #888 !important;
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #detailed-micro-report .bar-sm { height: 3.5pt !important; }

  #detailed-micro-report .bar > span {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #detailed-micro-report .bar .tick { opacity: 0.3; }

  /* Macro-ratio stacked colour bar (public_day: inline height:12px) */
  #detailed-micro-report [style*="height:12px"] { height: 5pt !important; }

  /* ── Food-log entry border indicators ── */
  #detailed-micro-report [style*="border-left"] { border-left-width: 2pt !important; }

  /* ── Override large inline font sizes in food log / macros ── */
  #detailed-micro-report [style*="font-size:1.5rem"] { font-size: 11pt !important; }
  #detailed-micro-report [style*="font-size:0.9rem"] { font-size: 7pt !important; }
  #detailed-micro-report [style*="font-size:0.85rem"] { font-size: 7pt !important; }
  #detailed-micro-report [style*="font-size:0.8rem"] { font-size: 6.5pt !important; }
  #detailed-micro-report [style*="font-size:0.78rem"] { font-size: 6.5pt !important; }
  #detailed-micro-report [style*="font-size:0.75rem"] { font-size: 6pt !important; }

  /* ── Force colour printing for bars and chips ── */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
