/* Jeu : les cousins d'écriture */

/* Repli pour les navigateurs sans color-mix() (Safari avant 16.2, vieux iPad) : sous chaque règle qui mélange
   des couleurs, un petit bloc @supports not redonne une couleur simple de base.css (la plus présente du mélange).
   Une ligne de repli écrite juste avant ne suffirait pas : une valeur qui contient var() est jugée trop tard,
   elle devient « unset » (le noir d'un SVG, un fond transparent). */

.cousins__choix {
  justify-content: center;
}

.cousins__pile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--espace-3);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--trait);
  font-weight: 700;
}

.cousins__tas {
  display: inline-flex;
  gap: 0.35rem;
}

.cousins__feuille {
  display: inline-block;
  width: 1rem;
  height: 1.3rem;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent), 0 2px 0 var(--ombre);
  transition: transform 200ms ease, opacity 200ms ease, background 200ms ease;
}

.cousins__feuille.est-faite {
  background: var(--fn-juste);
  box-shadow: inset 0 0 0 2px var(--fn-juste-texte);
  opacity: 0.65;
  transform: scale(0.9);
}

.cousins__pile-texte.est-derniere {
  color: var(--accent);
}

/* ---------- Les deux cartes, sur la table ---------- */

.cousins__table {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  gap: var(--espace-3);
  width: 100%;
  max-width: 54rem;
}

@media (min-width: 760px) {
  .cousins__table {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
}

.cousins__carte {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--espace-3);
  width: 100%;
  max-width: 24rem;
  padding: var(--espace-4);
  border-radius: 26px;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--encre) 8%, transparent) 1px, transparent 1.5px) 0 0 / 16px 16px,
    var(--surface-2); /* le code des couleurs : plus de jaune pâle en décor (il dit « le piège ») */
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 55%, var(--trait)), 0 8px 18px var(--ombre);
  transform: rotate(-1.2deg);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .cousins__carte { background: radial-gradient(circle at 1px 1px, transparent 1px, transparent 1.5px) 0 0 / 16px 16px, var(--surface-2); } }

.cousins__carte--b {
  transform: rotate(1.4deg);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--encre) 8%, transparent) 1px, transparent 1.5px) 0 0 / 16px 16px,
    color-mix(in srgb, var(--violet) 12%, var(--surface));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--violet) 45%, var(--trait)), 0 8px 18px var(--ombre);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .cousins__carte--b { background: radial-gradient(circle at 1px 1px, transparent 1px, transparent 1.5px) 0 0 / 16px 16px, var(--surface); } }

.cousins__entre {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--trait);
  color: var(--encre-2);
  font-family: var(--police-titre);
  font-size: 1.2rem;
}

.cousins__table.est-trouve .cousins__entre {
  /* trouvés : c'est juste, vert pâle, et le « ? » devient une coche */
  background: var(--fn-juste);
  color: var(--fn-juste-texte);
  box-shadow: none;
  font-size: 0;
}

.cousins__table.est-trouve .cousins__entre::after {
  content: '\2713';
  font-family: var(--police-texte);
  font-size: 1.5rem;
  font-weight: 800;
}

/* ---------- Un mot de la carte ---------- */

.cousins__mot {
  flex: 1 1 6.2rem;
  max-width: 11rem;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.2rem;
  min-height: 6.4rem;
  padding: var(--espace-2) var(--espace-1);
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--encre);
  box-shadow: inset 0 0 0 2px var(--trait), 0 3px 0 var(--trait);
  transform: rotate(var(--penche, 0deg));
  transition: transform var(--duree), box-shadow var(--duree), background var(--duree);
}

.cousins__carte--4 .cousins__mot {
  flex-basis: calc(50% - var(--espace-3));
  max-width: none;
}

.cousins__mot:hover {
  transform: rotate(0deg) translateY(-2px);
}

