/* Thème commun My LFBB : couleurs, dégradés et animations (chargé après le style de chaque page) */
:root {
  --brand: #c2003f;
  --brand-2: #ff6b3d;
  --brand-grad: linear-gradient(135deg, #b0003a 0%, #e0224e 45%, #ff6b3d 100%);
  --bg: #fbf6f7;
  --card: #ffffff;
  --text: #1f1a24;
  --muted: #76707f;
  --border: #eee3e6;
  --accent: #d1144a;
  --win: #14a36b;
  --loss: #e23d4f;
  --draw: #d98a0b;
  --chip: #fbeef1;
  --shadow: 0 1px 2px rgba(80, 0, 30, .06), 0 6px 20px rgba(80, 0, 30, .07);
  --shadow-hover: 0 4px 10px rgba(80, 0, 30, .10), 0 16px 36px rgba(80, 0, 30, .14);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #140f14;
    --card: #1f1820;
    --text: #f3ecf1;
    --muted: #a99fac;
    --border: #33283a;
    --accent: #ff5c85;
    --win: #34d399;
    --loss: #ff6b7a;
    --draw: #f5b544;
    --chip: #2b2030;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-hover: 0 4px 10px rgba(0, 0, 0, .5), 0 16px 36px rgba(0, 0, 0, .5);
  }
}

