:root {
	--red: #dc0a2d;
	--red-d: #a3001b;
	--bg: #f2f0ec;
	--ink: #1d1d26;
	--muted: #6b6b78;
	--card: #ffffff;
	--line: #e3e0da;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14141b;
		--ink: #f2f2f5;
		--muted: #a0a0ad;
		--card: #1f1f29;
		--line: #30303c;
	}
}

* {
	box-sizing: border-box;
	min-width: 0;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--ink);
	font: 16px/1.5 Rubik, system-ui, sans-serif;
	overflow-x: clip;
}

button,
select,
input {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
}

:focus-visible {
	outline: 3px solid #29a8e0;
	outline-offset: 2px;
}

/* ---------- En-tête façon Pokédex ---------- */
.top {
	background: var(--red);
	color: #fff;
	box-shadow: 0 6px 0 var(--red-d);
}

.top-inner {
	max-width: 1200px;
	margin: auto;
	padding: 20px 24px;
	display: flex;
	gap: 20px;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
}

.brand {
	display: flex;
	align-items: center;
	gap: 14px;
}

.lens {
	flex: none;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: 6px solid #fff;
	background: radial-gradient(circle at 35% 30%, #d9f8ff, #29a8e0 45%, #0b5d9e);
	box-shadow: 0 0 0 3px rgba(0, 0, 0, .3), inset -6px -6px 10px rgba(0, 0, 0, .25);
	animation: glow 2.4s ease-in-out infinite;
}

@keyframes glow {
	50% {
		box-shadow: 0 0 0 3px rgba(0, 0, 0, .3), 0 0 22px 4px rgba(120, 220, 255, .8), inset -6px -6px 10px rgba(0, 0, 0, .25);
	}
}

.leds {
	display: flex;
	gap: 6px;
	align-self: flex-start;
	margin-top: 6px;
}

.leds i {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 2px solid rgba(0, 0, 0, .3);
	background: #ff4d4d;
}

.leds i:nth-child(2) {
	background: #ffcb05;
}

.leds i:nth-child(3) {
	background: #4cd964;
}

h1 {
	margin: 0;
	font-size: clamp(28px, 4vw, 40px);
	line-height: 1.05;
	font-weight: 800;
}

.hello {
	margin: 2px 0 0;
	opacity: .85;
}

.search {
	flex: 1 1 280px;
	display: flex;
	justify-content: flex-end;
}

.search input {
	width: min(420px, 100%);
	height: 48px;
	border: 0;
	border-radius: 999px;
	padding: 0 20px 0 46px;
	font-size: 16px;
	color: #1d1d26;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b78' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat 16px center / 18px;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15);
}

/* ---------- Filtres ---------- */
.controls {
	max-width: 1200px;
	margin: 28px auto 4px;
	padding: 0 24px;
}

.gens {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding-bottom: 6px;
	scrollbar-width: thin;
}

.gen {
	flex: none;
	border: 2px solid var(--line);
	background: var(--card);
	border-radius: 14px;
	padding: 8px 14px;
	text-align: left;
	line-height: 1.2;
	font-weight: 700;
}

.gen small {
	display: block;
	font-weight: 400;
	font-size: 13px;
	opacity: .7;
}

.gen[aria-selected="true"] {
	background: var(--ink);
	color: var(--bg);
	border-color: var(--ink);
}

.row {
	display: flex;
	gap: 16px;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	margin-top: 16px;
}

.types {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.chip {
	border: 2px solid transparent;
	border-radius: 999px;
	padding: 5px 12px;
	font-size: 13px;
	font-weight: 500;
	background: color-mix(in srgb, var(--t) 20%, var(--card));
}

.chip.on {
	background: var(--t);
	color: #fff;
	text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}

.actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.pill,
select {
	height: 44px;
	border-radius: 999px;
	border: 2px solid var(--line);
	background: var(--card);
	padding: 0 14px;
	font-size: 14px;
	font-weight: 500;
}

.pill[aria-pressed="true"] {
	background: #ffcb05;
	border-color: #e0a800;
	color: #1d1d26;
}

.status {
	color: var(--muted);
	font-size: 14px;
	margin: 14px 0 0;
	min-height: 21px;
}

/* ---------- Grille de cartes ---------- */
.grid {
	max-width: 1200px;
	margin: 0 auto;
	padding: 14px 24px 40px;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
	gap: 18px;
}

.card {
	position: relative;
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 22px;
	padding: 18px 16px;
	text-align: center;
	cursor: pointer;
	overflow: hidden;
	transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
	transition: transform .15s ease-out, box-shadow .2s;
	animation: rise .45s backwards;
	animation-delay: calc(var(--i, 0) * 12ms);
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
}

.card::before {
	content: "";
	position: absolute;
	inset: 0 0 40% 0;
	background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--c) 40%, transparent), transparent 70%);
}

