/* ===== Encyclopedia : tableau périodique des éléments =====
   Fichier dédié, chargé après style.css. Préfixe tp-*. Réutilise .vignette, .question, .correction et le bilan hx-*.
   Une couleur par famille (variable --c), mêlée au fond bleu nuit du site. */

.famille-non-metal { --c: #2ecc71; }
.famille-gaz-noble { --c: #9b7bff; }
.famille-alcalin { --c: #ff5d5d; }
.famille-alcalino-terreux { --c: #ffa94d; }
.famille-metalloide { --c: #3fd0c9; }
.famille-halogene { --c: #f5c542; }
.famille-metal-pauvre { --c: #9fb0c9; }
.famille-transition { --c: #3d8bff; }
.famille-lanthanide { --c: #ff7ac8; }
.famille-actinide { --c: #c58bff; }

/* Vignettes : petites cases d'éléments qui s'allument tour à tour */
.vignette-tableau .vignette-decor { display: grid; place-items: center; }
.tp-vignette-cases { display: grid; grid-template-columns: repeat(4, 34px); gap: 5px; }
.tp-vignette-cases i { display: grid; place-items: center; height: 34px; border-radius: 6px; border: 1px solid #3fd0c966; background: #3fd0c914; color: #3fd0c9; font-family: "Cinzel", Georgia, serif; font-style: normal; font-weight: 900; font-size: 0.85rem; animation: tp-allume 4s ease-in-out infinite; }
.tp-vignette-cases i:nth-child(2) { animation-delay: 0.5s; } .tp-vignette-cases i:nth-child(3) { animation-delay: 1s; } .tp-vignette-cases i:nth-child(4) { animation-delay: 1.5s; }
.tp-vignette-cases i:nth-child(5) { animation-delay: 2s; } .tp-vignette-cases i:nth-child(6) { animation-delay: 2.5s; } .tp-vignette-cases i:nth-child(7) { animation-delay: 3s; } .tp-vignette-cases i:nth-child(8) { animation-delay: 3.5s; }
@keyframes tp-allume { 0%, 30%, 100% { box-shadow: none; filter: none; } 12% { box-shadow: 0 0 14px currentColor; filter: brightness(1.5); } }

/* Le tableau : 18 colonnes, 7 périodes, puis lanthanides et actinides séparés par un espace */
.tp-tableau { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); grid-template-rows: repeat(7, auto) 10px auto auto; gap: 3px; margin: 12px 0 16px; }
.tp-case { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1; min-width: 0; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--c, var(--bord)) 45%, transparent); background: color-mix(in srgb, var(--c, var(--carte)) 10%, var(--fond)); color: var(--texte-doux); line-height: 1; overflow: hidden; transition: background 0.3s, border-color 0.3s; }
.tp-numero { position: absolute; top: 2px; left: 3px; font-size: clamp(0.4rem, 0.9vw, 0.58rem); opacity: 0.7; }
.tp-symbole { font-size: clamp(0.55rem, 1.5vw, 0.95rem); font-weight: 800; }
.tp-case.visible { background: color-mix(in srgb, var(--c) 30%, var(--fond)); color: var(--texte); }
.tp-case.visible .tp-symbole { color: color-mix(in srgb, var(--c) 60%, #fff); }
.tp-case.bon { border-color: var(--vert); box-shadow: inset 0 0 0 1px var(--vert); }
.tp-case.faux { border-color: var(--rouge); box-shadow: inset 0 0 0 1px var(--rouge); }
.tp-case.actuel { z-index: 1; border-color: #f5c542b3; background: color-mix(in srgb, var(--c) 18%, var(--fond)); color: var(--or); animation: tp-actuel 2.6s ease-in-out infinite; }
.tp-renvoi { border-style: dashed; background: none; font-size: clamp(0.35rem, 0.8vw, 0.55rem); }
@keyframes tp-actuel { 0%, 100% { box-shadow: inset 0 0 0 1px #f5c54255; } 50% { box-shadow: inset 0 0 0 1px #f5c542aa, 0 0 6px #f5c5424d; } }

/* Légende des familles */
.tp-legende { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 0.82rem; color: var(--texte-doux); }
.tp-legende li { display: inline-flex; align-items: center; gap: 6px; }
.tp-pastille { width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--c) 55%, var(--fond)); border: 1px solid var(--c); }

/* Fiche de l'élément après chaque réponse */
.tp-fiche { margin: 10px 0 14px; padding: 10px 14px; border-left: 4px solid var(--c); border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, var(--fond)); color: var(--texte); font-weight: 600; }
.tp-fiche.cache { display: none; }
.hx-carte .tp-fiche { animation: hx-lecon 0.5s ease-out; }

/* Vignette « Le tableau complet » : façon générique de série, fumée verte et titre écrit avec deux
   symboles d'éléments, « [Ta]bleau [Co]mplet », qui se révèlent dans la fumée puis s'estompent en boucle. */
.vignette-decor.tp-generique { display: grid; place-items: center; overflow: hidden; background: radial-gradient(ellipse at 50% 60%, #1f4a2a, #0a1c10 70%, #06120b); }
.tp-generique-titre { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; color: #e8f2e3; }
.tp-mot { display: inline-flex; align-items: flex-end; animation: tp-apparait 6s ease-in-out infinite; }
.tp-mot:nth-child(2) { animation-delay: 0.6s; }
.tp-elt { position: relative; display: inline-grid; place-items: center; width: 1.75em; height: 1.75em; padding-top: 0.15em; margin-right: 1px; border: 2px solid #9fd8a6; background: linear-gradient(160deg, #3f8f4f, #1d5a2b 60%, #164422); color: #fff; font-weight: 700; box-shadow: 0 0 12px #7fd18a55; }
.tp-elt small { position: absolute; top: 2px; left: 3px; font-family: system-ui, sans-serif; font-size: 0.38rem; line-height: 1; }
.tp-fumee { position: absolute; bottom: -40%; width: 70%; height: 110%; border-radius: 50%; background: radial-gradient(ellipse, #9fdc9a33, transparent 65%); filter: blur(6px); animation: tp-fumee 6s ease-out infinite; }
.tp-fumee.f1 { left: -20%; } .tp-fumee.f2 { left: 15%; animation-delay: 2s; } .tp-fumee.f3 { right: -20%; animation-delay: 4s; }
@keyframes tp-fumee { from { transform: translateY(25%) scale(0.8); opacity: 0; } 35% { opacity: 1; } to { transform: translateY(-40%) scale(1.3); opacity: 0; } }
@keyframes tp-apparait { 0% { opacity: 0; filter: blur(5px); } 25%, 75% { opacity: 1; filter: none; } 100% { opacity: 0; filter: blur(5px); } }

@media (max-width: 560px) {
  .tp-tableau { gap: 2px; }
  .tp-numero { display: none; }
  .tp-case { border-radius: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .tp-vignette-cases i, .tp-case.actuel, .hx-carte .tp-fiche, .tp-mot, .tp-fumee { animation: none !important; }
  .tp-fumee { opacity: 0.6; }
  .tp-case.actuel { box-shadow: inset 0 0 0 1px #f5c542aa; }
}

/* Tableau complet : les cases sont des boutons, on choisit celle à remplir */
button.tp-case { font: inherit; padding: 0; cursor: pointer; }
button.tp-case:hover:not(.bon):not(.faux) { border-color: var(--or); }
button.tp-case:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; z-index: 2; }
button.tp-case.bon, button.tp-case.faux { cursor: default; }
