/**
 * Doory print styles — fiche d'un bien (et d'un programme).
 *
 * Chargée avec media="print" (aucun coût à l'écran) après front.css :
 * à spécificité égale, elle gagne. Objectif : une fiche A4 lisible, sans
 * interface (menu, boutons, formulaire, carrousels, vidéos), avec la photo
 * de couverture, les chiffres clés, le descriptif, les équipements et le
 * contact ; les autres photos sont en dernière page.
 *
 * Organisation :
 *   1. Page et base
 *   2. Éléments d'interface masqués
 *   3. Galerie (couverture ; autres photos en dernière page)
 *   4. Mise en page (colonnes, coupures de page)
 *   5. Contact, carte, médias, énergie
 */

/* stylelint-disable no-descending-specificity -- groupées par composant */

@page {
	size: a4 portrait;
	margin: 12mm 12mm 22mm;
}

@media print {

	/* ======================================================================
	   1. Page et base
	   ====================================================================== */

	/* Tailles réduites : tout ce qui est en rem (thème compris) suit
	   cette base. */
	html {
		font-size: 8pt;
	}

	body {
		background: #fff !important;
		color: #000 !important;
		font-size: 8pt;
		line-height: 1.3;
	}

	/* Apparitions au défilement : rien ne doit rester invisible sur le papier. */
	[data-gb-reveal],
	[data-gb-reveal-skip] {
		opacity: 1 !important;
		transform: none !important;
		transition: none !important;
		animation: none !important;
	}

	.dry-single {
		display: flex;
		flex-direction: column;
		max-width: none !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	.dry-single h1 {
		font-size: 13pt;
		line-height: 1.15;
	}

	.dry-single h2 {
		font-size: 9pt;
		margin-block: 3mm 1mm;
	}

	.dry-single h2,
	.dry-single h3 {
		break-after: avoid;
	}

	/* Les pastilles colorées (énergie, badges) gardent leur fond : c'est
	   l'information. */
	.dry-energy,
	.dry-badge,
	.dry-badges * {
		print-color-adjust: exact;
		-webkit-print-color-adjust: exact;
	}

	/* ======================================================================
	   2. Éléments d'interface masqués
	   ====================================================================== */
	body.single-dry_property .wp-site-blocks > header,
	body.single-dry_property .wp-site-blocks > footer,
	body.single-dry_program .wp-site-blocks > header,
	body.single-dry_program .wp-site-blocks > footer,
	#wpadminbar,
	.wp-block-doory-breadcrumb,
	.wp-block-doory-similar-properties,
	.wp-block-doory-property-program-lots,
	.wp-block-doory-property-transit,
	.wp-block-doory-property-media,
	.wp-block-doory-property-summary,
	.wp-block-doory-property-rooms,
	.dry-map,
	.dry-map-embed,
	.dry-map-placeholder,
	.wp-block-doory-property-neighbourhood,
	.wp-block-doory-property-program,
	.dry-neighbourhood__aside,
	.dry-neighbourhood .dry-tags,
	.dry-neighbourhood__label,
	.wp-block-doory-favorites,
	.dry-fav,
	.dry-compare-bar,
	.dry-lead,
	.dry-contact-link,
	.dry-gallery__actions,
	.dry-gallery__more,
	.dry-gallery__link,
	.dry-map__load,
	.dry-map__note,
	.dry-media__frame,
	.dry-sr-only,
	.dry-collection__nav,
	.dry-description__more,
	.dry-features__chevron,
	iframe,
	video {
		display: none !important;
	}

	/* ======================================================================
	   3. Galerie : couverture + 3 vignettes
	   ====================================================================== */
	.dry-gallery .dry-gallery__grid {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		grid-template-rows: auto;
		gap: 2mm;
		aspect-ratio: auto;
	}

	.dry-gallery--count-1 .dry-gallery__grid {
		grid-template-columns: 1fr;
	}

	.dry-gallery--count-2 .dry-gallery__grid,
	.dry-gallery--count-3 .dry-gallery__grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.dry-gallery .dry-gallery__item {
		display: block;
		aspect-ratio: 3 / 2;
		break-inside: avoid;
	}

	.dry-gallery .dry-gallery__item--main {
		grid-column: 1 / -1;
		grid-row: auto;
		aspect-ratio: 16 / 8;
	}

	/* Page 1 : la couverture seule ; les autres photos sont sur la dernière page
	   (.dry-print-photos). */
	.dry-gallery .dry-gallery__item:nth-child(n+2) {
		display: none;
	}

	.dry-gallery__img {
		transform: none !important;
	}

	/* ======================================================================
	   4. Mise en page
	   ====================================================================== */

	/* Colonnes empilées : le texte prend toute la largeur, le contact suit. */
	.dry-single .wp-block-columns {
		display: block;
	}

	.dry-single .wp-block-column {
		flex-basis: auto !important;
		width: auto !important;
		min-width: 0;
	}

	.dry-header {
		margin-bottom: 0;
		padding-block: 2mm;
		border-bottom: 0.5pt solid #000;
		break-after: avoid;
	}

	.dry-header,
	.wp-block-doory-property-key-facts,
	.wp-block-doory-property-energy,
	.wp-block-doory-property-lease,
	.dry-fact,
	.dry-facts--table tr,
	.dry-map__static,
	.wp-block-doory-property-contact {
		break-inside: avoid;
	}

	.wp-block-doory-property-description p,
	.wp-block-doory-property-description li {
		orphans: 3;
		widows: 3;
	}


	/* Les autres photos passent en fin de fiche : la galerie « disparaît »
	   (display: contents) et ses enfants deviennent des éléments de la
	   colonne principale, que `order` replace. */
	.dry-single > * {
		max-width: none !important;
		margin-inline: 0 !important;
	}

	.dry-gallery {
		display: contents;
	}

	.dry-print-logo {
		order: -1;
		display: block;
		align-self: flex-end;
		width: auto;
		max-width: 50mm;
		max-height: 14mm;
		margin: 0 0 3mm;
	}

	.dry-print-photos {
		order: 10;
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 3mm;
		margin: 0;
		padding: 0;
		list-style: none;
		break-before: page;
	}

	.dry-print-photos li {
		margin: 0;
		break-inside: avoid;
	}

	.dry-print-photos img {
		display: block;
		width: 100%;
		height: auto;
		aspect-ratio: 3 / 2;
		object-fit: cover;
	}

	/* Sections : libellé à gauche, contenu à droite (description, équipements,
	   énergie…). */
	.wp-block-doory-property-description,
	.wp-block-doory-property-summary,
	.wp-block-doory-property-highlights,
	.wp-block-doory-property-lease,
	.wp-block-doory-property-features,
	.wp-block-doory-property-energy,
	.wp-block-doory-property-neighbourhood,
	.wp-block-doory-property-rooms {
		display: grid;
		grid-template-columns: 32mm 1fr;
		column-gap: 4mm;
		margin-top: 2.5mm;
		padding-top: 1.5mm;
		border-top: 0.5pt solid #000;
	}

	.wp-block-doory-property-description > *,
	.wp-block-doory-property-summary > *,
	.wp-block-doory-property-highlights > *,
	.wp-block-doory-property-lease > *,
	.wp-block-doory-property-features > *,
	.wp-block-doory-property-energy > *,
	.wp-block-doory-property-neighbourhood > *,
	.wp-block-doory-property-rooms > * {
		grid-column: 2;
	}

	.wp-block-doory-property-description > h2,
	.wp-block-doory-property-summary > h2,
	.wp-block-doory-property-highlights > h2,
	.wp-block-doory-property-lease > h2,
	.wp-block-doory-property-features > h2,
	.wp-block-doory-property-energy > h2,
	.wp-block-doory-property-neighbourhood > h2,
	.wp-block-doory-property-rooms > h2 {
		display: block;
		grid-column: 1;
		grid-row: 1;
		margin: 0;
		font-size: 10pt;
	}

	.dry-features__title {
		margin: 0 0 0.5mm;
		font-size: 8pt;
		font-weight: 700;
	}

	/* Équipements : les groupes se répartissent sur 3 colonnes, listes simples
	   sans pastilles. */
	.wp-block-doory-property-features {
		grid-template-columns: 32mm repeat(3, 1fr);
	}

	.wp-block-doory-property-features > h2 {
		grid-row: 1 / span 12;
	}

	.wp-block-doory-property-features > .dry-features__group {
		grid-column: auto;
		border: 0;
		break-inside: avoid;
	}

	.dry-features__panel .dry-tags {
		display: block;
		margin: 0;
		padding: 0;
		font-size: 7.5pt;
		line-height: 1.25;
	}

	.dry-features__panel .dry-tag {
		display: block;
		padding: 0;
		border: 0;
		background: none;
		break-inside: avoid;
	}

	/* Texte du descriptif : plus petit que le reste du thème, paragraphes
	   serrés. */
	.dry-description__text,
	.dry-description__text p,
	.dry-description__text li {
		font-size: 8pt;
		line-height: 1.35;
	}

	.dry-description__text p {
		margin: 0 0 1.5mm;
	}

	/* Tags (atouts, pastilles) : petits. */
	.dry-tag,
	.dry-chip,
	.dry-highlights li {
		font-size: 7pt;
		line-height: 1.2;
		padding: 0.6mm 2mm;
		--dry-icon-size: 1em;
	}

	/* Chiffres clés : une rangée de tuiles compactes (4 par ligne). */
	.dry-key-facts .dry-facts--inline {
		grid-template-columns: repeat(4, 1fr);
		gap: 2mm;
	}

	.dry-key-facts {
		padding-block: 2mm;
		margin: 0;
	}

	.dry-key-facts .dry-fact {
		padding: 1.5mm 2.5mm;
	}

	.wp-block-doory-property-energy p {
		font-size: 8pt;
	}

	/* Contenus repliés à l'écran (« Lire la suite », accordéons d'équipements) :
	   tout est déplié sur le papier. */
	.dry-description__text.is-clamped {
		display: block;
		overflow: visible;
		-webkit-line-clamp: unset;
		line-clamp: unset;
	}

	.dry-features__panel[hidden] {
		display: block !important;
	}

	.dry-features__toggle {
		padding-block: 1mm;
		font-weight: 600;
	}

	/* ======================================================================
	   5. Contact, carte, médias, énergie
	   ====================================================================== */

	/* Contact : la carte de l'agent seule (nom, téléphone, e-mail) ; le
	   formulaire est masqué. */
	.wp-block-doory-property-contact {
		margin-top: 5mm;
		padding: 3mm 4mm;
		border: 0.5pt solid #000;
	}

	.dry-agent-chip__photo {
		max-height: 28mm;
		width: auto;
	}

	.dry-agent-chip a {
		color: inherit;
		text-decoration: none;
	}

	/* Carte : image statique (crédit OpenStreetMap conservé), hauteur bornée. */
	.dry-map__image {
		max-height: 70mm;
	}

	.dry-map__open {
		display: none;
	}

	/* Visite virtuelle / vidéo : le cadre est masqué, on imprime l'adresse du
	   lien. */
	.dry-media__open a[href^="http"]::after,
	.dry-media__links a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-size: 8pt;
		word-break: break-all;
	}

	/* Énergie : l'étiquette ne doit jamais être coupée entre deux pages. */
	.wp-block-doory-property-energy {
		margin-top: 4mm;
	}
}
