/* =============================================
   VARIABLES — couleurs, espacements, polices
   ============================================= */
:root {
  --color-bg: #f0f0f0;
  --color-surface: #ffffff;
  --color-primary: #e3350d;    /* rouge Pokéball */
  --color-primary-dark: #b52a0a;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-shadow: rgba(0, 0, 0, 0.1);

  --radius-card: 12px;
  --radius-badge: 999px;
  --shadow-card: 0 2px 8px var(--color-shadow);
  --transition: 0.2s ease;

  /* Taille d'une carte Pokémon dans la grille */
  --card-min-width: 140px;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* =============================================
   HEADER
   ============================================= */
.header {
  background-color: var(--color-primary);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ---- Barre de recherche ---- */
/* TODO Étape 3 : donne ces styles à ton <input> en lui ajoutant la classe "search-input" */
.search-input {
  flex: 1;
  max-width: 400px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-badge);
  border: none;
  font-size: 1rem;
  outline: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
  background: rgba(255, 255, 255, 0.35);
}

/* =============================================
   GRILLE DE POKÉMON
   ============================================= */
.main {
  padding: 2rem;
}

.pokemon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: 1rem;
}

/* =============================================
   CARTE POKÉMON
   ============================================= */
/* TODO Étape 2 : donne ces styles à chaque carte en lui ajoutant la classe "pokemon-card" */
.pokemon-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  user-select: none;
}

.pokemon-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px var(--color-shadow);
}

.pokemon-card__number {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.pokemon-card__sprite {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
}

.pokemon-card__name {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: capitalize;
  text-align: center;
}

/* =============================================
   LOADER (spinner)
   ============================================= */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--color-text-muted);
}

.loader__spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   MESSAGE D'ERREUR
   ============================================= */
.error-message {
  text-align: center;
  padding: 3rem;
  color: var(--color-primary);
  font-size: 1.1rem;
}

/* =============================================
   MODALE — Fiche détaillée
   ============================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal__content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  padding: 2rem;
  width: min(90vw, 420px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color var(--transition);
}

.modal__close:hover {
  color: var(--color-primary);
}

/* Contenu interne de la fiche */
.modal__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.modal__artwork {
  width: 180px;
  height: 180px;
  object-fit: contain;
}

.modal__name {
  font-size: 1.4rem;
  font-weight: 800;
  text-transform: capitalize;
}

/* ---- Badges de type ---- */
.modal__types {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.type-badge {
  padding: 0.25rem 0.9rem;
  border-radius: var(--radius-badge);
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  text-transform: capitalize;
}

/* Couleurs par type — TODO bonus : utilise ces classes dans tes badges */
.type--normal   { background: #A8A77A; }
.type--fire     { background: #EE8130; }
.type--water    { background: #6390F0; }
.type--electric { background: #F7D02C; color: #333; }
.type--grass    { background: #7AC74C; }
.type--ice      { background: #96D9D6; color: #333; }
.type--fighting { background: #C22E28; }
.type--poison   { background: #A33EA1; }
.type--ground   { background: #E2BF65; color: #333; }
.type--flying   { background: #A98FF3; }
.type--psychic  { background: #F95587; }
.type--bug      { background: #A6B91A; }
.type--rock     { background: #B6A136; }
.type--ghost    { background: #735797; }
.type--dragon   { background: #6F35FC; }
.type--dark     { background: #705746; }
.type--steel    { background: #B7B7CE; color: #333; }
.type--fairy    { background: #D685AD; }

/* ---- Stats de base ---- */
.modal__stats {
  width: 100%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal__stats li {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border);
  text-transform: capitalize;
}

.modal__stats li:last-child {
  border-bottom: none;
}

.modal__stats li span:last-child {
  font-weight: 700;
  color: var(--color-primary);
}
