/* print.css — Phase 9. Letter landscape, both views, grid-only output.
 * No in-app print button — printing is a hidden feature triggered by the
 * browser's default Cmd/Ctrl+P shortcut. The styling is rough; circle back
 * if printing becomes a regular workflow again.
 *
 * Why !important: the day-grid scaler (Grid._applyResponsiveScale /
 * Week._applyResponsiveScale) writes --minute-px and --col-width *inline* on
 * :root from the on-screen container size. Inline beats CSS without
 * !important. We force print-specific sizes so the grid fits the page.
 *
 * Why print-color-adjust: exact: cards, WorkHours bands, and the hour-line
 * gradient on .day-col use background colors. Browsers strip backgrounds in
 * print by default ("background graphics off"). Without this, the grid prints
 * as black ink on white. */

@page {
  size: letter landscape;
  margin: 0.4in;
}

@media print {

  /* ── Page background + colour fidelity ────────────────────────────────── */

  html, body {
    background: #fff !important;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Hide non-grid chrome ─────────────────────────────────────────────── */

  #app-header,
  #booking-panel,
  #loading-overlay,
  .fb-overlay,
  .fb-launcher,
  #screen-login,
  .day-col-hdr-refresh,
  .day-header-refresh,
  .day-nav,
  #date-picker,
  #week-teacher-picker,
  #btn-feedback,
  .btn-logout,
  #readonly-pill,
  #search-input {
    display: none !important;
  }

  /* Keep the date/week labels visible — they're the only header content the
     printed copy needs. */
  #day-header,
  #teacher-week-header {
    display: flex !important;
    align-items: baseline;
    gap: 12px;
    padding: 0 0 6px 0 !important;
    margin: 0 0 8px 0;
    border-bottom: 1px solid #999 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  #day-label,
  #week-label {
    font-size: 14px;
    font-weight: 700;
  }

  #day-summary,
  #week-summary {
    font-size: 11px;
    color: #555;
  }

  /* ── Show only the active view ────────────────────────────────────────── */

  /* JS already toggles `hidden` on the inactive view shell. Reinforce here in
     case a print is triggered mid-transition. */
  body.view-day      #teacher-week-view { display: none !important; }
  body.view-teacher-week #day-view      { display: none !important; }

  /* ── Open the scrollers so the full grid prints ───────────────────────── */

  #app-main,
  #day-grid,
  #teacher-week-grid {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
  }

  #day-view,
  #teacher-week-view {
    height: auto !important;
    display: block !important;
  }

  /* ── Disable sticky on axis/headers/corner ────────────────────────────── */
  /* Sticky doesn't play well with overflow:visible and page breaks. Let the
     axis and column headers flow with the grid; they'll appear once at the
     top, which is what a printout wants anyway. */

  #day-grid-corner,
  #day-grid-headers,
  #day-grid-axis,
  #teacher-week-corner,
  #teacher-week-headers,
  #teacher-week-axis,
  .day-allday-gutter {
    position: static !important;
  }

  /* ── Print-specific grid scale ────────────────────────────────────────── */
  /* Overrides the JS-set inline vars on :root. */

  :root {
    --minute-px: 0.85px !important;
    --col-width: 1.25in !important;
  }

  /* Week view: 5 fixed columns, want them wider than day view. Letter
     landscape minus 0.8in margins minus 0.5in axis ≈ 9.7in usable; 5 × 1.9in
     leaves a comfortable margin. */
  body.view-teacher-week {
    --col-width: 1.9in !important;
  }

  /* ── Card/band color fidelity ─────────────────────────────────────────── */

  .appt-card,
  .day-allday-chip,
  .wh-band,
  .day-col {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Sharper card outlines in print — the screen's box-shadow doesn't survive,
     and a 1px border reads better on paper. */
  .appt-card {
    box-shadow: none !important;
    border-color: #444 !important;
  }

  /* ── Page-break hints ─────────────────────────────────────────────────── */
  /* Avoid splitting a card across pages. With overflow:visible the grid
     will paginate vertically (since the 780 × 0.85px column is ~700px ≈
     7.3in, it fits one page tall, but a horizontally-wide day view will
     paginate horizontally — acceptable). */

  .appt-card,
  .day-allday-chip {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Hide focus/hover outlines that may have been left active. */
  *:focus { outline: none !important; }
}
