/* === Mes stats =====================================================
   Construite comme Trophées : barre du joueur ou carte d'accès en haut, puis les onglets
   (wipe en cours, wipes passés, parcours global), les catégories à gauche et la catégorie
   choisie à droite. Les lignes viennent du jeu, mises en page comme dans le livret.
   Panneaux sombres, liserés dorés, coins francs. */

.stats-board :is(h2, h3) {
  margin: 0;
  color: var(--parchment);
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-empty {
  margin: 0;
  padding: 40px 20px;
  color: var(--text-soft);
  text-align: center;
}
.stats-empty.is-large {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 50px 20px;
}
.stats-empty.is-large i {
  color: var(--gold);
  font-size: 2rem;
}
.stats-empty.is-large p {
  max-width: 460px;
  margin: 0;
}

/* --- Plateau --- */
.stats-board {
  margin-top: 18px;
}
.stats-board[hidden] {
  display: none;
}

/* Onglets des trois vues */
/* Les quatre onglets sur une ligne, et le bouton « Actualiser » au bout */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stats-tabs {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.stats-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border: 1px solid var(--line-gold);
  background: var(--row-gradient);
  color: var(--text);
  font: 900 0.95rem "Roboto Condensed", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.2s;
}
.is-ready .stats-tabs button {
  animation: rise-in 0.4s ease both;
}
.stats-tabs button:nth-child(2) {
  animation-delay: 0.06s;
}
.stats-tabs button:nth-child(3) {
  animation-delay: 0.12s;
}
.stats-tabs button:nth-child(4) {
  animation-delay: 0.18s;
}
.stats-tabs button i {
  color: var(--gold);
}
.stats-tabs button:hover {
  border-color: rgba(var(--gold-rgb), 0.6);
  transform: translateY(-2px);
}
.stats-tabs button[aria-selected="true"] {
  border-color: var(--red);
  background: linear-gradient(160deg, rgba(var(--red-rgb), 0.6), rgba(90, 22, 18, 0.75));
  color: var(--parchment);
}
.stats-tabs button[aria-selected="true"] i {
  color: var(--parchment);
}

/* Wipes archivés */
/* Catégories à gauche, catégorie choisie à droite */
.stats-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}
.stats-layout.is-empty {
  grid-template-columns: minmax(0, 1fr);
}
.stats-layout.is-empty .stats-menu {
  display: none;
}
/* Le menu : la pièce commune (packages/ui/css/side-menu.css) ; ici, son apparition en cascade */
.stats-menu button {
  animation: rise-in 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 25ms);
}

.stats-panel {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line-gold);
  background: var(--panel-gradient);
  transform: perspective(1400px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.35s ease;
}
.stats-panel.is-entering > * {
  animation: rise-in 0.35s ease both;
}
.stats-panel__head {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-gold);
}
/* Un trait doré court sous le titre à chaque ouverture */
.stats-panel__head:after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
  transform-origin: left;
}
.is-entering .stats-panel__head:after {
  animation: st-draw 0.6s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

/* Tri */
.stats-sort {
  display: flex;
  gap: 4px;
}
.stats-sort button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line-gold);
  background: var(--row-gradient);
  color: var(--text-soft);
  font: 700 0.8rem "Roboto Condensed", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 0.2s,
    color 0.2s;
}
.stats-sort button:hover {
  border-color: rgba(var(--gold-rgb), 0.6);
  color: var(--parchment);
}
.stats-sort button[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--parchment);
  box-shadow: inset 0 -2px var(--gold);
}
.stats-sort i {
  color: var(--gold);
}
.stats-panel__head h2 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
}
.stats-panel__head p {
  margin: 4px 0 0;
  color: var(--text-soft);
}

