/* Shared by the isolated print document and the Ctrl+P fallback.
   A4 landscape has 200mm of usable height after 5mm page margins.
   Keep 1mm for rounding; all remaining height belongs to the writing grid. */
@page {
  size: A4 landscape;
  margin: 5mm;
}

body.weekly-planner-print-page {
  margin: 0;
  padding: 0;
  background: #fff;
}

#weekly-planner-print-root {
  display: none;
  --wp-accent: #b94f1b;
  --wp-soft: #fff3e9;
  --wp-notes: #087d85;
  box-sizing: border-box;
  color: #243a38;
  font: 10pt/1.35 'Segoe UI', Arial, sans-serif;
  text-align: left;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

body.weekly-planner-print-page > #weekly-planner-print-root { display: block; }
#weekly-planner-print-root * { box-sizing: border-box; }
#weekly-planner-print-root[data-theme="sky"] { --wp-accent: #367ca6; --wp-soft: #edf5fa; --wp-notes: #8b5a8c; }
#weekly-planner-print-root[data-theme="sage"] { --wp-accent: #56765c; --wp-soft: #f0f5eb; --wp-notes: #947044; }
#weekly-planner-print-root[data-theme="ink"] { --wp-accent: #4d5856; --wp-soft: #fff; --wp-notes: #4d5856; }

#weekly-planner-print-root .wp-print-sheet {
  display: flex;
  flex-direction: column;
  width: 287mm;
  max-width: 100%;
  height: 199mm;
  margin: 0;
  padding: 2mm;
  border: .6mm double var(--wp-accent);
  background: #fff;
  overflow: visible;
}

#weekly-planner-print-root .wp-print-heading { flex: 0 0 auto; margin: 0 0 2mm; }
#weekly-planner-print-root h1 { margin: 0; font: 20pt/1.1 Georgia, serif; color: #243a38; overflow-wrap: anywhere; }
#weekly-planner-print-root .wp-print-heading p { margin: 1.5mm 0 0; font-size: 8pt; }
#weekly-planner-print-root .wp-print-focus { margin: 0 0 2mm; padding: 0 0 2mm; border-bottom: .2mm solid #d6ded9; white-space: pre-wrap; overflow-wrap: anywhere; }
#weekly-planner-print-root .wp-print-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  flex: 1 1 0;
  min-height: 0;
  gap: 3mm;
}
#weekly-planner-print-root .wp-print-day { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#weekly-planner-print-root .wp-print-day > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2mm;
  min-height: 7mm;
  padding: 1mm 2mm;
  flex: 0 0 auto;
  border-top: .6mm solid var(--wp-accent);
  color: var(--wp-accent);
  background: var(--wp-soft);
}
#weekly-planner-print-root h2 { margin: 0; font: 700 8.5pt/1.2 'Segoe UI', Arial, sans-serif; text-transform: uppercase; letter-spacing: .5pt; }
#weekly-planner-print-root .wp-print-day > header > span { font-size: 8pt; }
#weekly-planner-print-root .wp-print-notes > header { color: var(--wp-notes); border-color: var(--wp-notes); }
#weekly-planner-print-root .wp-print-writing { position: relative; flex: 1; min-height: 0; }
#weekly-planner-print-root .wp-print-rules { position: absolute; inset: 0; width: 100%; height: 100%; }
#weekly-planner-print-root .wp-print-entry { position: relative; padding: 0 1.5mm; font-size: 10pt; line-height: 6mm; white-space: pre-wrap; overflow-wrap: anywhere; }
#weekly-planner-print-root .wp-print-weather { display: flex; gap: 2mm; flex: 0 0 auto; padding: 1.5mm 1mm; color: #536960; font-size: 8pt; }
#weekly-planner-print-root .wp-print-weather svg { flex: 0 0 6mm; width: 6mm; height: 6mm; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#weekly-planner-print-root .wp-print-forecast { font-weight: 600; }
#weekly-planner-print-root .wp-print-weather-detail { font-size: 7pt; }
#weekly-planner-print-root .wp-print-credit { flex: 0 0 auto; margin: 2mm 0 0; font-size: 6.5pt; line-height: 1.3; color: #536960; }
#weekly-planner-print-root a { color: inherit; text-decoration: none; }

/* Long entries expand rather than being cut off at the bottom of a cell. */
#weekly-planner-print-root[data-overflow="true"] .wp-print-sheet { height: auto; min-height: 199mm; }
#weekly-planner-print-root[data-overflow="true"] .wp-print-grid { flex: none; grid-template-rows: auto auto; }
#weekly-planner-print-root[data-overflow="true"] .wp-print-day { break-inside: avoid; }
#weekly-planner-print-root[data-overflow="true"] .wp-print-writing { min-height: 55mm; }

@media print {
  body.wp-print-active,
  body.weekly-planner-print-page { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.wp-print-active > :not(#weekly-planner-print-root),
  body.weekly-planner-print-page > :not(#weekly-planner-print-root) { display: none !important; }
  body > #weekly-planner-print-root { display: block !important; margin: 0 !important; padding: 0 !important; }
  /* Defensive fallback for late ad insertion when printing via Ctrl+P. */
  ins.adsbygoogle,
  .google-auto-placed,
  .adsbygoogle,
  iframe,
  [id^="google_ads"],
  [id^="google_vignette"],
  [data-ad-status],
  [data-ad-client] { display: none !important; }
  #weekly-planner-print-root .wp-print-sheet > :not(.wp-print-heading):not(.wp-print-focus):not(.wp-print-grid):not(.wp-print-credit),
  #weekly-planner-print-root .wp-print-grid > :not(.wp-print-day) { display: none !important; }
}
