/* ==========================================================================
   list-part.css — site 22
   Listes de produits / articles (list.part.*.tpl) — mise en page flex
   ========================================================================== */

:root {
	--lp-card-width: 238px;
	--lp-card-min-height: 250px;
	--lp-gap: 20px;
	--lp-image-height: 180px;
	--lp-hover-bg: #eee;
	--lp-border: #ddd;
	--lp-muted: #999;
	--lp-text-soft: #666;
}

/* --------------------------------------------------------------------------
   Sélecteur de mode d'affichage
   -------------------------------------------------------------------------- */

.viewmode {
	display: inline-flex;
	width: 16px;
	height: 16px;
	margin-right: 5px;
	background-repeat: no-repeat;
	background-position: center;
	box-sizing: content-box;
	border: 2px solid transparent;
	vertical-align: middle;
}

.viewmode.active {
	border-color: var(--lp-border);
}

.viewmode.icone {
	background-image: url('images/view-icone.png');
}

.viewmode.result {
	background-image: url('images/view-result.png');
}

.viewmode.list {
	background-image: url('images/view-list.png');
}

/* --------------------------------------------------------------------------
   Conteneur de résultats
   -------------------------------------------------------------------------- */

.results {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: stretch;
	gap: var(--lp-gap);
	margin: 10px 0;
}

/* Le tableau ouvert en mode "result" ne doit pas casser la grille */
.results > table {
	display: contents;
}

/* Le bouton « ajouter la sélection » occupe toute la ligne */
.results > div:not(.result-icones):not(.result-list) {
	flex: 1 0 100%;
}

/* --------------------------------------------------------------------------
   Vignette (modes icone / result / list)
   -------------------------------------------------------------------------- */

.result-icones {
	display: flex;
	flex-direction: column;
	flex: 0 0 var(--lp-card-width);
	width: var(--lp-card-width);
	min-height: var(--lp-card-min-height);
	box-sizing: border-box;
	position: relative;
}

/* Titre : hauteur fixe de 3 lignes pour que toutes les images
   démarrent à la même hauteur, quel que soit la longueur du titre */
.result-icones h2 {
	--lp-title-lines: 3;
	text-align: center;
	margin: 5px 0;
	width: 100%;
	line-height: 1.2em;
	height: calc(var(--lp-title-lines) * 1.2em);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--lp-title-lines);
	line-clamp: var(--lp-title-lines);
	overflow: hidden;
}

.result-icones .icone {
	text-align: center;
	padding: 5px 0;
	min-height: 130px;
	transition: background-color 0.2s ease;
}

.result-icones .icone > a {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 5px;
	text-decoration: none;
}

/* Image : boîte de hauteur fixe, l'image s'y inscrit sans déformation.
   !important nécessaire pour écraser le style inline width: (180*ratio)px */
.result-icones .icone img {
	display: block;
	width: auto !important;
	max-width: 100%;
	height: var(--lp-image-height);
	object-fit: contain;
	margin: 0 auto;
}

.result-icones .icone:hover {
	background-color: var(--lp-hover-bg);
}

.result-icones .title {
	font-size: 0.8rem;
	color: var(--lp-muted);
	flex-grow: 1;
}

/* Prix + bouton d'ajout, poussés en bas de la carte */
.result-icones .price {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 5px;
	margin: auto 0 0;
	font-size: 0.8rem;
	text-align: left;
}

.result-icones .add_button {
	display: none;
	margin-left: auto;
}

.result-icones .article-slide-link {
	margin-top: 5px;
}

#carousel {
	clear: both;
	flex: 1 0 100%;
}

/* --------------------------------------------------------------------------
   Ligne de liste
   -------------------------------------------------------------------------- */

.result-list {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	flex: 1 0 100%;
	padding: 8px 0 5px;
	margin-bottom: 5px;
	line-height: 1rem;
	transition: background-color 0.2s ease;
}

.result-list:hover {
	background-color: var(--lp-hover-bg);
}

.result-list > .title {
	flex: 1 1 80%;
	min-width: 0;
}

.result-list > .title > .reference {
	color: var(--lp-text-soft);
	font-weight: bold;
}

.result-list .price {
	flex: 0 0 auto;
	margin-left: auto;
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */

@media (max-width: 540px) {
	.results {
		gap: 10px;
	}

	.result-icones {
		flex: 1 1 calc(50% - 10px);
		width: auto;
		min-width: 140px;
	}
}
