/* Screen */
.estate-print-only {
  display: none !important;
}

.estate-print-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 20px;
}

.estate-print-button {
  padding: 11px 20px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #333;
  color: #fff;
  font: inherit;
  line-height: 1.3;
  cursor: pointer;
}

.estate-print-button:hover {
  background: #555;
}

.estate-print-button:focus-visible {
  outline: 3px solid #777;
  outline-offset: 3px;
}

.estate-print-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.estate-print-status {
  font-size: 14px;
}

/* Print */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  /*
   * Keep only the property article and its ancestors.
   * Other page elements must not occupy printed space.
   */
  body:has(.estate-print-header) *:not(
    .node.nehnutelnost,
    .node.nehnutelnost *,
    :has(.node.nehnutelnost)
  ) {
    display: none !important;
  }

  body:has(.estate-print-header),
  body:has(.estate-print-header) *:has(.node.nehnutelnost),
  .node.nehnutelnost,
  .node.nehnutelnost > .content {
    display: block !important;
    position: static !important;
    float: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    background: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
    columns: auto !important;
  }

  body:has(.estate-print-header) {
    color: #222 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 10pt !important;
    line-height: 1.35 !important;
  }

  body:has(.estate-print-header)::before,
  body:has(.estate-print-header)::after,
  body:has(.estate-print-header) *:has(.node.nehnutelnost)::before,
  body:has(.estate-print-header) *:has(.node.nehnutelnost)::after,
  .node.nehnutelnost::before,
  .node.nehnutelnost::after {
    display: none !important;
  }

  .node.nehnutelnost *,
  .node.nehnutelnost *::before,
  .node.nehnutelnost *::after {
    box-sizing: border-box;
    text-shadow: none !important;
    box-shadow: none !important;
  }

  .node.nehnutelnost a {
    color: inherit !important;
    text-decoration: none !important;
  }

  .node.nehnutelnost a::after {
    content: none !important;
  }

  .estate-print-only {
    display: block !important;
  }

  .estate-print-actions,
  .node.nehnutelnost .content-head,
  .nehnutelnost-heading-gallery,
  .nehnutelnost-kontakt-wrapper,
  .node.nehnutelnost .contextual {
    display: none !important;
  }

  .node.nehnutelnost > .content > :not(
    .nehnutelnost-data-wrapper,
    .nehnutelnost-text-wrapper
  ) {
    display: none !important;
  }

  /* Header */
  .estate-print-header {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6mm;
    margin: 0 0 4mm !important;
    padding: 0 0 4mm !important;
    border-bottom: 1px solid #ccc;
    break-inside: avoid;
    font-size: 9pt;
  }

  .estate-print-company {
    display: flex;
    align-items: center;
    gap: 4mm;
    min-width: 0;
  }

  .estate-print-company > img {
    display: block;
    flex: 0 0 22mm;
    width: 22mm !important;
    height: auto !important;
    margin: 0 !important;
  }

  .estate-print-company > div {
    line-height: 1.5;
  }

  .estate-print-broker {
    max-width: 65mm;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .estate-print-broker img,
  .estate-print-broker .field--field-obrazok-makler {
    display: none !important;
  }

  .estate-print-broker,
  .estate-print-broker * {
    position: static !important;
    float: none !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    font-size: 9pt !important;
    line-height: 1.4 !important;
  }

  /* Title */
  .estate-print-title {
    margin: 0 0 4mm !important;
    padding: 0 !important;
    color: #222 !important;
    font-size: 15pt !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    break-after: avoid;
  }

  /* One large photo and four smaller photos */
  .estate-print-gallery {
    display: grid !important;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: repeat(2, 26mm);
    grid-auto-flow: row;
    gap: 3mm;
    margin: 0 0 5mm !important;
    padding: 0 !important;
    break-inside: avoid;
  }

  .estate-print-gallery:empty {
    display: none !important;
  }

  .estate-print-gallery > :first-child {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .estate-print-gallery > * {
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 2mm;
  }

  .estate-print-gallery > * > div,
  .estate-print-gallery picture,
  .estate-print-gallery a {
    display: block;
    width: 100%;
    height: 100%;
  }

  .estate-print-gallery img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: cover;
    object-position: center;
    border: 0 !important;
  }

  /* Property details */
  .node.nehnutelnost h2,
  .nehnutelnost-text-label {
    margin: 4mm 0 3mm !important;
    padding: 0 !important;
    color: #222 !important;
    font-size: 12pt !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    break-after: avoid;
  }

  .nehnutelnost-data-wrapper,
  .nehnutelnost-data-wrapper-inside,
  .nehnutelnost-data-left,
  .nehnutelnost-data-right,
  .nehnutelnost-text-wrapper,
  .nehnutelnost-detail {
    position: static !important;
    float: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
  }

  .nehnutelnost-data-wrapper {
    display: block !important;
    margin-bottom: 4mm !important;
    break-inside: avoid;
  }

  .nehnutelnost-data-wrapper-inside {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6mm;
  }

  .nehnutelnost-data-left,
  .nehnutelnost-data-right {
    display: block !important;
  }

  .nehnutelnost-data-left > *,
  .nehnutelnost-data-right > * {
    margin: 0 0 2mm !important;
    font-size: 10pt !important;
    line-height: 1.3 !important;
    overflow-wrap: anywhere;
  }

  /* Description can continue onto another page */
  .nehnutelnost-text-wrapper,
  .nehnutelnost-detail {
    display: block !important;
    break-inside: auto !important;
  }

  .nehnutelnost-detail,
  .nehnutelnost-detail p,
  .nehnutelnost-detail li {
    color: #222 !important;
    font-size: 10pt !important;
    line-height: 1.35 !important;
  }

  .nehnutelnost-detail p {
    margin: 0 0 3mm !important;
    orphans: 3;
    widows: 3;
  }

  .nehnutelnost-detail ul,
  .nehnutelnost-detail ol {
    margin: 0 0 3mm !important;
    padding-left: 5mm !important;
  }

  .nehnutelnost-detail h2,
  .nehnutelnost-detail h3,
  .nehnutelnost-detail h4 {
    break-after: avoid;
  }

  .nehnutelnost-detail img {
    max-width: 100% !important;
    height: auto !important;
    break-inside: avoid;
  }

  /* Notes */
  .estate-print-notes {
    margin-top: 5mm !important;
    min-height: 30mm;
    break-inside: avoid;
  }
}