.cousins__image {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.cousins__image > .icone {
  width: 2.4rem;
  height: 2.4rem;
}

.cousins__ecrit {
  font-weight: 700;
  font-size: 1.22rem;
  line-height: 1.2;
  white-space: nowrap;
}

.cousins__comme .cousins__ecrit {
  white-space: normal;
}

.cousins__mot.est-choisi {
  /* le code des couleurs : le mot qu'on vient de choisir porte le contour bleu */
  background: var(--surface);
  box-shadow: inset 0 0 0 3px var(--encre), 0 0 0 3px var(--fn-change);
  transform: rotate(0deg) scale(1.05);
}

.cousins__mot.est-indice {
  animation: cousins-indice 640ms ease-in-out 3;
  box-shadow: inset 0 0 0 2px var(--trait), 0 0 0 4px var(--accent), 0 0 16px 4px color-mix(in srgb, var(--accent) 60%, transparent);
}

@keyframes cousins-indice {
  0%, 100% { transform: rotate(var(--penche, 0deg)); }
  30% { transform: rotate(-7deg) translateY(-3px); }
  70% { transform: rotate(7deg) translateY(-3px); }
}

.cousins__mot.est-cousin {
  /* le code des couleurs : un cousin trouvé, c'est juste : vert pâle, et une coche dans le coin */
  position: relative;
  background: var(--fn-juste);
  color: var(--fn-juste-texte);
  box-shadow: inset 0 0 0 3px var(--fn-juste-texte), 0 0 0 5px var(--accent);
  transform: rotate(0deg) scale(1.06);
  animation: entrer 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.cousins__mot.est-cousin::after {
  content: '\2713';
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
  color: var(--fn-juste-texte);
}

.cousins__table.est-trouve .cousins__mot:not(.est-cousin) {
  opacity: 0.5;
}

/* le morceau commun, allumé */
.cousins__morceau {
  padding: 0 0.06em;
  border-radius: 0.2em;
  /* le code des couleurs : le morceau qu'on cherche, en jaune surligné */
  background: var(--fn-piege);
  color: var(--fn-piege-texte);
  box-shadow: 0 0 0 1.5px var(--encre);
}

/* ---------- La réponse ---------- */

.cousins__message {
  max-width: 32rem;
  min-height: 1.5em;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.cousins__reponse {
  display: grid;
  justify-items: center;
  gap: var(--espace-2);
  width: 100%;
  max-width: 34rem;
  text-align: center;
}

.cousins__reponse:empty {
  display: none;
}

.cousins__comme {
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem);
  line-height: 1.3;
  animation: entrer 420ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.cousins__comme .cousins__ecrit {
  font-size: inherit;
}

.cousins__comme-mot {
  font-weight: 400;
  color: var(--encre-2);
}

.cousins__raison {
  font-size: 1.1rem;
  line-height: 1.4;
}

.cousins__indice {
  min-height: 3rem;
}

.cousins__truc {
  display: grid;
  justify-items: center;
  width: 100%;
}

/* ---------- La collection ---------- */

.cousins__collection {
  display: grid;
  gap: var(--espace-3);
  width: 100%;
  max-width: 46rem;
  padding: var(--espace-5);
  border-radius: var(--rayon-grand);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--trait);
}

.cousins__collection-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--espace-2);
}

.cousins__collection-titre {
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1.15rem;
}

.cousins__paires {
  display: flex;
  flex-wrap: wrap;
  gap: var(--espace-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cousins__paire {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.3rem 0.8rem;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--trait);
}

.cousins__paire .cousins__ecrit {
  font-size: 1.08rem;
}

.cousins__paire-et {
  color: var(--encre-2);
  font-weight: 700;
}

.cousins__paire.est-neuve {
  animation: entrer 600ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@media (max-width: 520px) {
  .cousins__carte {
    gap: var(--espace-2);
    padding: var(--espace-3);
  }

  .cousins__mot {
    flex-basis: 5.4rem;
    min-height: 5.6rem;
    padding-inline: 0.35rem;
  }

  .cousins__mot--long .cousins__ecrit {
    font-size: 0.98rem;
  }

  .cousins__image {
    width: 2rem;
    height: 2rem;
    font-size: 2rem;
  }

  .cousins__image > .icone {
    width: 2rem;
    height: 2rem;
  }

  .cousins__ecrit {
    font-size: 1.08rem;
  }

  .cousins__entre {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
}
