/* Board pack — print / PDF (A4 landscape). Rendered by public/boardpack.js into #print-root.
   Class-only styling (strict CSP: no inline styles). Mirrors the PowerPoint design. */

@page { size: A4 landscape; margin: 12mm; }
@page bp-cover { size: A4 landscape; margin: 0; }

#print-root { display: none; }

/* Printing is for the admin when people sign in (admin-only.js sets html.not-admin): anyone else prints only these words. */
@media print {
  html.not-admin body > * { display: none !important; }
  html.not-admin body::after { content: "Admin access only"; display: block; margin: 40mm auto; text-align: center; font: 600 22pt/1.4 "Inter", sans-serif; color: #000; }
}

/* Show only the pack while printing (class set by printPack, or any print while a pack is mounted). */
html.printing body > *:not(#print-root) { display: none !important; }
html.printing #print-root { display: block; }
@media print {
  body:has(> #print-root:not(:empty)) > *:not(#print-root) { display: none !important; }
  #print-root:not(:empty) { display: block; }
  html.printing body, body:has(> #print-root:not(:empty)) { background: #fff !important; margin: 0; padding: 0; }
}

#print-root, .pack-preview {
  /* the client's brand (Brand Refresh v4): navy, coral accent */
  --bp-navy: #161327; --bp-peach: #E8654A; --bp-bg: #FBF4EF; --bp-line: #ECE4DC;
  --bp-ink-2: #4F4446; --bp-muted: #7A6E6A; --bp-good: #16A068; --bp-bad: #E0483C; --bp-cover-sub: #DCD6EA;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--bp-navy);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
  font-variant-numeric: tabular-nums;
}
#print-root *, #print-root *::before, #print-root *::after, .pack-preview * { box-sizing: border-box; }

/* On screen (while the dialog is up) show the pages as sheets. */
@media screen {
  html.printing body { background: #DAE4E7; }
  html.printing #print-root { padding: 24px 0; }
  html.printing .bp-page { margin: 0 auto 24px; box-shadow: 0 10px 30px -12px rgba(34, 26, 69, .3); }
  html.printing .bp-content { padding: 12mm; width: 297mm; height: 210mm; }
}

/* ---------- Pages ---------- */
.bp-page {
  position: relative; overflow: hidden; background: #fff;
  width: 273mm; height: 186mm;
  break-after: page; page-break-after: always; break-inside: avoid;
}
.bp-page:last-child { break-after: auto; page-break-after: auto; }

/* ---------- Brand ---------- */
.bp-brand { display: inline-flex; align-items: center; gap: 2.2mm; white-space: nowrap; }
.bp-mark { width: 6mm; height: 6mm; flex-shrink: 0; }
.bp-word { font-size: 10.5pt; letter-spacing: -.01em; }
.bp-word b { font-weight: 400; color: var(--bp-navy); }
.bp-word i { font-style: normal; font-weight: 750; color: var(--bp-navy); }
.bp-accent { width: 18mm; height: 1mm; border-radius: 1mm; background: var(--bp-peach); }

/* ---------- Cover ---------- */
.bp-cover {
  page: bp-cover; width: 297mm; height: 210mm;
  background: var(--bp-navy); color: #fff; padding: 20mm 22mm;
  display: flex; flex-direction: column;
}
.bp-ring {
  position: absolute; width: 168mm; height: 168mm; right: -62mm; top: 22mm;
  border: 11mm solid var(--bp-peach); border-radius: 50%;
}
.bp-ring-2 {
  position: absolute; width: 200mm; height: 200mm; right: -78mm; top: 6mm;
  border: 1.8mm solid transparent; border-top-color: rgba(232, 101, 74, .55); border-left-color: rgba(232, 101, 74, .55);
  border-radius: 50%; transform: rotate(-20deg);
}
.bp-cover-head { position: relative; }
.bp-cover .bp-mark { width: 9mm; height: 9mm; }
.bp-cover .bp-word { font-size: 17pt; }
.bp-cover .bp-word b { color: #fff; }
.bp-product { margin-top: 2.5mm; font-size: 8.5pt; letter-spacing: .22em; text-transform: uppercase; color: #A8998E; }
.bp-cover-main { position: relative; margin-top: auto; margin-bottom: auto; max-width: 160mm; }
.bp-cover-title { margin: 0 0 6mm; font-size: 33pt; line-height: 1.08; font-weight: 750; letter-spacing: -.02em; color: #fff; }
.bp-cover-sub { margin: 5mm 0 0; font-size: 13pt; color: var(--bp-cover-sub); }
.bp-cover-foot { position: relative; font-size: 9.5pt; color: #A8998E; }

/* ---------- Content pages ---------- */
.bp-content { display: flex; flex-direction: column; }
.bp-head { display: flex; justify-content: space-between; align-items: center; gap: 8mm; }
.bp-head-meta { font-size: 8pt; color: var(--bp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-title { margin: 6mm 0 3mm; font-size: 20pt; line-height: 1.15; font-weight: 750; letter-spacing: -.015em; color: var(--bp-navy); }
.bp-sub { margin: 2.5mm 0 0; font-size: 9.5pt; color: var(--bp-muted); }
.bp-body { flex: 1; min-height: 0; margin-top: 6mm; display: flex; flex-direction: column; }
.bp-foot { display: flex; justify-content: space-between; align-items: center; border-top: .3mm solid var(--bp-line); padding-top: 2.5mm; margin-top: 4mm; font-size: 7.5pt; color: var(--bp-muted); }
.bp-pno { font-weight: 700; color: var(--bp-navy); }

.bp-sec { min-height: 0; }
.bp-flex { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bp-subhead { margin: 0 0 3mm; font-size: 10.5pt; font-weight: 700; color: var(--bp-navy); }
.bp-sec-stack > .bp-sec + .bp-sec { margin-top: 6mm; }

/* Two-up */
.bp-two { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 0; }
.bp-half { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-right: 7mm; }
.bp-half + .bp-half { padding: 0 0 0 7mm; border-left: .3mm solid var(--bp-line); }

/* KPIs */
.bp-kpis { display: grid; gap: 4mm; }
.bp-cols-1 { grid-template-columns: repeat(1, 1fr); } .bp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.bp-cols-3 { grid-template-columns: repeat(3, 1fr); } .bp-cols-4 { grid-template-columns: repeat(4, 1fr); }
.bp-cols-5 { grid-template-columns: repeat(5, 1fr); } .bp-cols-6 { grid-template-columns: repeat(6, 1fr); }
.bp-kpi { background: var(--bp-bg); border: .3mm solid var(--bp-line); border-radius: 3.5mm; padding: 4mm; min-height: 30mm; display: flex; flex-direction: column; }
.bp-kpi-label { font-size: 8.5pt; color: var(--bp-ink-2); }
.bp-kpi-value { margin: auto 0 1.5mm; padding-top: 3mm; font-size: 20pt; font-weight: 750; letter-spacing: -.02em; color: var(--bp-navy); white-space: nowrap; }
.bp-kpi-delta { font-size: 8.5pt; font-weight: 600; color: var(--bp-muted); }
.bp-kpi-delta.bp-good { color: var(--bp-good); } .bp-kpi-delta.bp-bad { color: var(--bp-bad); }
.bp-kpi-lead { background: var(--bp-navy); border-color: var(--bp-navy); }
.bp-kpi-lead .bp-kpi-label, .bp-kpi-lead .bp-kpi-delta.bp-neutral { color: var(--bp-cover-sub); }
.bp-kpi-lead .bp-kpi-value { color: #fff; }
.bp-kpi-lead .bp-kpi-delta.bp-good { color: #6FD7AE; } .bp-kpi-lead .bp-kpi-delta.bp-bad { color: #FF9A9A; }
.bp-half .bp-kpi { min-height: 22mm; padding: 3mm; }
.bp-half .bp-kpi-value { font-size: 14pt; }

/* Charts */
.bp-chart { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bp-chart-frame { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.bp-chart-img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
/* Fallback caps where flex sizing isn't honoured by the print engine. */
.bp-content > .bp-body > .bp-sec-chart .bp-chart-img { max-height: 120mm; }
.bp-half .bp-chart-img { max-height: 95mm; }
.bp-sec-stack .bp-chart-img { max-height: 70mm; }
.bp-note { margin: 3mm 0 0; padding-left: 3mm; border-left: 1mm solid var(--bp-peach); font-size: 9pt; color: var(--bp-ink-2); }
.bp-empty { display: grid; place-items: center; width: 100%; height: 40mm; background: var(--bp-bg); border-radius: 3mm; color: var(--bp-muted); font-size: 9pt; }

/* Tables */
.bp-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.bp-table th { text-align: left; font-weight: 700; color: var(--bp-navy); background: var(--bp-bg); border-bottom: .35mm solid #C9D7DB; padding: 1.9mm 2.5mm; }
.bp-table td { padding: 1.55mm 2.5mm; border-bottom: .25mm solid var(--bp-line); color: var(--bp-ink-2); }
.bp-table td:first-child { color: var(--bp-navy); }
.bp-table .bp-r { text-align: right; }
.bp-table tr { break-inside: avoid; }
.bp-half .bp-table { font-size: 8.5pt; }
.bp-more { margin: 2mm 0 0; font-size: 7.5pt; color: var(--bp-muted); }

/* Bullets */
.bp-bullets { margin: 0; padding: 0; list-style: none; max-width: 210mm; }
.bp-bullets li { position: relative; padding-left: 7mm; margin-bottom: 5mm; font-size: 12.5pt; line-height: 1.45; color: var(--bp-ink-2); }
.bp-bullets li::before { content: ""; position: absolute; left: 0; top: .55em; width: 2.2mm; height: 2.2mm; border-radius: 50%; background: var(--bp-peach); }
.bp-half .bp-bullets li { font-size: 10pt; margin-bottom: 3mm; padding-left: 5mm; }

/* Brief page: one sentence, up to three stats, one small table */
.bp-lead { margin: 0 0 5mm; max-width: 235mm; font-size: 12.5pt; line-height: 1.45; color: var(--bp-ink-2); }
.bp-brief > .bp-kpis { margin-bottom: 6mm; }
.bp-brief .bp-kpi-delta { line-height: 1.35; }

/* Notes */
.bp-notes { display: flex; flex-direction: column; gap: 6mm; }
.bp-quote { margin: 0; padding: .5mm 0 .5mm 5mm; border-left: 1.4mm solid var(--bp-peach); break-inside: avoid; }
.bp-quote p { margin: 0; font-size: 11pt; line-height: 1.45; color: var(--bp-navy); }
.bp-quote cite { display: block; margin-top: 2mm; font-style: normal; font-size: 8pt; color: var(--bp-muted); }
.bp-half .bp-notes { gap: 4mm; }
.bp-half .bp-quote p { font-size: 9.5pt; }

/* In-app preview: the same pages, scaled down. */
@media screen {
  .pack-preview .bp-page { zoom: .52; margin: 0 auto 28px; box-shadow: 0 8px 24px -10px rgba(34, 26, 69, .3); border-radius: 6px; }
  .pack-preview .bp-content { padding: 12mm; width: 297mm; height: 210mm; }
}
