/**
 * Image Match — styles du jeu.
 *
 * Tout est préfixé .ifim- : le shortcode peut être posé sur n'importe quelle
 * page sans risque de collision avec le thème (qui utilise Tailwind et
 * .ct-page). Les couleurs reprennent la charte : primary-blue #0A2D57,
 * accent-red #E63946.
 *
 * @package if-image-match
 */

.ifim-app {
	--ifim-blue: var(--primary-blue, #0A2D57);
	--ifim-red: var(--accent-red, #E63946);
	--ifim-ink: #1c2b3a;
	--ifim-muted: #5b6b7c;
	--ifim-line: #dfe6ee;
	max-width: 960px;
	margin: 0 auto;
	font-family: 'Inter', system-ui, -apple-system, sans-serif;
	color: var(--ifim-ink);
}

.ifim-app [hidden] { display: none !important; }

/* ---------- Bandeau de progression ---------- */
.ifim-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: .85rem;
}

.ifim-count {
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--ifim-muted);
}

.ifim-score {
	font-size: .8rem;
	font-weight: 600;
	color: var(--ifim-blue);
	background: rgba(10, 45, 87, .07);
	padding: .3rem .7rem;
	border-radius: 999px;
	white-space: nowrap;
}

.ifim-bar {
	height: 5px;
	border-radius: 99px;
	background: #e8eef5;
	overflow: hidden;
	margin-bottom: 1.1rem;
}