body {
  background:
    radial-gradient(1200px 400px at 100% -10%, color-mix(in srgb, var(--brand-2) 14%, transparent), transparent 70%),
    radial-gradient(900px 400px at -10% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---------- Menu ---------- */
.nav {
  background: var(--brand-grad);
  border-bottom: 0;
  box-shadow: 0 4px 18px rgba(176, 0, 58, .25);
  animation: slideDown .5s cubic-bezier(.2, .8, .2, 1) both;
}
.nav .brand { color: #fff; font-size: 1.1rem; letter-spacing: .01em; display: inline-flex; align-items: center; gap: 6px; }
.nav .brand::first-letter { display: inline-block; }
.nav a { color: rgba(255, 255, 255, .82); transition: background .2s, color .2s, transform .2s; }
.nav a:hover { background: rgba(255, 255, 255, .16); color: #fff; transform: translateY(-1px); }
.nav a.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
@media (prefers-color-scheme: dark) { .nav a.active { background: rgba(255, 255, 255, .95); } }

/* ---------- Titres ---------- */
h1 {
  font-size: 2rem !important;
  font-weight: 800;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeUp .5s .05s both;
}
.sub { animation: fadeUp .5s .1s both; }
h2 { animation: fadeUp .4s both; }

/* ---------- Champs & boutons ---------- */
input, select {
  border: 1.5px solid var(--border) !important;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
button {
  background: var(--brand-grad) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(209, 20, 74, .3);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(209, 20, 74, .35); filter: brightness(1.05); }
button:active:not(:disabled) { transform: translateY(0) scale(.97); }
form, .bar { animation: fadeUp .5s .15s both; }

/* ---------- Cartes ---------- */
.card, .stat, .rencontre, .wrap, .results, table {
  border-radius: 14px !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow);
}
.card, .stat, .rencontre, .results li {
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s, border-color .25s;
}
.card:hover, .stat:hover, .rencontre:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card { position: relative; overflow: hidden; }
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-grad);
  transform: scaleX(0); transform-origin: left; transition: transform .35s;
}
.card:hover::before, .card.active::before { transform: scaleX(1); }
.card.active { border-color: var(--accent) !important; box-shadow: 0 0 0 1.5px var(--accent), var(--shadow-hover); }

.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%;
  background: var(--brand-grad); opacity: .08;
}
.stat b { font-size: 1.8rem !important; }

/* Entrées en cascade */
.card, .stat, .rencontre, .results li, tbody tr { animation: fadeUp .45s cubic-bezier(.2, .8, .2, 1) both; }
.grid > :nth-child(2), .summary > :nth-child(2), #list > :nth-child(2), .results li:nth-child(2) { animation-delay: .06s; }
.grid > :nth-child(3), .summary > :nth-child(3), #list > :nth-child(3), .results li:nth-child(3) { animation-delay: .12s; }
.summary > :nth-child(4), #list > :nth-child(4), .results li:nth-child(4) { animation-delay: .18s; }
#list > :nth-child(5), .results li:nth-child(5) { animation-delay: .24s; }
#list > :nth-child(6) { animation-delay: .30s; }
#list > :nth-child(7) { animation-delay: .36s; }
#list > :nth-child(8) { animation-delay: .42s; }
#list > :nth-child(n+9) { animation-delay: .48s; }
tbody tr:nth-child(2) { animation-delay: .03s; } tbody tr:nth-child(3) { animation-delay: .06s; }
tbody tr:nth-child(4) { animation-delay: .09s; } tbody tr:nth-child(5) { animation-delay: .12s; }
tbody tr:nth-child(6) { animation-delay: .15s; } tbody tr:nth-child(7) { animation-delay: .18s; }
tbody tr:nth-child(8) { animation-delay: .21s; } tbody tr:nth-child(9) { animation-delay: .24s; }
tbody tr:nth-child(n+10) { animation-delay: .27s; }

/* ---------- Tableaux ---------- */
table { overflow: hidden; }
.wrap table, .detail table { box-shadow: none; border-radius: 0 !important; }
th { background: var(--chip) !important; color: var(--muted); text-transform: uppercase; font-size: .72rem !important; letter-spacing: .05em; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
tfoot th { text-transform: none; font-size: .9rem !important; color: var(--text); }
a { transition: color .15s; }

/* ---------- Chiffres & badges ---------- */
.avg, .new, .score {
  background: var(--brand-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.avg { font-size: 2.6rem !important; font-weight: 800 !important; animation: pop .6s .25s cubic-bezier(.2, 1.4, .4, 1) both; display: inline-block; }
.arrow { animation: nudge 1.6s ease-in-out infinite; display: inline-block; }
.diff, .badge { animation: pop .5s .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.diff.up, .badge.v { color: #fff !important; background: linear-gradient(135deg, #0f9d63, #34c98a) !important; }
.diff.down, .badge.d { color: #fff !important; background: linear-gradient(135deg, #d42a44, #ff6b6b) !important; }
.badge.n { color: #fff !important; background: linear-gradient(135deg, #d98a0b, #f5b544) !important; }
.level, .lvl { background: color-mix(in srgb, var(--accent) 12%, transparent) !important; color: var(--accent) !important; font-weight: 600; }
.pts.pos { color: var(--win) !important; }
.pts.zero { color: var(--loss) !important; opacity: .8; }
.dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); animation: pop .4s .3s both; }
.dot.v { background: var(--win) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--win) 20%, transparent); }
.dot.d { background: var(--loss) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--loss) 20%, transparent); }

/* Interclubs : liseré coloré selon le résultat */
.rencontre { border-left: 5px solid var(--border) !important; }
.rencontre:has(.badge.v) { border-left-color: var(--win) !important; }
.rencontre:has(.badge.d) { border-left-color: var(--loss) !important; }
.rencontre:has(.badge.n) { border-left-color: var(--draw) !important; }
.detail:not([hidden]) { animation: open .35s ease both; }
.toggle { font-weight: 600; }

/* ---------- Chargement : volant qui rebondit ---------- */
.msg:not(.err):not(:empty):not([hidden]) { display: flex; align-items: center; gap: 10px; }
.msg:not(.err):not(:empty)::before {
  content: "🏸"; display: inline-block; font-size: 1.3rem;
  animation: shuttle 1s ease-in-out infinite;
}
.msg.err { background: color-mix(in srgb, var(--loss) 10%, transparent); padding: 10px 14px; border-radius: 10px; animation: shake .4s both; }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 100% { opacity: 1; transform: scale(1); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
@keyframes open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes shuttle { 0%, 100% { transform: translateY(0) rotate(-20deg); } 50% { transform: translateY(-8px) rotate(20deg); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Pied de page ---------- */
.site-footer {
  max-width: 1000px; margin: 8px auto 0; padding: 20px 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: .8rem; line-height: 1.5; text-align: center;
}
.site-footer p { margin: 0 0 6px; }
.site-footer strong { color: var(--text); }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
.sm-only { display: none; }

@media (max-width: 640px) {
  main { padding: 16px 12px 24px !important; }
  .site-footer { padding: 16px 12px 96px; font-size: .75rem; }
  h1 { font-size: 1.6rem !important; }
  .sub { font-size: .85rem !important; margin-bottom: 14px !important; }
  h2 { font-size: 1.15rem; margin: 20px 0 10px !important; }

  /* Menu : barre d'onglets fixée en bas de l'écran, icône + libellé court */
  .nav {
    position: fixed !important; top: auto !important; bottom: 0; left: 0; right: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 18px rgba(176, 0, 58, .25);
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideUp .5s cubic-bezier(.2, .8, .2, 1) both;
  }
  .nav-in { height: 62px !important; padding: 0 6px !important; gap: 2px !important; overflow: visible !important; }
  .nav .brand { display: none; }
  .nav a {
    flex: 1; min-width: 0; font-size: 0 !important; padding: 6px 2px !important;
    display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 12px !important;
  }
  .nav a::before { font-size: 1.25rem; line-height: 1; }
  .nav a::after { font-size: .68rem; font-weight: 600; letter-spacing: .01em; }
  .nav a[href="/"]::before { content: "🔎"; }
  .nav a[href="/"]::after { content: "Joueur"; }
  .nav a[href="/club"]::before { content: "👥"; }
  .nav a[href="/club"]::after { content: "Club"; }
  .nav a[href="/interclubs"]::before { content: "🏆"; }
  .nav a[href="/interclubs"]::after { content: "Interclubs"; }
  .nav a[href="/paliers"]::before { content: "📈"; }
  .nav a[href="/paliers"]::after { content: "Paliers"; }
  .nav a:hover { transform: none; }

  /* Champs */
  form { flex-direction: row; }
  input, select, button { font-size: 16px !important; } /* évite le zoom auto sur iPhone */
  button { padding: 12px 14px !important; }

  /* --- Recherche joueur : 3 disciplines côte à côte, format compact --- */
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; }
  .grid .card { padding: 10px 8px !important; text-align: center; }
  .grid .card h3 { flex-direction: column; align-items: center; gap: 4px; font-size: .85rem !important; margin-bottom: 6px !important; }
  .grid .level { font-size: .68rem !important; padding: 1px 6px !important; }
  .grid .compare { flex-direction: column; align-items: center; gap: 0; }
  .grid .compare .lbl, .grid .compare .arrow { display: none; }
  .grid .compare > div:first-child { order: 2; flex-direction: row; gap: 4px; align-items: baseline; }
  .grid .compare > div:first-child::before { content: "avant"; font-size: .7rem; color: var(--muted); }
  .grid .old { font-size: .95rem !important; line-height: 1.2; }
  .grid .avg { font-size: 2.2rem !important; line-height: 1.1; }
  .grid .diff { margin: 4px 0 0 !important; order: 3; font-size: .78rem; }
  .grid .card p { display: none; }
  #detail table { font-size: .82rem; }
  #detail .dow, #detail .event { display: none; }
  #detail td.date { white-space: nowrap; font-size: .75rem; color: var(--muted); }
  #detail th, #detail td { padding: 8px 6px !important; }

  /* --- Club : cellules réduites à "nouveau + écart" --- */
  .summary { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 6px !important; }
  .stat { min-width: 0 !important; padding: 8px 6px !important; text-align: center; }
  .stat b { font-size: 1.3rem !important; }
  .stat span { font-size: .65rem !important; line-height: 1.2; display: block; }
  .bar { gap: 8px !important; }
  .bar label { font-size: .85rem; }
  #rows .numero, #rows .lvl, #rows .old, #rows .to { display: none; }
  #rows .diff.same { visibility: hidden; }
  .sub:has(+ .bar) { display: none; }
  #rows td, .wrap th { padding: 9px 6px !important; }
  #rows td.player { white-space: normal; font-size: .85rem; }
  #rows .diff { margin-left: 3px !important; min-width: 0 !important; font-size: .72rem !important; }
  .wrap th.c { font-size: 0 !important; }
  .wrap th.c .sm-only { display: inline; font-size: .72rem; }

  /* --- Interclubs --- */
  .division { font-size: .8rem !important; }
  .standings td.team-name { white-space: normal !important; font-size: .82rem; }
  .standings td, .standings th { padding: 8px 6px !important; }
  .head { padding: 12px !important; }
  .teams { font-size: .88rem !important; }
  .score { font-size: 1.15rem !important; }
  .res { flex-direction: column; align-items: flex-end !important; gap: 4px !important; }
  .detail table { font-size: .8rem !important; }
  .detail th, .detail td { padding: 7px 5px !important; }
  .detail .lvl, .detail .res-col { display: none; }
  .detail td.sets .set { display: block; }
  .detail tr.mv td.disc { box-shadow: inset 3px 0 0 var(--win); }
  .detail tr.md td.disc { box-shadow: inset 3px 0 0 var(--loss); }

  /* --- Paliers --- */
  .sim { grid-template-columns: 1fr 1fr !important; }
  .sim label:first-child { grid-column: 1 / -1; }
  .verdict { padding: 12px !important; }
  .two table th, .two table td { padding: 8px !important; font-size: .85rem; }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

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