/* ===================================================================
   Pobieranie dokumentu prawnego jako PDF
   -------------------------------------------------------------------
   Serwis ma CSP ze "script-src 'self'", wiec biblioteka PDF z CDN
   zostalaby zablokowana. Generatory dzialajace przez canvas (html2pdf,
   html2canvas) rasteryzuja tekst - powstaje plik nieprzeszukiwalny,
   bez zaznaczalnej tresci, ciezki i slabo lamiacy strony. Do zalacznika
   do umowy to zly material.

   Dlatego dokument drukuje przegladarka: opcja "Zapisz jako PDF" daje
   prawdziwy PDF z tekstem, spisem tresci w zakladkach i poprawna
   paginacja, a ponizszy arkusz decyduje, jak ma wygladac.
   =================================================================== */

/* --- Przycisk pobrania --- */
.pdf-bar { display: flex; justify-content: flex-end; margin: 0 0 22px; }
.pdf-bar--bottom { margin: 32px 0 8px; }

.btn-pdf {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: #C8102E; color: #fff;
  font-family: inherit; font-size: .9rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.18);
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn-pdf:hover { background: #A50D25; box-shadow: 0 6px 18px -6px rgba(200,16,46,.6); transform: translateY(-1px); }
.btn-pdf:active { transform: none; }
.btn-pdf:focus-visible { outline: 3px solid #C8102E; outline-offset: 3px; }
.btn-pdf svg { width: 20px; height: 20px; flex: none; }
.btn-pdf small { display: block; font-weight: 400; font-size: .72rem; opacity: .85; margin-top: 1px; }
.btn-pdf-text { display: flex; flex-direction: column; align-items: flex-start; }

@media (prefers-reduced-motion: reduce) {
  .btn-pdf { transition: none; }
  .btn-pdf:hover { transform: none; }
}
@media (max-width: 520px) {
  .pdf-bar { justify-content: stretch; }
  .btn-pdf { width: 100%; justify-content: center; }
  .btn-pdf-text { align-items: center; }
}

/* Sygnatura pobrania - na ekranie niewidoczna, pojawia sie tylko na wydruku. */
.pdf-sygnatura { display: none; }

/* --- Wydruk / zapis do PDF --- */
@media print {
  @page { margin: 18mm 16mm 20mm; }

  /* Elementy nawigacyjne i ozdobne nie naleza do dokumentu prawnego. */
  header, footer, nav, aside, .site-header, .site-footer, .main-nav,
  .pdf-bar, .toc, .art-toc, .doc-toc, .toc-card, .toc-mobile, .to-top,
  .hero-grid-bg, .art-hero-inner .hero-quick, .breadcrumb, .art-crumbs,
  .read-bar, .nav-toggle, .cookie-bar, .reveal-init,
  .pp-header, .pp-footer, .pp-header-nav, .doc-nav, .site-nav
  { display: none !important; }

  html, body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  body { margin: 0; }
  .layout, .art-shell, .art-layout, .container, main, article,
  .legaldoc, .doc-layout, .content, .wrap, .pp-body, .doc { display: block !important; width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; }

  /* Sygnatura na pierwszej stronie - kto, skad i kiedy pobral dokument. */
  .pdf-sygnatura {
    display: block !important;
    border: 1px solid #999; border-radius: 3px;
    padding: 8px 10px; margin: 0 0 16px;
    font-size: 8.5pt; line-height: 1.45; color: #333;
  }
  .pdf-sygnatura strong { color: #000; }
  .pdf-sygnatura .pdf-syg-url { word-break: break-all; }

  h1 { font-size: 17pt; margin: 0 0 10px; }
  h2 { font-size: 12.5pt; margin: 16px 0 6px; break-after: avoid; page-break-after: avoid; }
  h3 { font-size: 11pt; break-after: avoid; page-break-after: avoid; }
  p, li { orphans: 3; widows: 3; }

  /* Punkt regulaminu nie powinien pekac miedzy stronami. */
  li, .legal-company-box, table, figure, .def-box, .lex-it {
    break-inside: avoid; page-break-inside: avoid;
  }

  a { color: #000 !important; text-decoration: underline; }
  /* Adresy przy odnosnikach - na papierze sam tekst odnosnika nic nie mowi.
     Pomijamy kotwice wewnetrzne, bo w PDF i tak prowadza donikad. */
  .legal-doc a[href^="http"]::after,
  .art-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }

  img { max-width: 100% !important; }
  figure, .art-figure { margin: 10px 0; }
  figcaption { font-size: 8.5pt; color: #444; }
}
