/* Molotop 1.2 : widget de création (Top 5) et écran de résultat. */
.mtp-widget {
	--mtp-accent: #FFC82E;
	--mtp-accent-rgb: 255,200,46;
	--mtp-ink: #2a1030;
	box-sizing: border-box;
	max-width: 720px;
	margin: 24px auto;
	padding: 28px 24px 26px;
	border-radius: 22px;
	color: #fff;
	font-family: Poppins, "Segoe UI", system-ui, sans-serif;
	position: relative;
	overflow: hidden;
	contain: layout;
	background:
		radial-gradient(circle at 96% 14%, rgba(255,235,180,.9), rgba(255,170,110,.35) 14%, rgba(255,150,100,0) 42%),
		linear-gradient(180deg, #241552 0%, #4a2380 20%, #8b3a94 42%, #d95f80 66%, #f58f63 86%, #2a1030 100%);
}
.mtp-widget * { box-sizing: border-box; }
.mtp-widget img { -webkit-user-drag: none; user-drag: none; -webkit-touch-callout: none; }
.mtp-widget.is-done .mtp-builder { display: none; }

.mtp-head { text-align: center; }
.mtp-title {
	font-style: italic; font-weight: 700; font-size: 40px; line-height: 1.15; letter-spacing: -.5px;
	text-shadow: 0 3px 14px rgba(40,10,60,.35);
}
.mtp-swoosh { display: block; margin: 2px auto 8px; }
.mtp-hint { margin: 0 0 16px; font-size: 14px; color: rgba(255,255,255,.9); }
.mtp-progress { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.mtp-progress span { width: 34px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.28); transition: background .25s ease; }
.mtp-progress span.is-on { background: var(--mtp-accent); }

/* Candidats */
.mtp-pool {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
	gap: 10px;
	margin-bottom: 22px;
	min-height: 1px;
}
.mtp-card {
	position: relative;
	display: flex; flex-direction: column; align-items: center; gap: 6px;
	padding: 10px 6px 9px;
	border: 1.5px solid rgba(255,255,255,.28);
	border-radius: 16px;
	background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.08));
	cursor: grab; user-select: none; touch-action: none;
	transition: transform .15s ease, opacity .2s ease, border-color .15s ease;
}
.mtp-card:hover { transform: translateY(-3px); border-color: var(--mtp-accent); }
.mtp-card:focus-visible { outline: 3px solid var(--mtp-accent); outline-offset: 2px; }
.mtp-card:active { cursor: grabbing; }
.mtp-card.is-used { opacity: .4; pointer-events: none; }
.mtp-card.is-dragging { transform: scale(1.04); z-index: 5; }
.mtp-card img, .mtp-card-placeholder {
	width: 58px; height: 58px; border-radius: 50%; object-fit: cover; object-position: 50% 12%;
	border: 2px solid rgba(255,255,255,.7); display: block; background: rgba(255,255,255,.25);
}
.mtp-card-name { font-size: 13px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; text-align: center; line-height: 1.2; }

/* Classement : même disposition que l'image générée */
.mtp-ranking {
	display: grid;
	grid-template-columns: repeat(24, 1fr);
	grid-template-rows: 132px 190px 132px;
	gap: 12px;
	margin-bottom: 20px;
}
.mtp-slot {
	position: relative; overflow: hidden;
	display: flex; align-items: flex-end;
	padding: 12px;
	border: 1.5px dashed rgba(255,255,255,.5);
	border-radius: 16px;
	background: rgba(20,8,40,.28);
	transition: border-color .2s ease, background .2s ease;
}
.mtp-slot[data-rank="4"] { grid-column: span 11; }
.mtp-slot[data-rank="2"] { grid-column: span 13; }
.mtp-slot[data-rank="1"] { grid-column: span 24; }
.mtp-slot[data-rank="3"] { grid-column: span 14; }
.mtp-slot[data-rank="5"] { grid-column: span 10; }
.mtp-slot.is-next { border-style: solid; border-color: var(--mtp-accent); background: rgba(var(--mtp-accent-rgb), .14); animation: mtp-pulse 1.4s ease-in-out infinite; }
.mtp-slot.is-over { border-style: solid; border-color: var(--mtp-accent); background: rgba(var(--mtp-accent-rgb), .28); }
.mtp-slot.is-filled { border-style: solid; border-color: rgba(255,255,255,.35); animation: none; }
@keyframes mtp-pulse { 50% { box-shadow: 0 0 0 5px rgba(var(--mtp-accent-rgb), .3); } }
@media (prefers-reduced-motion: reduce) { .mtp-slot.is-next { animation: none; } }

.mtp-slot-rank {
	position: absolute; left: 12px; top: 2px; z-index: 1;
	font-weight: 700; font-size: 76px; line-height: 1;
	background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.05));
	-webkit-background-clip: text; background-clip: text; color: transparent;
}
.mtp-slot[data-rank="1"] .mtp-slot-rank { font-size: 128px; top: 6px; }
.mtp-slot[data-rank="4"].is-filled .mtp-slot-rank { left: auto; right: 12px; }
.mtp-slot-empty { position: relative; z-index: 2; margin-left: auto; max-width: 55%; text-align: right; font-size: 12px; color: rgba(255,255,255,.85); }
.mtp-slot[data-rank="4"] .mtp-slot-empty { margin-left: 0; margin-right: auto; text-align: left; }

