/* ==========================================================================
   FlipFolio — styles front
   ========================================================================== */

/* --- Conteneur / grille ------------------------------------------------ */
.ff-grid {
	--ff-radius: 16px;
	display: grid;
	grid-template-columns: repeat(var(--ff-cols, 3), minmax(0, 1fr));
	gap: var(--ff-gap, 28px);
	box-sizing: border-box;
	font-family: var(--ff-font, "Inter", sans-serif);
	padding: clamp(16px, 3vw, 40px) clamp(16px, 4vw, 56px);
}

.ff-grid * {
	box-sizing: border-box;
}

/* Pleine largeur : on casse le conteneur du thème pour occuper tout le viewport. */
.ff-fullwidth {
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	max-width: 100vw;
}

/* Largeur contrainte (option "pleine largeur" désactivée). */
.ff-constrained {
	max-width: var(--ff-maxw, 1200px);
	margin-left: auto;
	margin-right: auto;
}

/* --- La carte ---------------------------------------------------------- */
.ff-card {
	position: relative;
	aspect-ratio: var(--ff-ratio, 3 / 4);
	perspective: 1400px;
	-webkit-perspective: 1400px;
	cursor: pointer;
	transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
	outline: none;
}

.ff-card.ff-static {
	cursor: default;
}

/* Léger soulèvement au survol (sur les cartes non purement au survol). */
@media (hover: hover) {
	.ff-card:hover {
		transform: translateY(-6px);
	}
}

/* --- Mécanique du retournement 3D -------------------------------------- */
.ff-flip-inner {
	position: relative;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	-webkit-transform-style: preserve-3d;
	transition: transform 0.75s cubic-bezier(0.2, 0.75, 0.2, 1);
}

/* Retournement au clic (classe posée par le JS). */
.ff-card.is-flipped .ff-flip-inner {
	transform: rotateY(180deg);
}

/* Retournement au survol (si l'option est activée), sur les appareils à souris. */
@media (hover: hover) {
	.ff-hover .ff-card:not(.ff-static):hover .ff-flip-inner {
		transform: rotateY(180deg);
	}
}

.ff-face {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: var(--ff-radius, 16px);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	box-shadow:
		0 10px 30px rgba(17, 24, 39, 0.12),
		0 2px 8px rgba(17, 24, 39, 0.08);
}

.ff-back {
	transform: rotateY(180deg);
}

/* --- Recto : la photo -------------------------------------------------- */
.ff-front {
	background: #e9ebf0;
}

.ff-photo {
	position: absolute;
	inset: 0;
}

.ff-photo .ff-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Bloc de repli sans photo : dégradé neutre avec l'initiale. */
.ff-noimg {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-size: clamp(3rem, 8vw, 5rem);
	font-weight: 700;
	color: rgba(255, 255, 255, 0.9);
	background: linear-gradient(135deg, var(--ff-accent, #4f46e5), #111827);
}

/* Voile dégradé en bas pour la lisibilité du nom / rôle. */
.ff-front-info {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 44px 20px 18px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	background: linear-gradient(to top, rgba(15, 18, 26, 0.88) 12%, rgba(15, 18, 26, 0) 100%);
	color: #fff;
}

.ff-name {
	font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.3rem);
	font-weight: 700;
	line-height: 1.2;
}

.ff-role {
	font-size: clamp(0.78rem, 0.72rem + 0.2vw, 0.9rem);
	font-weight: 500;
	letter-spacing: 0.02em;
	color: rgba(255, 255, 255, 0.82);
}

/* Petit indice « retournable » en haut à droite. */
.ff-flip-hint {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	color: #fff;
	background: rgba(15, 18, 26, 0.42);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0.85;
	transition: opacity 0.3s ease, background 0.3s ease;
}

.ff-flip-icon {
	width: 18px;
	height: 18px;
}

@media (hover: hover) {
	.ff-card:hover .ff-flip-hint {
		opacity: 1;
		background: var(--ff-accent, #4f46e5);
	}
}

/* --- Verso : la biographie --------------------------------------------- */
.ff-back {
	background: var(--ff-card, #ffffff);
	color: var(--ff-text, #1f2430);
}

.ff-back-inner {
	position: absolute;
	inset: 0;
	padding: clamp(20px, 4vw, 30px);
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}

.ff-accent-bar {
	display: block;
	width: 42px;
	height: 4px;
	border-radius: 4px;
	margin-bottom: 14px;
	background: var(--ff-accent, #4f46e5);
	flex: 0 0 auto;
}

.ff-back-name {
	font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.3rem);
	font-weight: 700;
	line-height: 1.2;
}

.ff-back-role {
	font-size: clamp(0.8rem, 0.74rem + 0.2vw, 0.92rem);
	font-weight: 600;
	color: var(--ff-accent, #4f46e5);
	margin-top: 2px;
	margin-bottom: 12px;
}

.ff-bio {
	margin: 0;
	font-size: clamp(0.86rem, 0.8rem + 0.25vw, 0.98rem);
	line-height: 1.6;
	color: var(--ff-text, #1f2430);
	opacity: 0.85;
	word-break: break-word;
}

/* --- Accessibilité clavier --------------------------------------------- */
.ff-card:focus-visible .ff-face {
	box-shadow:
		0 0 0 3px rgba(79, 70, 229, 0.7),
		0 12px 30px rgba(17, 24, 39, 0.18);
}

/* --- Apparition au scroll (fade-in) ------------------------------------ */
.ff-reveal .ff-card:not(.ff-visible) {
	opacity: 0;
	transform: translateY(26px);
	will-change: transform, opacity;
}

.ff-reveal .ff-card {
	transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.55s ease;
}

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 781px) {
	.ff-grid {
		grid-template-columns: repeat(var(--ff-cols-mobile, 1), minmax(0, 1fr));
		gap: var(--ff-gap-mobile, 20px);
		padding: clamp(14px, 5vw, 28px);
	}
}

/* --- Accessibilité : mouvement réduit ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.ff-card,
	.ff-flip-inner {
		transition: none !important;
	}
	.ff-reveal .ff-card {
		opacity: 1 !important;
		transform: none !important;
	}
}