/* Une ligne de stat */
.stat-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stat-row {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line-gold);
  background: var(--row-gradient);
  transition:
    border-color 0.2s,
    transform 0.2s;
}
.is-entering .stat-row {
  animation: rise-in 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 20ms);
}
.stat-row:hover {
  border-color: rgba(var(--gold-rgb), 0.55);
  transform: translateX(3px);
}
.stat-row:after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(var(--parchment-rgb), 0.07) 50%, transparent 65%);
  transform: translateX(-100%);
}
.stat-row:hover:after {
  transform: translateX(100%);
  transition: transform 0.7s ease;
}
.stat-row__value {
  font-variant-numeric: tabular-nums;
}
.stat-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.stat-row__label {
  color: var(--text);
  font-size: 0.95rem;
}
.stat-row__value {
  color: var(--parchment);
  font: 900 1.15rem "Roboto Condensed", sans-serif;
  text-align: right;
}

/* Une arme : sa fiche, comme dans le livret */
.weapon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.weapon-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line-gold);
  background: var(--row-gradient);
  transition:
    border-color 0.2s,
    transform 0.2s;
}
.is-entering .weapon-card {
  animation: rise-in 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.weapon-card:hover {
  border-color: rgba(var(--gold-rgb), 0.55);
  transform: translateY(-2px);
}
.weapon-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.weapon-card__image {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line-gold);
  background: rgba(var(--shadow-rgb), 0.3);
}
.weapon-card__icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.weapon-card h3 {
  font-size: 1.05rem;
}
.weapon-card__head small {
  color: var(--gold);
  font: 700 0.8rem "Roboto Condensed", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.weapon-card__numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}