.mtp-slot-photo {
	position: absolute; bottom: 0; right: 8%; z-index: 1;
	width: 46%; max-width: 170px; height: 125%;
	object-fit: cover; object-position: 50% 0;
}
.mtp-slot[data-rank="1"] .mtp-slot-photo { right: auto; left: 50%; transform: translateX(-50%); width: 40%; max-width: 240px; height: 118%; }
.mtp-slot[data-rank="4"] .mtp-slot-photo { right: auto; left: 14%; }
.mtp-slot::after { /* fondu sombre en bas de carte */
	content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%; z-index: 1; pointer-events: none;
	background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.45)); opacity: 0; transition: opacity .2s ease;
}
.mtp-slot.is-filled::after { opacity: 1; }
.mtp-slot-name {
	position: relative; z-index: 2; margin-left: auto;
	padding: 6px 14px; border-radius: 12px; font-weight: 700; font-size: 13px; letter-spacing: .4px; text-transform: uppercase;
	border: 1.5px solid rgba(255,255,255,.35);
	background: linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,.08)), rgba(20,10,35,.38);
}
.mtp-slot[data-rank="4"] .mtp-slot-name { margin-left: 0; margin-right: auto; }
.mtp-slot-remove {
	position: absolute; top: 8px; right: 8px; z-index: 3; width: 26px; height: 26px; padding: 0; margin: 0;
	border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; line-height: 0;
	display: flex; align-items: center; justify-content: center;
}
.mtp-slot-remove svg { width: 11px; height: 11px; display: block; }
.mtp-slot-remove:hover { background: #000; }

/* Boutons */
.mtp-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.mtp-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	padding: 13px 24px; border-radius: 14px; border: 0; cursor: pointer;
	font: inherit; font-weight: 700; font-size: 15px; text-decoration: none;
	background: var(--mtp-accent); color: var(--mtp-ink);
	transition: background .15s ease, color .15s ease, opacity .15s ease;
}
.mtp-btn-icon { display: inline-flex; line-height: 1; }
.mtp-btn-icon:empty { display: none; }
.mtp-btn:hover { background: #fff; color: var(--mtp-ink); }
.mtp-btn-reset { background: rgba(255,255,255,.16); color: #fff; border: 1.5px solid rgba(255,255,255,.35); }
.mtp-btn-reset:hover { background: rgba(255,255,255,.3); color: #fff; }
.mtp-btn[disabled] { opacity: .45; cursor: not-allowed; }
.mtp-btn[disabled]:hover { background: var(--mtp-accent); }
.mtp-btn:focus-visible, .mtp-link:focus-visible, .mtp-share button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Écran de résultat (après génération) */
.mtp-result { text-align: center; }
.mtp-result-title { font-style: italic; font-weight: 700; font-size: 32px; line-height: 1.2; text-shadow: 0 3px 14px rgba(40,10,60,.35); }
.mtp-result-sub { margin: 4px 0 16px; font-size: 14px; color: rgba(255,255,255,.9); }
.mtp-canvas {
	display: block; width: min(400px, 100%); height: auto; aspect-ratio: 1080 / 1440;
	margin: 0 auto 18px; border-radius: 14px; border: 1.5px solid rgba(255,255,255,.4);
	box-shadow: 0 10px 30px rgba(20,5,40,.45);
}
.mtp-share-download { display: flex; width: min(400px, 100%); margin: 0 auto 10px; font-size: 16px; }
.mtp-share { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(400px, 100%); margin: 0 auto 10px; }
.mtp-share .mtp-btn { padding: 11px 4px; font-size: 13px; border-radius: 12px; background: rgba(0,0,0,.3); color: #fff; border: 1.5px solid rgba(255,255,255,.35); }
.mtp-share .mtp-btn:hover { background: rgba(0,0,0,.5); border-color: var(--mtp-accent); color: #fff; }
.mtp-share-note { min-height: 40px; max-width: 400px; margin: 6px auto 12px; font-size: 13px; color: rgba(255,255,255,.9); }
.mtp-result-links { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mtp-link { background: none; border: 0; padding: 6px 8px; color: #fff; font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.mtp-link:hover { background: none; color: var(--mtp-accent); }

@media (max-width: 520px) {
	.mtp-widget { padding: 22px 14px 20px; margin: 14px 0; border-radius: 16px; }
	.mtp-title { font-size: 30px; }
	.mtp-ranking { grid-template-rows: 110px 150px 110px; gap: 10px; }
	.mtp-slot-rank { font-size: 56px; }
	.mtp-slot[data-rank="1"] .mtp-slot-rank { font-size: 90px; }
	.mtp-slot-name { font-size: 11px; padding: 5px 10px; }
}

/* Vue "résultat" partagé (lien ?mtp_r=<id>) : l'image d'un ami + un bouton
   pour créer son propre Top. Classe distincte de .mtp-widget pour que le JS
   du widget interactif ne s'y initialise jamais. */
.mtp-result-page {
	--mtp-accent: #FFC82E;
	--mtp-accent-rgb: 255,200,46;
	--mtp-ink: #2a1030;
	box-sizing: border-box;
	max-width: 720px;
	margin: 24px auto;
	padding: 20px;
	background: #fff;
	border: 1px solid #ebebeb;
	border-radius: 14px;
	text-align: center;
	font-family: Poppins, "Segoe UI", system-ui, sans-serif;
}
.mtp-result-page .mtp-btn { background: var(--mtp-accent); color: var(--mtp-ink); }
.mtp-result-page .mtp-btn:hover { background: #000; color: var(--mtp-accent); }
.mtp-result-view-image { display: block; width: 100%; max-width: 480px; margin: 0 auto 16px; border-radius: 10px; }
.mtp-result-view-cta-wrap { margin: 0; }
.mtp-result-view-cta { display: inline-flex; }