.ifim-bar > i {
	display: block;
	height: 100%;
	width: 0;
	background: linear-gradient(90deg, var(--ifim-blue), #2563eb);
	transition: width .25s;
}

/* ---------- Pastilles niveau / scène ---------- */
.ifim-chips {
	display: flex;
	flex-wrap: wrap;
	gap: .45rem;
	margin-bottom: .9rem;
}

.ifim-chip {
	font-size: .74rem;
	font-weight: 600;
	letter-spacing: .05em;
	text-transform: uppercase;
	padding: .3rem .65rem;
	border-radius: 999px;
	background: rgba(10, 45, 87, .07);
	color: var(--ifim-blue);
}

.ifim-chip--level {
	background: rgba(230, 57, 70, .1);
	color: var(--ifim-red);
}

/* ---------- Photo ---------- */
.ifim-frame {
	position: relative;
	aspect-ratio: 16 / 9;
	margin: 0 0 1.1rem;
	border-radius: 14px;
	overflow: hidden;
	background: #e9eef4;
	border: 1px solid var(--ifim-line);
	cursor: zoom-in;
}

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

.ifim-frame:focus-visible {
	outline: 3px solid var(--ifim-blue);
	outline-offset: 3px;
}

.ifim-zoom {
	position: absolute;
	top: .7rem;
	right: .7rem;
	width: 2rem;
	height: 2rem;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: rgba(10, 45, 87, .72);
	color: #fff;
	font-size: .8rem;
	pointer-events: none;
}

/* Icône en SVG et non en Font Awesome : le repère de zoom doit s'afficher même
   si la police d'icônes du thème n'est pas chargée sur la page. */
.ifim-zoom svg { display: block; }

.ifim-frame figcaption {
	position: absolute;
	left: .7rem;
	bottom: .7rem;
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .04em;
	background: rgba(10, 45, 87, .78);
	color: #fff;
	padding: .25rem .6rem;
	border-radius: 999px;
}

/* ---------- Question et propositions ---------- */
.ifim-ask {
	font-size: .98rem;
	font-weight: 600;
	margin: 0 0 .8rem;
}

.ifim-opts {
	display: grid;
	gap: .55rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ifim-opt {
	display: flex;
	align-items: flex-start;
	gap: .7rem;
	width: 100%;
	text-align: left;
	font-family: inherit;
	font-size: .95rem;
	line-height: 1.5;
	color: var(--ifim-ink);
	background: #fff;
	border: 1.5px solid var(--ifim-line);
	border-radius: 12px;
	padding: .8rem .9rem;
	cursor: pointer;
	transition: border-color .15s, background .15s;
}

.ifim-opt:hover:not(:disabled) {
	border-color: var(--ifim-blue);
	background: #f8fafc;
}

.ifim-opt:disabled { cursor: default; }

.ifim-letter {
	flex: 0 0 auto;
	width: 1.55rem;
	height: 1.55rem;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-size: .78rem;
	font-weight: 700;
	background: #eef4fb;
	color: var(--ifim-blue);
	margin-top: .05rem;
}

.ifim-opt.is-correct {
	border-color: #15803d;
	background: #f1fbf4;
}

.ifim-opt.is-correct .ifim-letter {
	background: #15803d;
	color: #fff;
}

.ifim-opt.is-wrong {
	border-color: var(--ifim-red);
	background: #fdf3f4;
}

.ifim-opt.is-wrong .ifim-letter {
	background: var(--ifim-red);
	color: #fff;
}

.ifim-opt.is-dim { opacity: .62; }

/* ---------- Correction ---------- */
.ifim-feedback {
	margin-top: 1rem;
	padding: .9rem 1rem;
	border-radius: 12px;
	background: #f8fafc;
	border-left: 4px solid var(--ifim-blue);
}

.ifim-feedback.is-good {
	border-left-color: #15803d;
	background: #f1fbf4;
}

.ifim-feedback.is-bad {
	border-left-color: var(--ifim-red);
	background: #fdf3f4;
}

.ifim-feedback strong {
	display: block;
	font-size: .9rem;
	margin-bottom: .3rem;
}

.ifim-feedback p {
	margin: 0;
	font-size: .9rem;
	line-height: 1.55;
	color: var(--ifim-muted);
}

/* ---------- Bouton suivant ---------- */
.ifim-next {
	display: block;
	width: 100%;
	margin-top: 1rem;
	border: 0;
	border-radius: 12px;
	cursor: pointer;
	font-family: inherit;
	font-size: .95rem;
	font-weight: 600;
	color: #fff;
	background: var(--ifim-blue);
	padding: .85rem 1.2rem;
	transition: background .15s;
}

.ifim-next:hover { background: #0f3d73; }

/* ---------- Fin de série ---------- */
.ifim-end {
	text-align: center;
	padding: .5rem 0;
}

.ifim-end-kicker {
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--ifim-muted);
	margin: 0;
}

.ifim-end-score {
	font-family: 'Playfair Display', Georgia, serif;
	font-size: 2.6rem;
	margin: .2rem 0;
	color: var(--ifim-blue);
}

.ifim-end-score small {
	font-size: 1.1rem;
	color: var(--ifim-muted);
}

.ifim-end-msg {
	color: var(--ifim-muted);
	margin: .2rem auto 1.2rem;
	max-width: 34rem;
}

/* ---------- Agrandissement ---------- */
.ifim-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	overflow: auto;
	padding: 3.2rem .5rem 2.4rem;
	background: #08142a;
	cursor: zoom-out;
}

.ifim-lightbox img {
	display: block;
	margin: 0 auto;
	width: 100%;
	max-width: 1100px;
	height: auto;
	border-radius: 10px;
	cursor: zoom-in;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

/* Zoom ×2 : à 390 px la photo passe de ~359 à ~718 px et devient défilable.
   C'est le seul moyen de lire le détail qui décide la réponse. */
.ifim-lightbox.is-zoomed img {
	width: 200%;
	max-width: none;
	cursor: zoom-out;
}

.ifim-lightbox-hint {
	position: fixed;
	left: 0;
	right: 0;
	bottom: .7rem;
	text-align: center;
	font-size: .72rem;
	color: #fff;
	opacity: .75;
	pointer-events: none;
}

.ifim-lightbox-close {
	position: fixed;
	top: .7rem;
	right: .7rem;
	width: 2.4rem;
	height: 2.4rem;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	background: rgba(255, 255, 255, .18);
	color: #fff;
	font-size: 1.15rem;
	line-height: 1;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
	.ifim-opt {
		font-size: .92rem;
		padding: .75rem .8rem;
		gap: .6rem;
	}

	.ifim-ask { font-size: .94rem; }

	.ifim-end-score { font-size: 2.2rem; }
}

/* En colonne unique (tablette, petit portable), la photo prenait toute la
   largeur — 923 × 520 px à 1023 px de large — et repoussait les quatre
   propositions hors de l'écran. On la borne en largeur : elle reste lisible,
   et l'énoncé apparaît dessous sans avoir à défiler. */
@media (max-width: 1023px) {
	.ifim-frame {
		max-width: 660px;
		margin-left: auto;
		margin-right: auto;
	}
}

/* ---------- Deux colonnes : photo et propositions ensemble -------------
 * Mesuré avant ce changement, en 1440 × 800 : la photo occupait 786 → 1326 px
 * et les propositions commençaient à 1380 px. Autrement dit, quand la photo
 * était à l'écran, AUCUNE proposition ne l'était — alors que l'exercice
 * consiste précisément à comparer les deux.
 *
 * À partir de 1024 px : la photo passe à gauche et reste collée sous l'en-tête
 * pendant qu'on lit les quatre phrases. Rien ne change en dessous, où la
 * colonne unique est la seule lisible.
 */
@media (min-width: 1024px) {
	.ifim-app { max-width: 1080px; }

	.ifim-cols {
		display: grid;
		grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
		gap: 1.5rem;
		align-items: start;
	}

	.ifim-cols .ifim-frame {
		position: sticky;
		top: 6.5rem;
		margin: 0;
	}

	.ifim-side { min-width: 0; }

	/* Dans une colonne de ~490 px, les phrases de 20 mots tiennent en trois
	   lignes : on resserre légèrement pour que les quatre restent visibles. */
	.ifim-side .ifim-opt {
		padding: .7rem .8rem;
		font-size: .93rem;
	}

	.ifim-side .ifim-ask { margin-bottom: .7rem; }
}