.card:hover {
	box-shadow: 0 14px 30px color-mix(in srgb, var(--c) 40%, transparent);
}

.card:focus-visible {
	outline: 3px solid var(--c);
	outline-offset: 3px;
}

.art {
	position: relative;
	aspect-ratio: 1;
	display: grid;
	place-items: center;
}

/* Pokéball en filigrane */
.art::before {
	content: "";
	position: absolute;
	inset: 6%;
	border-radius: 50%;
	border: 10px solid color-mix(in srgb, var(--c) 22%, transparent);
	background:
		radial-gradient(circle, transparent 14%, color-mix(in srgb, var(--c) 22%, transparent) 14% 22%, transparent 22%),
		linear-gradient(transparent 46%, color-mix(in srgb, var(--c) 22%, transparent) 46% 54%, transparent 54%);
}

.art img {
	position: relative;
	width: 85%;
	height: auto;
	aspect-ratio: 1;
	filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .22));
	transition: transform .25s;
}

.card:hover .art img {
	transform: scale(1.08) translateY(-4px);
}

.num {
	position: absolute;
	top: 14px;
	left: 16px;
	z-index: 1;
	font-weight: 700;
	font-size: 14px;
	color: var(--muted);
}

.fav {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 2;
	width: 44px;
	height: 44px;
	border: 0;
	background: none;
	font-size: 22px;
	line-height: 1;
	color: var(--line);
	transition: transform .2s;
}

.fav:hover {
	transform: scale(1.2);
}

.fav.on {
	color: #ffcb05;
	text-shadow: 0 1px 0 #c79a00;
}

.card h3 {
	position: relative;
	margin: 6px 0 8px;
	font-size: 18px;
	font-weight: 700;
}

.badges {
	position: relative;
	display: flex;
	gap: 6px;
	justify-content: center;
	flex-wrap: wrap;
}

.badge {
	background: var(--t);
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	padding: 3px 10px;
	border-radius: 999px;
	text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
	white-space: nowrap;
}

.tag {
	display: inline-block;
	margin-top: 8px;
	padding: 2px 8px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 700;
	color: #7a5c00;
	background: #fff1b8;
}

/* Squelettes de chargement */
.sk {
	min-height: 270px;
	cursor: default;
	border-color: transparent;
	background: linear-gradient(100deg, var(--card) 40%, var(--line) 50%, var(--card) 60%) 0 0 / 200% 100%;
	animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
	to {
		background-position: -200% 0;
	}
}

.empty {
	text-align: center;
	color: var(--muted);
	padding: 20px 24px 60px;
	font-size: 18px;
}

.empty .pill {
	margin-top: 12px;
	color: var(--ink);
}

