/* ============================================================
   Classement Tarot — feuille de style
   Direction : le classement FFT est bâti sur les enseignes du jeu
   (1P/1C/1K/1T = Pique, Cœur, Carreau, Trèfle). Le vocabulaire
   visuel vient donc de la table de jeu : feutre vert, carte ivoire,
   rouge et noir des enseignes. Lecture prioritaire sur l'esthétique :
   public 60-80 ans, corps de texte à 17px, contrastes AA partout.
   ============================================================ */

:root {
  color-scheme: light;

  /* Surfaces */
  --feutre:      #1F4D3D;   /* vert de table */
  --feutre-fonce:#163A2D;
  --feutre-clair:#2E6B55;
  --ivoire:      #FAF7EF;   /* face de carte */
  --papier:      #F1EDE2;   /* fond de page */
  --carte:       #FFFFFF;

  /* Encres */
  --encre:       #1A1714;
  --encre-2:     #4A443C;
  --encre-3:     #6E675C;
  --trait:       #DED7C6;
  --trait-fort:  #C4BBA5;

  /* Enseignes */
  --rouge:       #B3221F;   /* Cœur, Carreau */
  --noir:        #23201C;   /* Pique, Trèfle */
  --laiton:      #9A6E1C;   /* 1ère série nationale */

  /* Séries pour les courbes — palette catégorielle validée
     (bandes de clarté, plancher de chroma, séparation daltonisme,
     contraste ≥ 3:1 sur fond clair) */
  --s1: #2F6BCE;
  --s2: #C8501C;
  --s3: #128A6B;
  --s4: #9A3FA2;
  --s5: #AC7E17;
  --s6: #B03A63;

  /* États */
  --hausse:      #12694F;
  --baisse:      #A63228;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --ombre: 0 1px 2px rgba(26,23,20,.06), 0 8px 24px -12px rgba(26,23,20,.18);
  --ombre-fort: 0 2px 4px rgba(26,23,20,.08), 0 18px 40px -18px rgba(26,23,20,.30);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: Bitter, Georgia, "Times New Roman", serif; font-weight: 700; line-height: 1.2; margin: 0; }

