/* ============================================================
   VitaNova — calorie calculator print / "Save as PDF" ("My daily plate")
   Loaded with media="print" on the calculator page only. It hides the
   whole page except .calc-print (resources/views/partials/calc-print),
   which calorie-calculator.js fills just before printing. Colours are
   fixed (not theme tokens) so dark mode never prints light text.
   ============================================================ */
/* margin 0 removes the browser's own header/footer (URL, date, title, page numbers);
   the 14mm page margins are drawn by .calc-print and the layout table instead */
@page { size: A4; margin: 0; }

html, body {
  background: #fff !important;
  color: #000 !important;
  margin: 0 !important;
  padding: 0 !important;
}
*, *::before, *::after { animation: none !important; transition: none !important; box-shadow: none !important; }

/* Everything except the print version: navbar, footer, search, chips, buttons, ads, cookie banner… */
body > :not(main),
main > :not(.calc-print),
ins.adsbygoogle, .adsbygoogle, iframe { display: none !important; }
main { display: block !important; margin: 0 !important; padding: 0 !important; min-height: 0 !important; }

.calc-print {
  display: block !important;
  color: #000;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 10.5pt;
  line-height: 1.5;
  padding: 0 14mm;   /* side margins, on every page */
}
[dir="rtl"] .calc-print { font-family: 'IBM Plex Sans Arabic', 'DM Sans', system-ui, sans-serif; }
.calc-print [hidden] { display: none !important; }
.calc-print p { margin: 0; }
.calc-print h2 { margin: 0 0 3mm; padding-bottom: 1.5mm; font-size: 13pt; color: #1F5F5B; border-bottom: .75pt solid #1F5F5B; }

/* Layout table: its footer row reserves room for .cp-footer at the bottom of every page */
.cp-layout { width: 100%; border-collapse: collapse; }
.cp-layout > thead > tr > td,
.cp-layout > tbody > tr > td,
.cp-layout > tfoot > tr > td { padding: 0; border: 0; }
.cp-head-space { height: 14mm; }     /* top margin, repeated on every page */
.cp-footer-space { height: 25mm; }   /* our footer + bottom margin, on every page */

/* Header */
.cp-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 3mm; border-bottom: 1.5pt solid #1F5F5B; }
.cp-brand { display: flex; align-items: center; gap: 2.5mm; color: #1F5F5B; font-weight: 700; font-size: 13pt; }
.cp-brand img { width: 9mm; height: 9mm; object-fit: contain; }
.cp-date { font-size: 9.5pt; color: #333; }
.cp-title { margin: 4mm 0 3mm; font-size: 18pt; line-height: 1.25; color: #000; }

/* Target: plate + numbers */
.cp-target { display: flex; align-items: center; gap: 8mm; margin-bottom: 5mm; break-inside: avoid; page-break-inside: avoid; }
.cp-plate { position: relative; flex: none; width: 44mm; height: 44mm; }
.cp-plate svg { width: 100%; height: 100%; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cp-plate__c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.cp-plate__c strong { font-family: 'DM Serif Display', Georgia, serif; font-size: 21pt; line-height: 1; color: #000; }
.cp-plate__c span { font-size: 8.5pt; color: #333; margin-top: 1mm; }
.cp-target__text { flex: 1; min-width: 0; }
.cp-goal { font-size: 13pt; font-weight: 700; color: #1F5F5B; margin-bottom: 2mm !important; }
.cp-note { margin-bottom: 3mm !important; padding: 2mm 3mm; border: .5pt solid #C6873A; border-radius: 2mm; font-size: 9pt; color: #333; }
.cp-macros { border-collapse: collapse; min-width: 70mm; }
.cp-macros th, .cp-macros td { padding: 1.2mm 3mm; border-bottom: .5pt solid #C9D8D5; text-align: start; }
.cp-macros thead th { font-size: 8.5pt; color: #1F5F5B; text-transform: uppercase; letter-spacing: .04em; }
[dir="rtl"] .cp-macros thead th { text-transform: none; letter-spacing: 0; }
.cp-macros td { font-variant-numeric: tabular-nums; }
.cp-dot { display: inline-block; width: 3mm; height: 3mm; border-radius: .8mm; margin-inline-end: 1.5mm; vertical-align: middle; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cp-dot--p { background: #1F5F5B; }
.cp-dot--c { background: #C6873A; }
.cp-dot--f { background: #EBC894; }

/* My details */
.cp-details { margin-bottom: 5mm; break-inside: avoid; page-break-inside: avoid; }
.cp-details dl { display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: 2mm 3mm; margin: 0; }
.cp-details dl > div { padding: 1.6mm 2.5mm; border: .5pt solid #C9D8D5; border-radius: 2mm; }
.cp-details dt { font-size: 8pt; color: #555; }
.cp-details dd { margin: 0; font-weight: 700; }

/* Today's meals */
.cp-day { margin-bottom: 4mm; }
.cp-meal { margin-bottom: 3mm; break-inside: avoid; page-break-inside: avoid; }
.cp-meal h3 { margin: 0 0 1.5mm; font-size: 11pt; color: #1F5F5B; }
.cp-items { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cp-items th, .cp-items td { padding: 1.2mm 2.5mm; border: .5pt solid #C9D8D5; text-align: start; vertical-align: top; }
.cp-items thead th {
  background: #E6F1F0; color: #1F5F5B; font-size: 8.5pt;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cp-items thead th:nth-child(1) { width: 46%; }
.cp-items thead th:nth-child(3) { width: 16%; }
.cp-items tfoot th, .cp-items tfoot td { font-weight: 700; background: #F4F8F7; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cp-items tfoot th { text-align: end; }
.cp-num { text-align: end !important; font-variant-numeric: tabular-nums; }
.cp-summary { width: 100%; border-collapse: collapse; margin-top: 2mm; break-inside: avoid; page-break-inside: avoid; }
.cp-summary th, .cp-summary td { padding: 1.5mm 3mm; border-top: .75pt solid #1F5F5B; text-align: start; }
.cp-summary td { text-align: end; font-weight: 700; }

/* Footer on every page */
.cp-footer {
  position: fixed; left: 14mm; right: 14mm; bottom: 9mm;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 4mm;
  padding-top: 1.5mm; border-top: .5pt solid #1F5F5B;
  font-size: 7.5pt; line-height: 1.4; color: #444;
}
.cp-footer .cp-disclaimer { flex-basis: 100%; }
.cp-url { color: #1F5F5B; font-weight: 600; }
