/* Compagnons (compagnons.js) : avatar des profils, page « Mon compagnon », mascotte du thème
   Classique, carte de victoire. Animations coupées par .anim-reduites (réglage du profil). */

/* --- Avatar --- */
.avatar-compagnon { display: inline-block; flex: none; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; line-height: 0; vertical-align: middle; }
.avatar-compagnon svg { display: block; width: 100%; height: 100%; }
.avatar-compagnon.mini { width: 28px; height: 28px; }
.avatar-compagnon.petit { width: 44px; height: 44px; }
.avatar-compagnon.moyen { width: 72px; height: 72px; }
.avatar-compagnon.avatar-profil { width: 64px; height: 64px; font-size: 0; }

/* les 4 visages sont dans le SVG ; l'humeur du parent choisit celui qu'on voit */
.visage { display: none; }
.visage-attend { display: inline; }
[data-humeur='content'] .visage-attend, [data-humeur='oups'] .visage-attend, [data-humeur='bravo'] .visage-attend { display: none; }
[data-humeur='content'] .visage-content, [data-humeur='oups'] .visage-oups, [data-humeur='bravo'] .visage-bravo { display: inline; }

/* --- En-tête : image du compagnon (« Mon compagnon ») + prénom ▾ (« Qui joue ? ») --- */
.bouton-compagnon {
  display: inline-flex; flex: none; width: 52px; height: 52px; border-radius: 50%;
  box-shadow: 0 0 0 3px #fff, 0 3px 10px rgba(0, 0, 0, 0.18); text-decoration: none;
}
.bouton-compagnon .avatar-compagnon { width: 100%; height: 100%; animation: compagnon-respire 3.4s ease-in-out infinite; }
.bouton-compagnon:focus-visible { outline: 3px solid #0072B2; outline-offset: 3px; }
.tete-menu:has(.bouton-compagnon) { gap: 8px; }
.bouton-profil.avec-compagnon { gap: 2px; padding: 4px 10px; margin-left: -4px; }
.bouton-profil.avec-compagnon > span:first-child { font-size: inherit; line-height: inherit; }
.changer-profil { font-size: 0.9rem; opacity: 0.7; }
@media (max-width: 600px) {
  .bouton-profil.avec-compagnon { min-width: 44px; justify-content: center; padding: 4px 6px; }
  .bouton-profil.avec-compagnon .nom-profil { display: inline; max-width: 4.5em; font-size: 0.85rem; }
  .bouton-compagnon { width: 46px; height: 46px; }
}
/* téléphone : compagnon + prénom + titre + ★ + ⚙ sur 358 px, le titre ne doit pas passer sous ★ */
@media (max-width: 420px) {
  .tete-menu:has(.bouton-compagnon) { gap: 6px; }
  .avec-onglets .tete-menu:has(.bouton-compagnon) h1 { font-size: clamp(1.05rem, 5.1vw, 1.4rem); white-space: nowrap; }
  .bouton-profil.avec-compagnon .nom-profil { max-width: 4em; }
}
/* très petit écran (iPhone SE, Android 360 px) : le compagnon suffit, il ne reste que ▾ pour « Qui joue ? » */
@media (max-width: 380px) {
  .bouton-profil.avec-compagnon .nom-profil { display: none; }
}

/* --- « Qui joue ? » --- */
.lien-compagnon { display: flex; justify-content: center; align-items: center; min-height: 48px; margin: 0 0 12px; text-decoration: none; font-weight: 800; }
.carte-profil .avatar-compagnon.avatar-profil { margin-bottom: 4px; }
.choix-compagnon-nouveau { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 0; }
.choix-compagnon-nouveau label { cursor: pointer; }
.choix-compagnon-nouveau input { position: absolute; opacity: 0; pointer-events: none; }
.choix-compagnon-nouveau span {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 6px;
  border-radius: 14px; border: 3px solid transparent; background: #f6f3ee;
}
.choix-compagnon-nouveau svg { width: 64px; height: 64px; border-radius: 50%; }
.choix-compagnon-nouveau input:checked + span { border-color: #2b2b2b; background: #fff; }
.choix-compagnon-nouveau input:focus-visible + span { outline: 3px solid #0072B2; }

/* --- Espace parent --- */
.onglets [data-enfant] .avatar-compagnon { margin-right: 2px; }
.compagnon-parent { display: flex; align-items: center; gap: 12px; }

/* --- Menu : annonce d'un compagnon débloqué (même allure que celle des nouveaux jeux) --- */
.annonce-compagnon { margin: 12px 0 0; }
.annonce-compagnon .avatar-compagnon { box-shadow: 0 0 0 2px #fff; }

/* --- Page « Mon compagnon » --- */
.page-compagnon .menu { max-width: 720px; }
.scene-compagnon { display: flex; flex-direction: column; align-items: center; margin: 8px 0 6px; }
.apercu-compagnon {
  width: min(48vw, 40vh, 240px); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
  background: none; box-shadow: 0 0 0 6px #fff, 0 10px 26px rgba(0, 0, 0, 0.2); line-height: 0;
}
.apercu-compagnon svg { width: 100%; height: 100%; display: block; }
.apercu-compagnon[data-humeur='attend'] svg { animation: compagnon-respire 3.4s ease-in-out infinite; transform-origin: 50% 90%; }
.apercu-compagnon[data-humeur='content'] svg { animation: theme-saute 0.6s ease-out; transform-origin: 50% 90%; }
.apercu-compagnon:focus-visible { outline: 4px solid #0072B2; outline-offset: 8px; }
.nom-compagnon { margin: 14px 0 0; font-size: 1.35rem; font-weight: 800; }
.total-compagnon { margin: 2px 0 0; color: #6f685c; }
.total-compagnon b { color: #c98f00; }

.onglets-compagnon {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; margin: 8px -4px 0; scrollbar-width: none;
  position: sticky; top: 0; z-index: 2; background: inherit;
}
.onglet-compagnon {
  flex: none; min-height: 44px; padding: 6px 14px; font: inherit; font-weight: 800; border-radius: 999px; cursor: pointer;
  border: 2px solid #d8d1c5; background: #fff; color: #2b2b2b;
}
.onglet-compagnon[aria-selected='true'] { background: #2b2b2b; border-color: #2b2b2b; color: #fff; }
.message-compagnon:empty { margin: 0; min-height: 0; }
.message-compagnon { min-height: 1.4em; margin: 2px 0 6px; font-weight: 700; color: #8a5a00; text-align: center; }

.choix-compagnon { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; padding-bottom: 24px; }
.carte-compagnon {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 8px 6px 10px;
  font: inherit; border-radius: 16px; border: 3px solid #e6e0d6; background: #fff; color: #2b2b2b; cursor: pointer; text-align: center;
}
.carte-compagnon.choisi { border-color: #00785a; box-shadow: 0 0 0 3px #bfe9d8; }
.carte-compagnon.choisi::after { content: '✓'; position: absolute; top: 4px; right: 8px; font-weight: 900; color: #00785a; }
.mini-compagnon { display: block; width: 80px; height: 80px; border-radius: 50%; overflow: hidden; background: #f6f3ee; line-height: 0; }
.mini-compagnon svg { width: 100%; height: 100%; display: block; }
.rien-compagnon { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 2.4rem; line-height: 1; color: #b5ad9f; }
.nom-choix { font-size: 0.86rem; font-weight: 700; line-height: 1.2; }
.nom-choix small { display: block; font-weight: 600; color: #6f685c; }
.carte-compagnon.verrouille { background: #f3f0ea; }
.carte-compagnon.verrouille .mini-compagnon svg { filter: grayscale(1) opacity(0.55); }
/* animal verrouillé : en ombre (silhouette) */
.carte-compagnon.ombre .mini-compagnon svg { filter: brightness(0) opacity(0.28); }
.verrou-compagnon { font-size: 0.8rem; font-weight: 800; color: #5f584c; line-height: 1.2; }
.carte-compagnon .progres-style { width: 80%; height: 8px; }

/* --- Mascotte du thème Classique : le compagnon en jeu (humeurs de themes.css) --- */
.mascotte-theme.mascotte-compagnon .avatar-compagnon {
  width: 84px; height: 84px; pointer-events: auto; cursor: pointer; transform-origin: 50% 90%;
  border: 4px solid #fff; box-shadow: 0 0 0 4px #2b2b2b, 0 6px 14px rgba(0, 0, 0, 0.25); box-sizing: border-box;
}
.mascotte-compagnon[data-humeur='attend'] .avatar-compagnon { animation: theme-respire 3.2s ease-in-out infinite; }
.mascotte-compagnon[data-humeur='content'] .avatar-compagnon { animation: theme-saute 0.6s ease-out; }
.mascotte-compagnon[data-humeur='oups'] .avatar-compagnon { animation: theme-hoche 0.6s ease-in-out; }
.mascotte-compagnon[data-humeur='bravo'] .avatar-compagnon { animation: theme-bravo 0.45s ease-in-out 6 alternate; }
@media (max-width: 700px) {
  .mascotte-theme.mascotte-compagnon .avatar-compagnon { width: 60px; height: 60px; border-width: 3px; box-shadow: 0 0 0 3px #2b2b2b, 0 4px 10px rgba(0, 0, 0, 0.25); }
}

/* --- Carte de victoire --- */
/* Classique : le compagnon à la place de la mascotte, en haut de la carte */
.compagnon-victoire { display: flex; justify-content: center; margin: 2px auto 8px; }
.compagnon-victoire .avatar-compagnon {
  width: 92px; height: 92px; box-shadow: 0 0 0 4px #fff, 0 0 0 7px #2b2b2b, 0 6px 14px rgba(0, 0, 0, 0.2);
  animation: theme-bravo 0.45s ease-in-out 0.5s 6 alternate both;
}
/* autres thèmes : petit, à gauche de la mascotte du thème (.victoire::before, 96 px centrés) */
:root:not([data-theme='classique']) .compagnon-victoire { position: absolute; top: 46px; left: calc(50% - 108px); margin: 0; }
:root:not([data-theme='classique']) .compagnon-victoire .avatar-compagnon {
  width: 54px; height: 54px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--t-anneau, #2b2b2b), 0 4px 10px rgba(0, 0, 0, 0.2);
  animation-delay: 0.7s;
}
.victoire.grande-fete .compagnon-victoire .avatar-compagnon { animation: theme-fete 0.38s ease-in-out 0.4s 12 alternate both; }
.cadeau-compagnon {
  display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; margin: 8px 0 2px; padding: 6px 12px;
  border-radius: 14px; background: #e6f6ee; color: #0f5a40; font-weight: 700; text-decoration: none;
}
@media (max-width: 700px) {
  .compagnon-victoire .avatar-compagnon { width: 68px; height: 68px; }
  :root:not([data-theme='classique']) .compagnon-victoire { top: 30px; left: calc(50% - 82px); }
  :root:not([data-theme='classique']) .compagnon-victoire .avatar-compagnon { width: 44px; height: 44px; }
}

@keyframes compagnon-respire { 50% { transform: translateY(-2px) scale(1.03); } }

/* animations réduites : réglage du profil ou, par défaut, prefers-reduced-motion */
.anim-reduites .bouton-compagnon .avatar-compagnon,
.anim-reduites .apercu-compagnon svg,
.anim-reduites .mascotte-compagnon .avatar-compagnon,
.anim-reduites .compagnon-victoire .avatar-compagnon { animation: none !important; }
.anim-reduites .apercu-compagnon[data-humeur='content'] svg { animation: fondu 0.3s ease-out !important; }

/* étoiles suffisantes pour débloquer cet élément (fenêtre « Débloquer » au tap) */
.possible-compagnon { display: inline-block; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: #f0b400; color: #2b2000; font-weight: 800; font-size: 0.8rem; }
