/* =========================================================================
   ZOOMANTIX — Styles
   ========================================================================= */
:root {
  --carte: rgba(255, 253, 248, 0.74);
  --carte-bord: rgba(255, 255, 255, 0.7);
  --carte-ombre: 0 10px 40px rgba(40, 30, 10, 0.18);
  --texte: #23302a;
  --texte-doux: #5d6b63;
  --accent: #2e7d57;
  --accent-2: #1f9a8a;
  --accent-texte: #ffffff;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-bord: rgba(46, 125, 87, 0.18);
  --surface-forte: #ffffff;
  --jauge-fond: rgba(35, 48, 42, 0.08);
  --indice-fond: #fff6df;
  --indice-bord: #ecd395;
  --indice-texte: #6b4d0f;
  --voile: rgba(0, 0, 0, 0);
  --pastille: rgba(255, 255, 255, 0.85);
  --erreur: #b23a2a;
  color-scheme: light;
}

:root[data-theme="sombre"] {
  --carte: rgba(17, 24, 21, 0.7);
  --carte-bord: rgba(255, 255, 255, 0.08);
  --carte-ombre: 0 10px 40px rgba(0, 0, 0, 0.5);
  --texte: #e8efe9;
  --texte-doux: #9fb0a6;
  --accent: #5ccf96;
  --accent-2: #39b8c4;
  --accent-texte: #07140d;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-bord: rgba(92, 207, 150, 0.18);
  --surface-forte: #1b2520;
  --jauge-fond: rgba(255, 255, 255, 0.08);
  --indice-fond: rgba(238, 176, 50, 0.12);
  --indice-bord: rgba(238, 176, 50, 0.35);
  --indice-texte: #f3d58f;
  --voile: rgba(0, 0, 0, 0.15);
  --pastille: rgba(20, 28, 24, 0.8);
  --erreur: #ff8a78;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: #1b2a22;
  color: var(--texte);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Décor ---------- */
.decor {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--decor-ordi);
  transition: opacity 0.6s ease;
}
/* Écran en hauteur (téléphone, tablette en portrait) : décor portrait */
@media (max-aspect-ratio: 4/5) {
  .decor { background: var(--decor-tel); }
}
.voile { position: fixed; inset: 0; z-index: -1; background: var(--voile); pointer-events: none; }

