/* =============================================================
   Fiche A4 d'un bien — Alliance Immobilière Romande
   Conçue pour tenir sur une page. Les hauteurs sont exprimées en
   millimètres (aucune hauteur en pourcentage) : la mise en page
   reste identique à l'écran, à l'impression et en PDF.
   ============================================================= */
@page { size: A4 portrait; margin: 12mm 12mm 10mm; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: #EDEAE8;
  color: #1C2127;
  font-family: 'Jost', 'Helvetica Neue', Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
img { display: block; max-width: 100%; height: auto; }   /* height:auto neutralise l'attribut HTML height */
h1, h2 { margin: 0; font-weight: 500; }
p { margin: 0; }

/* Barre d'action (jamais imprimée) */
.print-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; padding: 12px; background: #1C2127; }
.print-bar button, .print-bar a { padding: 10px 18px; border: 0; border-radius: 6px; background: #C70000; color: #fff; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.print-bar a { border: 1px solid rgba(255, 255, 255, .4); background: transparent; }
.print-bar .hint { width: 100%; color: rgba(255, 255, 255, .65); font-size: 12.5px; text-align: center; }

/* Feuille */
.sheet { --photo-h: 74mm; --txt: 1; width: 210mm; min-height: 297mm; margin: 20px auto; padding: 12mm; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .12); }

/* En-tête */
.sh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10mm; padding-bottom: 3.5mm; border-bottom: 0.7mm solid #C70000; }
.sh-logo { width: 46mm; height: auto; }
.sh-agency { color: #555; font-size: 8.2pt; line-height: 1.45; text-align: right; }

/* Titre et prix */
.sh-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8mm; margin: calc(5mm * var(--txt)) 0 calc(4.5mm * var(--txt)); }
.sh-title-main { min-width: 0; }
.sh-tag { margin-bottom: 1mm; color: #C70000; font-size: 8.2pt; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sh-title h1 { font-size: 16pt; line-height: 1.18; }
.sh-place { margin-top: 1mm; color: #555; font-size: 10.5pt; }
.sh-price { flex: none; max-width: 62mm; text-align: right; }
.sh-price span { display: block; color: #777; font-size: 7.8pt; letter-spacing: .06em; text-transform: uppercase; }
.sh-price strong { display: block; color: #C70000; font-size: 15pt; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.sh-price em { display: block; color: #444; font-size: 8.8pt; font-style: normal; }

/* Photos — hauteurs fixes, aucun débordement possible */
.sh-photos { display: flex; gap: 2.5mm; margin-bottom: calc(5.5mm * var(--txt)); break-inside: avoid; page-break-inside: avoid; }
.sh-photos img { width: 100%; border-radius: 1.5mm; object-fit: cover; background: #F1ECEA; }
.sh-main { flex: 1 1 auto; min-width: 0; }
.sh-side { display: flex; flex: 0 0 58mm; flex-direction: column; gap: 2.5mm; }
/* --photo-h est ajusté par le script de la page pour remplir exactement une page A4 */
.sh-photos--1 img { height: var(--photo-h, 74mm); }
.sh-photos.is-empty img { height: min(var(--photo-h, 74mm), 62mm); }   /* photo à venir : jamais plein cadre */
.sh-photos--2 .sh-main img, .sh-photos--2 .sh-side img { height: var(--photo-h, 74mm); }
.sh-photos--3 .sh-main img { height: var(--photo-h, 74mm); }
.sh-photos--3 .sh-side img { height: calc((var(--photo-h, 74mm) - 2.5mm) / 2); }

/* Deux colonnes */
.sh-cols { display: flex; gap: 8mm; align-items: flex-start; }
.sh-col-left { flex: 0 0 72mm; }
.sh-col-right { flex: 1 1 auto; min-width: 0; }
.sh-block { margin-bottom: calc(5mm * var(--txt)); break-inside: avoid; page-break-inside: avoid; }
.sh-block:last-child { margin-bottom: 0; }
.sh-block h2 { margin-bottom: 2mm; padding-bottom: 1.2mm; border-bottom: 0.25mm solid #E2D9D5; color: #1C2127; font-size: 9.5pt; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.sh-table { width: 100%; border-collapse: collapse; font-size: calc(9pt * var(--txt)); }
.sh-table tr { break-inside: avoid; page-break-inside: avoid; }
.sh-table th, .sh-table td { padding: calc(1.15mm * var(--txt)) 0; border-bottom: 0.2mm solid #F2ECE9; text-align: left; vertical-align: top; }
.sh-table th { width: 36mm; padding-right: 2mm; color: #666; font-weight: 400; }
.sh-table td { font-weight: 500; }

.sh-features { margin: 0; padding: 0; list-style: none; font-size: calc(9pt * var(--txt)); }
.sh-features li { position: relative; padding: calc(0.6mm * var(--txt)) 0 calc(0.6mm * var(--txt)) 4mm; line-height: 1.45; }
.sh-features li::before { position: absolute; top: 0.6mm; left: 0; color: #C70000; content: "•"; }

.sh-desc { font-size: calc(9.5pt * var(--txt)); line-height: 1.52; text-align: left; }
.sh-desc p { margin: 0 0 calc(2.5mm * var(--txt)); orphans: 2; widows: 2; }
.sh-desc p:last-child { margin-bottom: 0; }

.sh-contact { padding: 3mm 3.5mm; border-radius: 1.5mm; background: #F8F0ED; font-size: 8.8pt; line-height: 1.5; }
.sh-contact strong { display: block; margin-bottom: 0.8mm; font-size: 9.2pt; font-weight: 600; }

/* Pied de page */
.sh-foot { margin-top: calc(6mm * var(--txt)); padding-top: 2.5mm; border-top: 0.25mm solid #E2D9D5; color: #777; font-size: 7.6pt; line-height: 1.45; break-inside: avoid; page-break-inside: avoid; }
.sh-foot .sh-url { color: #555; word-break: break-all; }
.sh-foot p { margin-top: 0.8mm; }

/* Le script ajoute « is-fitted » quand il a vérifié que tout tient sur une page :
   le pied de page est alors plaqué en bas de la feuille. */
.sheet.is-fitted { display: flex; flex-direction: column; }
.sheet.is-fitted .sh-foot { margin-top: auto; padding-top: 3mm; }

@media print {
  body { background: #fff; }
  .sheet.is-fitted { min-height: 273mm; }
  .no-print { display: none !important; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
}

@media screen and (max-width: 800px) {
  .sheet { width: auto; max-width: 100%; min-height: 0; margin: 12px; padding: 16px; }
  .sh-head, .sh-title, .sh-cols, .sh-photos { flex-direction: column; gap: 4mm; }
  .sh-agency, .sh-price { text-align: left; max-width: none; }
  .sh-side { flex: none; width: 100%; flex-direction: row; }
  .sh-side img { flex: 1 1 0; min-width: 0; }
  .sh-col-left, .sh-col-right { flex: none; width: 100%; }
  .sh-photos img, .sh-photos--3 .sh-side img, .sh-photos.is-empty img { height: auto; aspect-ratio: 3 / 2; }
  .sheet.is-fitted { display: block; }
}