.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--feutre); color: #fff; padding: .75rem 1rem; border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--laiton);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------- en-tête */
.site-header { background: var(--feutre); color: var(--ivoire); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .85rem; }
.brand-mark { width: 44px; height: 44px; flex: none; }
.site-header h1 { font-size: 1.45rem; letter-spacing: -.01em; }
.brand-sub { margin: .1rem 0 0; font-size: .84rem; color: #C8DACF; letter-spacing: .04em; text-transform: uppercase; }
.header-meta { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.pill {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
  padding: .35rem .8rem; border-radius: 999px; font-size: .88rem; white-space: nowrap;
}

/* ---------------------------------------------------- onglets */
.tabs { background: var(--feutre-fonce); position: sticky; top: 0; z-index: 20; box-shadow: var(--ombre); }
.tabs-inner { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.tabs-inner::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: #BFD3C9; font: inherit; font-weight: 500; font-size: .98rem;
  padding: .95rem 1.1rem; min-height: 48px; white-space: nowrap;
  border-bottom: 3px solid transparent; transition: color .18s ease, border-color .18s ease, background-color .18s ease;
}
.tab:hover { color: #fff; background: rgba(255,255,255,.06); }
.tab.is-active { color: #fff; border-bottom-color: var(--laiton); }

/* ---------------------------------------------------- blocs */
main { padding: 1.75rem 0 3rem; }
.view { display: block; }
[hidden] { display: none !important; }

.card {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre);
  padding: 1.35rem;
  margin-bottom: 1.35rem;
}
.card-head { margin-bottom: 1.1rem; }
.card-head h2 { font-size: 1.22rem; }
.card-sub { margin: .3rem 0 0; color: var(--encre-2); font-size: .95rem; }

/* ---------------------------------------------------- recherche */
.searchbar { margin-bottom: 1.5rem; position: relative; }
.searchbar > label { display: block; font-weight: 600; margin-bottom: .45rem; font-size: 1.02rem; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field .ico {
  position: absolute; left: 1rem; width: 22px; height: 22px;
  fill: none; stroke: var(--encre-3); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
#q {
  width: 100%; font: inherit; font-size: 1.1rem; padding: .9rem 1rem .9rem 3rem;
  min-height: 54px; border: 2px solid var(--trait-fort); border-radius: var(--r-md);
  background: var(--carte); color: var(--encre); transition: border-color .18s ease, box-shadow .18s ease;
}
#q:focus { border-color: var(--feutre); box-shadow: 0 0 0 4px rgba(31,77,61,.14); outline: none; }
.hint { margin: .55rem 0 0; color: var(--encre-2); font-size: .93rem; }

.suggest {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% - .3rem);
  margin: 0; padding: .35rem; list-style: none; max-height: 380px; overflow-y: auto;
  background: var(--carte); border: 1px solid var(--trait-fort); border-radius: var(--r-md); box-shadow: var(--ombre-fort);
}
.suggest li { padding: 0; }
.suggest button {
  display: flex; gap: .75rem; align-items: center; width: 100%; text-align: left;
  font: inherit; background: none; border: 0; cursor: pointer; padding: .7rem .8rem;
  border-radius: var(--r-sm); min-height: 48px; transition: background-color .15s ease;
}
.suggest button:hover, .suggest button.is-cursor { background: var(--papier); }
.suggest .s-nom { font-weight: 600; }
.suggest .s-meta { color: var(--encre-2); font-size: .9rem; }

/* ---------------------------------------------------- badge de série (élément signature) */
.serie {
  display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 600; font-size: .95rem; line-height: 1;
  padding: .4rem .6rem .4rem .45rem;
  background: var(--ivoire); border: 1.5px solid var(--trait-fort);
  border-radius: 4px 4px 4px 4px; white-space: nowrap;
  box-shadow: inset 0 0 0 1.5px var(--carte);
}
.serie .ens { font-size: 1.15em; line-height: 1; }
.serie[data-couleur="C"] .ens, .serie[data-couleur="K"] .ens { color: var(--rouge); }
.serie[data-couleur="P"] .ens, .serie[data-couleur="T"] .ens { color: var(--noir); }
.serie[data-couleur="N"] { border-color: var(--laiton); background: #FBF3DF; }
.serie[data-couleur="N"] .ens { color: var(--laiton); }
.serie-lg { font-size: 1.3rem; padding: .55rem .8rem .55rem .6rem; border-radius: 6px; }

/* ---------------------------------------------------- fiche joueur */
.fiche {
  background: var(--carte); border: 1px solid var(--trait); border-left: 6px solid var(--accent, var(--feutre));
  border-radius: var(--r-lg); box-shadow: var(--ombre); padding: 1.35rem; margin-bottom: 1.35rem;
}
.fiche-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.fiche-nom { font-size: 1.35rem; }
.fiche-meta { color: var(--encre-2); font-size: .96rem; margin: .2rem 0 0; }
.fiche-actions { display: flex; gap: .5rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: .85rem; margin-top: 1.1rem; }
.stat {
  background: var(--ivoire); border: 1px solid var(--trait); border-radius: var(--r-md); padding: .8rem .9rem;
}
.stat-k { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--encre-3); font-weight: 600; }
.stat-v { font-family: Bitter, Georgia, serif; font-size: 1.85rem; font-weight: 700; line-height: 1.15; margin-top: .15rem; }
.stat-n { font-size: .88rem; color: var(--encre-2); }
.delta { font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; gap: .25rem; }
.delta[data-sens="+"] { color: var(--hausse); }
.delta[data-sens="-"] { color: var(--baisse); }
.delta[data-sens="="] { color: var(--encre-3); }

/* jauge vers l'objectif */
.objectif { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--trait); }
.objectif h4 { margin: 0 0 .5rem; font-size: 1rem; font-family: inherit; font-weight: 600; }
.jauge { position: relative; height: 30px; background: var(--papier); border: 1px solid var(--trait); border-radius: 999px; overflow: hidden; }
.jauge-fill { height: 100%; background: var(--accent, var(--feutre)); border-radius: 999px; transition: width .5s ease; }
.jauge-txt { margin-top: .5rem; font-size: .96rem; color: var(--encre-2); }
.jauge-txt strong { color: var(--encre); }

/* ---------------------------------------------------- bandes de PP dans le bloc de série */
.bandes {
  display: flex; flex-direction: column; gap: 1px; background: var(--trait);
  border: 1px solid var(--trait); border-radius: var(--r-sm); overflow: hidden; margin: .85rem 0;
}
.bande {
  display: grid; grid-template-columns: 84px 1fr auto; gap: .75rem; align-items: baseline;
  padding: .5rem .8rem; background: var(--carte); font-size: .95rem;
}
.bande.is-moi { background: #FBF3DF; font-weight: 600; box-shadow: inset 4px 0 0 var(--laiton); }
.bande-pp { font-family: Bitter, Georgia, serif; font-weight: 700; font-variant-numeric: tabular-nums; }
.bande-rang { color: var(--encre-2); font-variant-numeric: tabular-nums; }
.bande-n { color: var(--encre-3); font-size: .9rem; text-align: right; }
.objectif + .objectif { margin-top: 1.1rem; }

/* ---------------------------------------------------- chips favoris */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.chip {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 44px;
  background: var(--carte); border: 1px solid var(--trait-fort); border-left: 5px solid var(--accent, var(--feutre));
  border-radius: 999px; padding: .3rem .35rem .3rem .8rem; font-size: .96rem; font-weight: 500;
}
.chip button {
  appearance: none; border: 0; background: var(--papier); cursor: pointer; color: var(--encre-2);
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; line-height: 1;
  transition: background-color .15s ease, color .15s ease;
}
.chip button:hover { background: var(--rouge); color: #fff; }

/* ---------------------------------------------------- filtres */
.filters {
  display: flex; flex-wrap: wrap; gap: .85rem; align-items: flex-end;
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r-lg);
  padding: 1.1rem; margin-bottom: 1.25rem; box-shadow: var(--ombre);
}
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 160px; }
.field-grow { flex: 1 1 260px; }
.field label { font-weight: 600; font-size: .92rem; }
.field select, .field input[type="search"] {
  font: inherit; padding: .6rem .7rem; min-height: 48px; border: 2px solid var(--trait-fort);
  border-radius: var(--r-sm); background: var(--carte); color: var(--encre); max-width: 100%;
}
.field select:focus, .field input:focus { border-color: var(--feutre); outline: none; box-shadow: 0 0 0 3px rgba(31,77,61,.14); }
.field-check { justify-content: center; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; min-height: 48px; }
.check input { width: 22px; height: 22px; accent-color: var(--feutre); cursor: pointer; }
.result-count { margin: 0 0 .8rem; color: var(--encre-2); font-weight: 500; }

/* ---------------------------------------------------- boutons */
.btn {
  appearance: none; font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: .55rem 1rem; border-radius: var(--r-sm);
  border: 2px solid var(--trait-fort); background: var(--carte); color: var(--encre);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.btn:hover { border-color: var(--feutre); background: var(--ivoire); }
.btn-primary { background: var(--feutre); border-color: var(--feutre); color: #fff; }
.btn-primary:hover { background: var(--feutre-clair); border-color: var(--feutre-clair); color: #fff; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.4); color: inherit; }
.tabs .btn-ghost, .site-header .btn-ghost { color: var(--ivoire); }
.site-header .btn-ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.7); }
.btn-sm { min-height: 38px; padding: .35rem .7rem; font-size: .9rem; }

/* ---------------------------------------------------- tableaux */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .97rem; }
table.data th, table.data td { padding: .7rem .65rem; text-align: left; border-bottom: 1px solid var(--trait); white-space: nowrap; }
table.data thead th {
  position: sticky; top: 0; background: var(--ivoire); font-weight: 600; font-size: .88rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--encre-2); border-bottom: 2px solid var(--trait-fort); z-index: 1;
}
table.sortable thead th[data-sort] { cursor: pointer; user-select: none; }
table.sortable thead th[data-sort]:hover { color: var(--feutre); }
table.sortable thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
table.sortable thead th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
table.data tbody tr:hover { background: var(--ivoire); }
table.data tbody tr.is-moi { background: #FBF3DF; }
table.data tbody tr.is-moi td { font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nom { white-space: normal; min-width: 180px; font-weight: 500; }
.rang-cell { font-family: Bitter, Georgia, serif; font-weight: 700; font-size: 1.05rem; }
.pager { display: flex; justify-content: center; padding-top: 1rem; }

/* ---------------------------------------------------- graphiques */
.chart-card { padding-bottom: 1rem; }
.chart { width: 100%; overflow: visible; display: block; }
.chart .grid { stroke: var(--trait); stroke-width: 1; }
.chart .axis-line { stroke: var(--trait-fort); stroke-width: 1.5; }
.chart text { font-family: "IBM Plex Sans", sans-serif; font-size: 13px; fill: var(--encre-2); }
.chart .tick { font-size: 12.5px; fill: var(--encre-3); }
.chart .serie-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .serie-dot { stroke: var(--carte); stroke-width: 2; }
.chart .lbl-direct { font-weight: 600; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin-top: .9rem; }
.legend-item { display: inline-flex; align-items: center; gap: .45rem; font-size: .93rem; }
.legend-swatch { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.chart-note { margin: .8rem 0 0; font-size: .92rem; color: var(--encre-2); }

.bars { display: flex; flex-direction: column; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1.4fr) 1fr auto; gap: .75rem; align-items: center; font-size: .95rem; }
.bar-track { display: block; background: var(--papier); border-radius: 999px; height: 22px; overflow: hidden; border: 1px solid var(--trait); }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-val { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: right; }
.bar-row.is-moi .bar-lbl { font-weight: 700; }

/* échelle des séries */
.echelle-blocs { display: flex; flex-direction: column; gap: 1.1rem; margin-top: .5rem; }
.bloc-serie { border: 1px solid var(--trait); border-radius: var(--r-md); overflow: hidden; }
.bloc-serie.is-moi { border-color: var(--laiton); box-shadow: 0 0 0 2px rgba(154,110,28,.18); }
.bloc-titre {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  margin: 0; padding: .7rem .9rem; background: var(--feutre); color: #fff; font-size: 1.05rem;
}
.bloc-seuil { font-family: "IBM Plex Sans", sans-serif; font-weight: 500; font-size: .88rem; color: #C8DACF; }
.echelons { display: flex; flex-direction: column; gap: 1px; background: var(--trait); }
.echelon {
  display: grid; grid-template-columns: 74px 1fr auto; gap: .75rem; align-items: center;
  padding: .55rem .9rem; background: var(--carte);
}
.echelon.is-moi { background: #FBF3DF; box-shadow: inset 4px 0 0 var(--laiton); font-weight: 600; }
.echelon-seuil { font-size: .9rem; color: var(--encre-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------- états vides */
.empty { text-align: center; padding: 3rem 1rem; color: var(--encre-2); }
.empty h2 { font-size: 1.25rem; color: var(--encre); margin-bottom: .4rem; }
.empty-art { width: 64px; height: 64px; fill: none; stroke: var(--trait-fort); stroke-width: 2; margin-bottom: .8rem; }
.callout {
  background: var(--ivoire); border: 1px solid var(--trait-fort); border-left: 5px solid var(--laiton);
  border-radius: var(--r-md); padding: 1rem 1.1rem; margin: 1rem 0;
}
.callout h4 { margin: 0 0 .35rem; font-size: 1rem; font-family: inherit; }
.callout p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------- simulateur */
.simu { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.simu-out {
  margin-top: 1.1rem; background: var(--feutre); color: #fff; border-radius: var(--r-md); padding: 1.1rem 1.2rem;
}
.simu-out .stat-v { color: #fff; }
.simu-out .stat-k, .simu-out .stat-n { color: #C8DACF; }

/* ---------------------------------------------------- dialogue */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; max-width: min(640px, calc(100vw - 2rem)); box-shadow: var(--ombre-fort); }
dialog::backdrop { background: rgba(22,58,45,.55); }
.dlg-inner { padding: 1.5rem; }
.dlg-inner h2 { font-size: 1.3rem; margin-bottom: .8rem; }
.dlg-inner h3 { font-size: 1.05rem; margin: 1.2rem 0 .3rem; }
.dlg-inner p { margin: .4rem 0; }
.dlg-inner form { margin-top: 1.4rem; }

/* ---------------------------------------------------- pied de page */
.site-footer { background: var(--feutre-fonce); color: #C8DACF; padding: 1.6rem 0 2.2rem; font-size: .93rem; }
.site-footer strong { color: var(--ivoire); }
.footnote { color: #9DB5AA; font-size: .87rem; }

/* ---------------------------------------------------- responsive */
@media (max-width: 720px) {
  .bande { grid-template-columns: 68px 1fr; }
  .bande-n { grid-column: 2; text-align: left; }
  body { font-size: 16px; }
  .site-header h1 { font-size: 1.2rem; }
  .stat-v { font-size: 1.55rem; }
  .fiche, .card { padding: 1.1rem; }
  .bar-row { grid-template-columns: minmax(90px, 1fr) 1.2fr auto; font-size: .9rem; }
  .echelon { grid-template-columns: 64px 1fr; }
  .echelon-seuil { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .tabs, .searchbar, .filters, .fiche-actions, .pager, .btn { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card, .fiche { box-shadow: none; break-inside: avoid; }
}
