/**
 * components/cards.css — Cartes de réalisations (archive et taxonomie).
 *
 * @package Sabandco2026
 */

@layer components {

	/* -------------------------------------------------------------------------
	 * Ligne réalisation (.rea-row)
	 * Chaque réalisation occupe une ligne pleine largeur :
	 *   col-md-6 image | col-md-6 texte (ou inversé avec .flex-md-row-reverse)
	 * ---------------------------------------------------------------------- */

	.rea-row {
		border: var(--border-width) solid var(--border-color);
		overflow: hidden;
	}

	/* Colonne image — hauteur fixe via aspect-ratio */
	.rea-row__image {
		aspect-ratio: 4 / 3;
		overflow: hidden;
	}

	.rea-row__img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		object-position: center;
		display: block;
		transition: transform var(--transition-slow);
	}

	.rea-row:hover .rea-row__img,
	.rea-row:focus-within .rea-row__img {
		transform: scale(1.03);
	}

	@media (prefers-reduced-motion: reduce) {
		.rea-row__img {
			transition: none;
		}
	}

	/* Colonne texte */
	.rea-row__body {
		min-height: 200px;
	}

	/* Liens de tags — z-index au-dessus du stretched-link */
	.rea-row__tags .tag-link {
		position: relative;
		z-index: 2;
		display: inline-block;
		margin-inline-end: var(--space-xs);
		margin-block-end: var(--space-xs);
		font-size: var(--font-size-sm);
		color: var(--color-text-muted);
		text-decoration: none;
	}

	.rea-row__tags .tag-link:hover {
		color: var(--color-primary);
	}

	/* -------------------------------------------------------------------------
	 * Carte accueil — section « Exemples de réalisations » (front-page.php)
	 *
	 * Règles extraites de sabandco2023/assets/dist/main.css :
	 *   .home .card-body .card-img-top { height: 320px }
	 *   .home .card-body .card-img-top img { height:100%; width:auto; transition:all .4s ease-in-out }
	 *   .home .card-body .btn-wrapper { background:rgba(0,0,0,.5); opacity:0 }
	 *   .home .card-body .btn-wrapper,
	 *   .home .card-body:hover .btn-wrapper { display:block; position:absolute;
	 *       transition:visibility 0ms .3s, opacity .3s linear; width:calc(100% - 30px) }
	 *   .home .card-body:hover .btn-wrapper { opacity:1 }
	 *   .home .card-body:hover img { transform:scale(1.5); transition:all .4s ease-in-out }
	 *
	 * Adaptations 2026 :
	 *   — figure height:500px déplacée depuis l'attribut style HTML
	 *   — object-fit:cover (au lieu de width:auto/height:100%)
	 *   — background:rgba(0,0,0,0.6) (légèrement plus opaque, contraste garanti)
	 *   — transition visibility supprimée (vestige, visibility non utilisé)
	 *   — :focus-within ajouté (clavier)
	 *   — prefers-reduced-motion
	 *
	 * Stretched-link — carte entière cliquable :
	 *   Bootstrap vendor : .card { position:relative } → contient .stretched-link::after.
	 *   .btn-wrapper : position:absolute relative à .card (même containing block).
	 *   La figure overflow:hidden délimite visuellement la bande.
	 *   Aucun autre ancêtre positionné entre le lien et .card.
	 *
	 * Contraste bouton (btn-outline-light, couleurs explicites) :
	 *   repos  : #fff sur rgba(0,0,0,0.6) sur photo blanche → fond effectif #666 → 5,74:1 ✓
	 *   survol/focus : #111 sur #fff → 18,9:1 ✓
	 *
	 * Écran tactile (hover:none) : 2023 ne gérait pas le touch — le btn-wrapper
	 *   restait invisible (opacity:0, pas de survol). Comportement identique reproduit.
	 *   La carte est entièrement cliquable via stretched-link (amélioration vs 2023).
	 * ---------------------------------------------------------------------- */

	/* Figure — hauteur déplacée depuis l'attribut style du HTML de 2023 */
	.home .card-body figure.card-img-top {
		height: 500px;
		overflow: hidden;
	}

	/* Image — object-fit:cover, remplace width:auto/height:100% de 2023 */
	.home .card-body .card-img-top img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		object-position: center;
		display: block;
		transition: transform .4s ease-in-out;
	}

	/* Bande : invisible au repos, absolue relative à .card (Bootstrap vendor).
	 * z-index: 1 (Option B) : crée un contexte d'empilement stable ; la bande
	 * reste visuellement derrière le bouton (parent < enfant) et au-dessus de
	 * l'image. Le bouton reste position:static → le ::after du stretched-link
	 * garde .btn-wrapper comme containing block (zone cliquable inchangée). */
	.home .card-body .btn-wrapper {
		display: block;
		position: absolute;
		background: rgba(0, 0, 0, 0.6);
		opacity: 0;
		transition: opacity .3s linear;
		z-index: 1;
	}

	/* Bande : visible au survol et au focus clavier */
	.home .card-body:hover .btn-wrapper,
	.home .card:focus-within .btn-wrapper {
		opacity: 1;
	}

	/* Image : zoom au survol et au focus clavier */
	.home .card-body:hover .card-img-top img,
	.home .card:focus-within .card-img-top img {
		transform: scale(1.5);
		transition: transform .4s ease-in-out;
	}

	/* Bouton — couleurs explicites, indépendantes des tokens Bootstrap.
	 * Sélecteur .btn (et non .btn-outline-light) : s'applique quelle que soit
	 * la variante. opacity:1 garantit l'opacité pleine dans le contexte
	 * d'empilement de la bande. --bs-btn-bg:transparent déclaré explicitement
	 * pour éviter tout écrasement accidentel au repos.
	 * Option B retenue (pas de position:relative ni z-index ici) : la bande est
	 * visuellement derrière le bouton (CSS — fond parent < enfants) et le
	 * ::after du stretched-link reste contenu par .btn-wrapper. */
	.home .card-body .btn-wrapper .btn {
		--bs-btn-color: #fff;
		--bs-btn-bg: transparent;
		--bs-btn-border-color: #fff;
		--bs-btn-hover-color: #111;
		--bs-btn-hover-bg: #fff;
		--bs-btn-hover-border-color: #fff;
		--bs-btn-active-color: #111;
		--bs-btn-active-bg: #fff;
		--bs-btn-active-border-color: #fff;
		opacity: 1;
	}

	/* Anneau de focus visible sur le bouton stretched-link */
	.home .card-body .btn-wrapper .stretched-link:focus-visible {
		outline: 2px solid transparent;
		outline-offset: 2px;
		box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111;
	}

	/* Focus carte entière */
	.home .card:focus-within {
		outline: 2px solid transparent;
		box-shadow: var(--focus-ring);
	}

	/* prefers-reduced-motion */
	@media (prefers-reduced-motion: reduce) {
		.home .card-body .btn-wrapper { transition: none; }
		.home .card-body .card-img-top img { transition: none; }
	}

	/* -------------------------------------------------------------------------
	 * En-tête d'archive / taxonomie
	 * ---------------------------------------------------------------------- */

	.archive-header {
		border-bottom: var(--border-width) solid var(--border-color);
		padding-bottom: var(--space-md);
	}

	.archive-title {
		font-family: var(--font-heading);
		font-weight: var(--font-weight-bold);
		letter-spacing: 0.08em;
	}
}
