/* ===== PRINT STYLES — Sotah & Kiddush ===== */

/* ---------- PRINT BUTTON (screen only) ---------- */
.print-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  background: #1a5a8a;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .2s;
}
.print-btn:hover { background: #145a80; transform: scale(1.05); }

/* ---------- PRINT HEADER & FOOTER (hidden on screen) ---------- */
.print-header,
.print-footer {
  display: none;
}

/* ======================================================
   @media print — COMMON
   ====================================================== */
@media print {
  @page {
    size: A4;
    margin: 6mm 8mm 10mm;
  }

  /* hide UI chrome */
  .print-btn,
  .topbar-wrap,
  .float-progress,
  .mode-tabs,
  .ch-scroll,
  .scene-ctrl,
  .font-ctrl,
  .footer { display: none !important; }

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

  a { color: #000 !important; text-decoration: none !important; }

  /* --- PRINT HEADER — top of first page --- */
  .print-header {
    display: flex !important;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid #999;
    padding: 0 0 3px;
    margin-bottom: 6px;
    font-family: 'Heebo', sans-serif;
  }
  .print-header .ph-bh {
    font-size: 8px;
    color: #999;
    position: absolute;
    top: 0;
    right: 0;
  }
  .print-header .ph-title {
    font-size: 11px;
    font-weight: 700;
    color: #333;
  }
  .print-header .ph-site {
    font-size: 9px;
    color: #888;
    direction: ltr;
  }

  /* --- PRINT FOOTER — bottom of every page --- */
  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid #bbb;
    padding: 4px 4px 2px;
    font-family: 'Heebo', sans-serif;
    font-size: 9px;
    color: #888;
    display: flex !important;
    justify-content: space-between;
    align-items: baseline;
    background: #fff;
  }
  .print-footer .pf-info {
    direction: rtl;
  }
  .print-footer .pf-page {
    font-size: 9px;
    color: #999;
  }
  .print-footer .pf-page::after {
    counter-increment: page;
    content: counter(page);
  }
  .print-footer .pf-site {
    direction: ltr;
    font-size: 9px;
  }

  /* Reserve space at bottom so content doesn't overlap footer */
  body {
    margin-bottom: 30px !important;
  }

  /* ======================================================
     SOTAH DAF — content flows across pages
     ====================================================== */

  /* hide site-only chrome by inline style matching */
  ._tb,                                                        /* topbar injected by topbar.js */
  div[style*="background:#fff;border-bottom:1px solid #e0e0e0;padding:16px"], /* page header with h1, ב״ה, filters */
  div[style*="display:flex;justify-content:center;gap:8px;padding:8px"],      /* nav bar rows */
  div[style*="padding:20px 16px 30px"],                        /* footer disclaimer */
  [id^="fbtn-"], #tbtn,                                        /* filter & toggle buttons */
  [id^="arrow"]                                                 /* collapse arrows */
  { display: none !important; }

  /* hide section count number in header buttons */
  [id^="sec"] > button span[style*="color:#bbb"] {
    display: none !important;
  }

  /* force all sections visible */
  [id^="content"] {
    display: block !important;
    padding: 1px 2px 2px !important;
    border: none !important;
    background: transparent !important;
  }

  /* section wrapper — ALLOW page breaks inside */
  [id^="sec"] {
    display: block !important;
    margin-bottom: 0 !important;
  }

  /* section header buttons — make them look like plain headers */
  [id^="sec"] > button {
    padding: 1px 2px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: default !important;
    border-bottom: 1px solid #ccc !important;
    border-radius: 0 !important;
    break-after: avoid !important;
  }
  [id^="sec"] > button span {
    font-size: 9px !important;
  }
  [id^="sec"] > button div {
    gap: 3px !important;
  }

  /* main content container — FULL WIDTH */
  div[style*="max-width:640px"] {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* "מה בדף הזה" summary box — keep visible, compact */
  div[style*="max-width:640px"] > div:first-child {
    padding: 4px 4px !important;
    margin-bottom: 3px !important;
    border: none !important;
    box-shadow: none !important;
    background: #f5f5f5 !important;
    border-radius: 4px !important;
  }
  div[style*="max-width:640px"] > div:first-child div:first-child {
    font-size: 9px !important;
    margin-bottom: 1px !important;
  }
  div[style*="max-width:640px"] > div:first-child div:last-child {
    font-size: 8.5px !important;
    line-height: 1.4 !important;
  }

  /* source text blocks (green/blue boxes) */
  [id^="content"] div[style*="border-right:4px"] {
    padding: 2px 4px !important;
    border-radius: 2px !important;
    border-right-width: 2px !important;
    margin: 0 !important;
  }
  [id^="content"] div[style*="border-right:4px"] div {
    font-size: 10.5px !important;
    line-height: 1.55 !important;
  }

  /* commentary/biur text */
  [id^="content"] div[style*="padding:9px"] {
    padding: 0 4px !important;
    font-size: 9px !important;
    line-height: 1.4 !important;
  }

  /* spacing between quote blocks — minimal */
  [id^="content"] > div > div[style*="margin-top:14px"] {
    margin-top: 1px !important;
  }
  [id^="content"] > div > div:first-child {
    margin-top: 0 !important;
  }

  /* keep print elements visible */
  .print-header,
  .print-footer {
    display: flex !important;
  }

  /* ======================================================
     KIDDUSH / RAMBAM — fit each chapter in TWO pages
     ====================================================== */

  /* topbar & navigation */
  .topbar,
  .mode-tabs,
  .ch-scroll,
  .float-progress,
  .sc-btn,
  .scene-ctrl,
  .lang-btn,
  .font-ctrl,
  .nb { display: none !important; }

  .main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* force all cards open */
  .hal-body {
    display: block !important;
    padding: 0 8px 6px !important;
  }
  .hal-arrow { display: none !important; }
  .hal-card {
    border: none !important;
    box-shadow: none !important;
    margin: 2px 0 !important;
  }
  .hal-header {
    padding: 3px 4px !important;
    cursor: default !important;
    border-bottom: 1px solid #ccc;
  }
  .hal-num {
    width: 20px !important;
    height: 20px !important;
    font-size: .65rem !important;
  }
  .hal-preview {
    font-size: .75rem !important;
    white-space: normal !important;
  }

  /* text blocks — compact */
  .txt-rambam {
    font-size: 10px !important;
    line-height: 1.6 !important;
    padding: 4px 6px !important;
    margin-bottom: 3px !important;
    border-right-width: 2px !important;
  }
  .txt-english {
    font-size: 8.5px !important;
    line-height: 1.5 !important;
    padding: 3px 6px !important;
    margin-bottom: 3px !important;
  }
  .txt-steinsaltz { margin-bottom: 3px !important; }
  .st-item {
    font-size: 9px !important;
    line-height: 1.45 !important;
    padding: 2px 0 !important;
  }
  .st-label { font-size: .6rem !important; margin-bottom: 2px !important; }
  .explain { font-size: 9px !important; line-height: 1.45 !important; }

  /* chapter dividers */
  .ch-divider {
    padding: 8px 0 4px !important;
    margin-top: 4px !important;
    page-break-before: always;
  }
  .ch-divider:first-child { page-break-before: avoid; }
  .ch-divider h2 { font-size: 14px !important; }
  .ch-divider .ch-count { font-size: 9px !important; }

  /* overview layers */
  .layer-body { display: block !important; }
  .layer-section { margin: 4px 0 !important; }
  .layer-header {
    padding: 4px 6px !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  .layer-num {
    width: 24px !important;
    height: 24px !important;
    font-size: .75rem !important;
  }
  .layer-title h3 { font-size: .85rem !important; }
  .layer-title p { font-size: .65rem !important; }

  /* step nav */
  .step-nav { display: none !important; }

  /* 3D scene */
  #scene3d { display: none !important; }

  /* tables & grids — compact */
  .data-grid { font-size: .65rem !important; gap: 1px !important; }
  .vis-tbl { font-size: .65rem !important; }
  .vis-tbl th, .vis-tbl td { padding: 2px 3px !important; }

  /* calc tools */
  .calc-tool { padding: 4px 6px !important; margin: 3px 0 !important; }

  /* viz containers */
  .viz-container { margin: 4px 0 !important; }

  .footer { display: none !important; }
}