.coin {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
}
.pastille {
  border: 1px solid var(--carte-bord);
  background: var(--pastille);
  color: var(--texte);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 8px 14px;
  font: 600 14px/1 "Inter", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.pastille:hover { transform: translateY(-1px); }


/* ---------- Mise en page ---------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 72px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.carte {
  background: var(--carte);
  border: 1px solid var(--carte-bord);
  border-radius: 22px;
  box-shadow: var(--carte-ombre);
  backdrop-filter: blur(9px) saturate(1.2);
  -webkit-backdrop-filter: blur(9px) saturate(1.2);
  padding: 22px;
}

/* La carte de jeu passe au-dessus des suivantes (liste de suggestions) */
.carte.jeu { position: relative; z-index: 5; }

/* ---------- En-tête ---------- */
.entete { text-align: center; padding-top: 26px; }
.titre {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: clamp(40px, 10vw, 58px);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  background: linear-gradient(120deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sous-titre { margin: 8px 0 18px; color: var(--texte-doux); }

.onglets {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--surface-bord);
  border-radius: 999px;
  gap: 4px;
}
.onglets button {
  border: 0;
  background: transparent;
  color: var(--texte-doux);
  font: 600 14px/1 "Inter", sans-serif;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.onglets button[aria-selected="true"] {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--surface-bord);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat strong {
  font-family: "Fraunces", Georgia, serif;
  font-size: 26px;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 12px; color: var(--texte-doux); }
.stat-indice { background: var(--indice-fond); border-color: var(--indice-bord); }
.stat-indice strong { color: var(--indice-texte); }
.stat-indice span { color: var(--indice-texte); }

/* ---------- Formulaire ---------- */
.formulaire { display: flex; gap: 8px; }
.champ { position: relative; flex: 1; min-width: 0; }
#saisie {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 2px solid var(--surface-bord);
  background: var(--surface-forte);
  color: var(--texte);
  font: 500 16px "Inter", sans-serif;
  outline: none;
}
#saisie:focus { border-color: var(--accent); }

.bouton {
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  font: 700 16px "Inter", sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(46, 125, 87, 0.3);
}
.bouton:hover { filter: brightness(1.06); }
.bouton:disabled { opacity: 0.5; cursor: default; }
.bouton.secondaire {
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--surface-bord);
  box-shadow: none;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-forte);
  border: 1px solid var(--surface-bord);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  max-height: 320px;
  overflow-y: auto;
}
.suggestions li {
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.suggestions li[aria-selected="true"] { background: var(--surface); outline: 1px solid var(--surface-bord); }
.suggestions .sci { font-size: 12px; color: var(--texte-doux); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestions .deja { font-size: 12px; color: var(--texte-doux); font-style: normal; }
.suggestions li.essaye { opacity: 0.55; }

.message { min-height: 1.5em; margin: 8px 2px 0; font-size: 14px; color: var(--erreur); }

/* ---------- Lignes d'essais ---------- */
.historique, .dernier { margin: 0; padding: 0; list-style: none; }
.dernier:not(:empty) { margin: 6px 0 14px; }
.historique { display: flex; flex-direction: column; gap: 6px; }

.ligne {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-bord);
}
.ligne .num { grid-row: 1 / span 2; font-size: 13px; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.ligne .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .temp { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ligne .temp small { font-weight: 500; color: var(--texte-doux); margin-right: 6px; }
.ligne .temp .palier { transition: opacity 0.4s ease; }
.ligne .temp .valeur { display: inline-block; min-width: 3.2em; text-align: right; }
.ligne .temp.en-cours .palier { opacity: 0; }
.ligne .temp .valeur:empty { display: none; }
.ligne .jauge { grid-column: 2 / span 2; height: 7px; border-radius: 99px; background: var(--jauge-fond); overflow: hidden; }
.ligne .jauge span {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ligne .detail {
  grid-column: 2 / span 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  font-size: 13px;
  color: var(--texte-doux);
}
.ligne .detail .puce {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--jauge-fond);
  color: var(--texte);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ligne .detail .ancetre { flex-basis: 100%; }
.ligne.recent { border-width: 2px; border-color: var(--accent); background: var(--surface-forte); }
.ligne.trouve { border-color: #e4402b; }
.ligne.nouveau { animation: apparition 0.45s ease; }

.etiquette-dernier { font-size: 12px; font-weight: 600; color: var(--texte-doux); margin: 0 0 6px 4px; text-transform: uppercase; letter-spacing: 0.05em; }

@keyframes apparition {
  from { transform: translateY(-6px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Indices ---------- */
.indices { display: flex; flex-direction: column; gap: 8px; }
.indices:not(:empty) { margin-bottom: 14px; }
.indice {
  background: var(--indice-fond);
  border: 1px dashed var(--indice-bord);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--indice-texte);
}
.indice h3 { margin: 0 0 4px; font: 700 13px "Inter", sans-serif; text-transform: uppercase; letter-spacing: 0.06em; }
.indice p { margin: 4px 0 0; color: var(--texte); }
.indice .groupe { font-family: "Fraunces", Georgia, serif; font-size: 20px; font-weight: 700; color: var(--indice-texte); }
.indice .desc { font-style: italic; color: var(--texte-doux); }
/* Indice disponible mais pas encore dévoilé */
.indice.cache { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.indice.cache h3 { margin: 0; }
.indice .voir { height: 38px; padding: 0 16px; font-size: 14px; }

/* ---------- Abandon ---------- */
.bouton.abandon { padding: 0; width: 50px; flex: none; font-size: 20px; }
.confirm-abandon {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--surface-bord);
}
.confirm-abandon[hidden] { display: none; }
.confirm-abandon p { margin: 0; font-size: 14px; }
.confirm-abandon .actions { display: flex; gap: 8px; }
.confirm-abandon .bouton { height: 38px; padding: 0 14px; font-size: 14px; }

/* ---------- Victoire ---------- */
.victoire {
  text-align: center;
  padding: 20px 16px;
  margin: 6px 0 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(46, 125, 87, 0.14), rgba(31, 154, 138, 0.14));
  border: 1px solid var(--surface-bord);
}
.victoire .grand { font-size: 40px; line-height: 1; }
.victoire h2 { font-family: "Fraunces", Georgia, serif; margin: 8px 0 2px; font-size: 26px; }
.victoire .sci { font-style: italic; color: var(--texte-doux); margin: 0 0 10px; }
.victoire .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Règles & pied ---------- */
.regles summary { cursor: pointer; font-weight: 700; }
.regles p, .regles li { color: var(--texte-doux); font-size: 15px; }
.regles ul { padding-left: 20px; }
.regles ul.paliers { list-style: none; padding-left: 4px; margin: 6px 0; }
.regles ul.paliers li { margin: 2px 0; }
.pied { text-align: center; font-size: 13px; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .page { padding-top: 64px; }
  .carte { padding: 16px; border-radius: 18px; }
  .stats { gap: 6px; }
  .stat strong { font-size: 22px; }
  .stat span { font-size: 11px; }
  .bouton { padding: 0 14px; }
  .coin .pastille span { display: none; }
  /* Place pour le nom de l'animal : le palier est déjà donné par l'emoji et la couleur */
  .ligne .temp small { display: none; }
  .ligne { column-gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