/* ---------- Fiche détaillée ---------- */
.modal {
	border: 0;
	padding: 0;
	border-radius: 28px;
	width: min(780px, calc(100% - 24px));
	max-height: calc(100% - 24px);
	background: var(--card);
	color: var(--ink);
	box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.modal[open] {
	animation: pop .3s cubic-bezier(.2, .9, .3, 1.2);
}

@keyframes pop {
	from {
		opacity: 0;
		transform: scale(.92);
	}
}

.modal::backdrop {
	background: rgba(10, 10, 20, .6);
	backdrop-filter: blur(4px);
}

.m-head {
	position: relative;
	color: #fff;
	padding: 14px 20px 0;
	background: linear-gradient(135deg, var(--c), var(--c2));
	text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.m-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.m-top .nav {
	display: flex;
	gap: 6px;
}

.icon {
	height: 40px;
	min-width: 40px;
	padding: 0 12px;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, .25);
	color: #fff;
	font-weight: 700;
	font-size: 14px;
}

.icon:hover {
	background: rgba(255, 255, 255, .4);
}

.icon.on {
	background: #fff;
	color: #1d1d26;
	text-shadow: none;
}

.m-hero {
	display: grid;
	grid-template-columns: 1fr minmax(0, 280px);
	align-items: end;
	gap: 12px;
}

.m-id {
	padding-bottom: 24px;
}

.m-id .n {
	font-weight: 700;
	opacity: .85;
}

.m-id h2 {
	margin: 0;
	font-size: clamp(32px, 5vw, 48px);
	line-height: 1.05;
	font-weight: 800;
}

.m-id .genus {
	margin: 4px 0 12px;
	opacity: .9;
}

.m-id .badge {
	background: rgba(255, 255, 255, .25);
	font-size: 14px;
	padding: 4px 12px;
}

.m-id .tools {
	display: flex;
	gap: 8px;
	margin-top: 14px;
	flex-wrap: wrap;
}

.m-art {
	position: relative;
	margin-bottom: -40px;
}

.m-art img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .35));
	animation: float 3.5s ease-in-out infinite;
}

@keyframes float {
	50% {
		transform: translateY(-8px);
	}
}

.m-body {
	padding: 52px 24px 24px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 28px;
}

.m-body h4 {
	margin: 0 0 10px;
	font-size: 15px;
	color: var(--muted);
	font-weight: 500;
}

.flavor {
	margin: 0 0 20px;
	font-size: 17px;
}

.facts {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin: 0;
}

.facts div {
	background: var(--bg);
	border-radius: 14px;
	padding: 10px 14px;
}

.facts dt {
	font-size: 13px;
	color: var(--muted);
}

.facts dd {
	margin: 0;
	font-weight: 700;
}

.facts .wide {
	grid-column: 1 / -1;
}

.stat {
	display: grid;
	grid-template-columns: 82px 34px 1fr;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	margin-bottom: 8px;
}

.stat b {
	text-align: right;
}

.bar {
	height: 10px;
	background: var(--bg);
	border-radius: 99px;
	overflow: hidden;
}

.bar i {
	display: block;
	height: 100%;
	width: var(--w);
	background: var(--sc);
	border-radius: inherit;
	animation: grow .8s ease-out backwards;
}

@keyframes grow {
	from {
		width: 0;
	}
}

.total {
	margin-top: 12px;
	padding-top: 10px;
	border-top: 2px dashed var(--line);
	display: flex;
	justify-content: space-between;
	font-weight: 700;
}

.evo-wrap {
	grid-column: 1 / -1;
}

.evo {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
	min-height: 120px;
}

.stage {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.evo-item {
	width: 112px;
	border: 2px solid transparent;
	background: var(--bg);
	border-radius: 16px;
	padding: 8px;
	display: flex;
	flex-direction: column;
	align-items: center;
	font-size: 14px;
	font-weight: 500;
}

.evo-item img {
	width: 80px;
	height: 80px;
}

.evo-item:hover {
	border-color: var(--line);
}

.evo-item.cur {
	border-color: var(--c);
}

.arrow {
	font-size: 24px;
	color: var(--muted);
}

.muted {
	color: var(--muted);
}

footer {
	text-align: center;
	color: var(--muted);
	font-size: 13px;
	padding: 10px 24px 30px;
}

footer a {
	color: inherit;
}

@media (max-width: 600px) {

	.top-inner,
	.controls,
	.grid {
		padding-left: 16px;
		padding-right: 16px;
	}

	.search input {
		width: 100%;
	}

	.grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 12px;
	}

	.card h3 {
		font-size: 16px;
	}

	.m-hero {
		grid-template-columns: 1fr;
	}

	.m-art {
		width: 200px;
		margin: -10px auto -40px;
		order: -1;
	}

	.m-id {
		padding-bottom: 12px;
	}

	.m-body {
		grid-template-columns: 1fr;
		padding: 52px 16px 20px;
	}
}

@media (prefers-reduced-motion: reduce) {

	*,
	*::before {
		animation: none !important;
		transition: none !important;
	}
}