.weapon-card__numbers div {
  padding: 6px 8px;
  background: rgba(var(--shadow-rgb), 0.25);
}
.weapon-card__numbers dt {
  color: var(--text-soft);
  font: 700 0.8rem "Roboto Condensed", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.weapon-card__numbers dd {
  margin: 2px 0 0;
  color: var(--parchment);
  font: 900 1rem "Roboto Condensed", sans-serif;
}
.weapon-bar {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.82rem;
}
.weapon-bar strong {
  color: var(--parchment);
  text-align: right;
}
.weapon-bar__track i {
  width: var(--fill, 0%);
  animation: fill-bar 0.9s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

/* Les icônes que le livret teint (silhouettes d'interface) : en crème sur le site. Les autres
   (objets, avatars de PNJ, véhicules) gardent leurs couleurs, comme en jeu. */
.stats-page img.is-tinted {
  filter: brightness(0) invert(0.9) sepia(0.25);
}

.stat-icon.is-empty,
.weapon-card__icon.is-empty {
  display: block;
}
.stats-page img.is-missing {
  visibility: hidden;
}

/* --- Petits écrans --- */
@media (max-width: 900px) {
  .stats-layout {
    grid-template-columns: 1fr;
  }
  .stats-menu {
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .stats-menu button {
    flex: none;
    grid-template-columns: auto;
  }
  .stats-menu small {
    display: none;
  }
}

@media (max-width: 620px) {
  .stats-tabs {
    grid-template-columns: 1fr;
  }
  .stats-sort span {
    display: none;
  }
  .weapon-card__numbers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats-page *,
  .stats-page *::before,
  .stats-page *::after {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes st-draw {
  from {
    transform: scaleX(0);
  }
}

.stat-rows + .weapon-grid {
  margin-top: 16px;
}

/* === Se comparer ================================================== */
.stats-compare {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line-gold);
  background: var(--panel-gradient);
}
.stats-compare[hidden] {
  display: none;
}
.compare-picker {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px 24px;
}
/* Sans team : la recherche prend la place, la team n'est qu'une ligne dessous */
.compare-picker.is-alone {
  grid-template-columns: minmax(0, 1fr);
}
.compare-picker.is-alone .compare-picker__team {
  display: flex;
  align-items: center;
  gap: 12px;
}
.compare-picker__friend small {
  display: flex;
  align-items: center;
  gap: 8px;
}
.compare-picker__friend small i {
  color: var(--gold);
}
.compare-picker__team,
.compare-picker__friend {
  display: grid;
  align-content: start;
  gap: 8px;
}
.compare-picker__mates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.compare-mate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line-gold);
  background: var(--row-gradient);
  color: var(--parchment);
  font: 700 0.9rem Roboto, sans-serif;
  cursor: pointer;
}
.compare-mate img,
.compare-mate > i:first-child {
  width: 28px;
  height: 28px;
  object-fit: cover;
}
.compare-mate[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold);
}
.compare-mate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.compare-mate .fa-lock {
  color: var(--text-soft);
  font-size: 0.8rem;
}
.compare-picker__empty,
.compare-picker__friend small {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}
.compare-picker__friend > div {
  display: flex;
  gap: 8px;
}
.compare-picker__friend input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-gold);
  background: #0e0d0b;
  color: var(--parchment);
  font: 400 0.95rem Roboto, sans-serif;
}
.compare-picker__error {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--red-text);
}
.compare-picker__views {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
}
.compare-picker__views button {
  padding: 8px 14px;
  border: 1px solid var(--line-gold);
  background: #15130f;
  color: var(--text-soft);
  font: 900 0.8rem "Roboto Condensed", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.compare-picker__views button[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--parchment);
}
.compare-picker__views button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Les deux joueurs, puis une ligne par stat : ma valeur | libellé | la sienne */
.compare-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.compare-head h2 {
  margin: 0;
  color: var(--parchment);
  font: 900 1.2rem "Roboto Condensed", sans-serif;
  text-transform: uppercase;
}
.compare-head__player {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--parchment);
}
.compare-head__player.is-other {
  justify-content: flex-end;
}
.compare-head__player img,
.compare-head__player > i {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid var(--line-gold);
}
.compare-rows {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.compare-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 1.2fr) 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid rgba(var(--gold-rgb), 0.14);
  background: var(--row-gradient);
}
.compare-row__label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
  text-align: center;
}
.compare-row__label .stat-icon {
  width: 26px;
  height: 26px;
}
.compare-row__label small {
  color: var(--text-soft);
}
.compare-row__value {
  display: grid;
  gap: 5px;
}
.compare-row__value strong {
  color: var(--text);
  font: 900 1.05rem "Roboto Condensed", sans-serif;
}
.compare-row__value i {
  display: block;
  width: var(--fill);
  height: 3px;
  background: #5c4a33;
}
.compare-row__value strong {
  color: var(--parchment);
}
.compare-row__value.is-me i {
  background: var(--gold);
}
.compare-row__value.is-other i {
  background: #d8cbb0;
}
/* Ma barre part du centre vers la gauche, la sienne vers la droite */
.compare-row__value:first-child {
  justify-items: end;
  text-align: right;
}
@media (max-width: 760px) {
  .compare-picker {
    grid-template-columns: 1fr;
  }
  .compare-row {
    grid-template-columns: 1fr 1fr;
  }
  .compare-row__label {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

/* Le résumé de la vue : six chiffres sur une ligne */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 12px;
  border: 1px solid var(--line-gold);
  background: var(--panel-gradient);
}
.stats-summary[hidden] {
  display: none;
}
.stats-summary > div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 16px 18px;
  border-left: 1px solid rgba(var(--gold-rgb), 0.16);
}
.stats-summary > div:first-child {
  border-left: 0;
}
.stats-summary > div > i,
.stats-summary__weapon {
  flex: none;
  width: 28px;
  color: var(--gold);
  font-size: 1.35rem;
  text-align: center;
}
.stats-summary__weapon {
  height: 28px;
  object-fit: contain;
}
.stats-summary span {
  min-width: 0;
}
.stats-summary small {
  display: block;
  color: var(--text-soft);
  font: 700 0.8rem Roboto, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stats-summary b {
  display: block;
  overflow: hidden;
  color: var(--parchment);
  font: 900 1.35rem "Roboto Condensed", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .stats-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .stats-summary > div:nth-child(4) {
    border-left: 0;
  }
}
@media (max-width: 700px) {
  .stats-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-summary > div {
    border-left: 0;
  }
}

/* Des onglets plus sobres : l'actif ressort, les autres sans cadre plein */
.stats-tabs button {
  border-color: transparent;
  border-bottom-color: var(--line-gold);
  background: rgba(var(--shadow-rgb), 0.22);
}
.stats-tabs button:hover {
  border-color: transparent;
  border-bottom-color: var(--gold);
  transform: none;
}
.stats-period {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  text-align: right;
}
.stats-period:empty {
  display: none;
}
.stats-summary b.is-muted {
  color: var(--text-soft);
  font-size: 1.05rem;
}

/* Le menu : la recherche, la vue d'ensemble, les familles repliables */
/* La vue d'ensemble : des cartes */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.stats-card {
  padding: 16px 18px;
  border: 1px solid rgba(var(--gold-rgb), 0.2);
  background: rgba(var(--shadow-rgb), 0.18);
}
.stats-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--parchment);
  font: 900 1.05rem "Roboto Condensed", sans-serif;
  text-transform: uppercase;
}
.stats-card h3 i {
  color: var(--gold);
}
.stats-card__empty {
  margin: 0;
  color: var(--text-soft);
}
.stats-top {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stats-top li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.stats-top__icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  padding: 4px;
  background: rgba(var(--shadow-rgb), 0.35);
}
.stats-top span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--parchment);
}
.stats-top strong small {
  color: var(--text-soft);
  font-weight: 400;
}
.stats-top i {
  position: relative;
  display: block;
  height: 6px;
  margin-top: 6px;
  background: var(--well);
  box-shadow: var(--well-shadow);
}
.stats-top i::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill);
  background: var(--gold);
  box-shadow: var(--fill-shadow);
}
.stats-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stats-facts li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stats-facts > li > i,
.stats-facts__icon {
  flex: none;
  width: 26px;
  height: 26px;
  color: var(--gold);
  font-size: 1.2rem;
  text-align: center;
  object-fit: contain;
}
.stats-facts small {
  display: block;
  margin-bottom: 2px;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.3;
}
.stats-facts b {
  color: var(--parchment);
  font: 900 1.2rem "Roboto Condensed", sans-serif;
}
@media (max-width: 900px) {
  .stats-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Ce wipe face au précédent */
.stats-previous {
  margin-top: 14px;
}
.stats-previous h3 {
  flex-wrap: wrap;
}
.stats-previous__modes {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}
.stats-previous__modes button {
  padding: 6px 12px;
  border: 1px solid var(--line-gold);
  background: transparent;
  color: var(--text);
  font: 700 0.8rem Roboto, sans-serif;
  text-transform: none;
  cursor: pointer;
}
.stats-previous__modes button[aria-pressed="true"] {
  border-color: var(--red);
  background: linear-gradient(160deg, rgba(var(--red-rgb), 0.6), rgba(90, 22, 18, 0.75));
  color: var(--parchment);
}
.stats-previous table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.stats-previous th,
.stats-previous td {
  padding: 8px 10px;
  border-top: 1px solid rgba(var(--gold-rgb), 0.12);
  color: var(--text);
  text-align: center;
}
.stats-previous thead th {
  border-top: 0;
  color: var(--text-soft);
  font: 700 0.8rem Roboto, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stats-previous tbody th {
  text-align: left;
  font-weight: 400;
}
.stats-previous tbody th i {
  width: 22px;
  margin-right: 8px;
  color: var(--gold);
}
.stats-previous td b {
  color: var(--parchment);
}
.stats-previous td i {
  margin-right: 4px;
  color: var(--gold);
}

/* Un petit libellé au-dessus d'un champ (Se comparer) */
.stats-label {
  color: var(--text-soft);
  font: 900 0.8rem "Roboto Condensed", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
