/* SportFarming — direction "dossier d'athlete / fiche RPG"
   Charbon chaud + un seul accent or. Anton (titres/niveaux), DM Mono (stats),
   Hanken Grotesk (corps). Sobre, filaire, gamifie. */

:root {
  --bg: #0d0d0f;
  --bg-panel: #141417;
  --bg-panel-2: #1b1b21;
  --bg-inset: #0a0a0c;
  --line: #26262d;
  --line-strong: #393941;
  --ink: #ece9e2;
  --ink-dim: #8f8c84;
  --ink-faint: #5c5a55;
  --gold: #e0a93f;
  --gold-bright: #f6c463;
  --gold-soft: rgba(224, 169, 63, 0.13);
  --danger: #cf6a5f;

  --display: 'Anton', 'Hanken Grotesk', sans-serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  --r: 8px;
  --r-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
  /* halo chaud tres discret en haut */
  background-image: radial-gradient(900px 480px at 50% -160px, rgba(224, 169, 63, 0.07), transparent 70%);
  background-attachment: fixed;
}

/* Grain : texture fine plein ecran, sans interactivite */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* --- Typo utilitaires --- */
.mono { font-family: var(--mono); }

/* --- Icones SVG (heritent la couleur via currentColor) --- */
.ic {
  display: block; width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; stroke-width: 1.7; }
.ic-dot { color: var(--ink-faint); }

/* --- Topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 13, 15, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.topbar h1 {
  font-family: var(--display); font-weight: 400; font-size: 1.45rem;
  letter-spacing: 0.06em; text-transform: uppercase; line-height: 1;
  display: flex; align-items: center; gap: 9px;
}
.logo { color: var(--gold); display: flex; }
.logo .ic { width: 23px; height: 23px; }
.logout-btn { display: flex; align-items: center; justify-content: center; }
.logout-btn .ic { width: 17px; height: 17px; }

.global-chip { flex: 1; min-width: 200px; }
.global-level { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.lvl-label {
  font-size: 0.62rem; color: var(--ink-dim); letter-spacing: 0.22em; text-transform: uppercase; font-weight: 600;
}
.lvl-value {
  font-family: var(--display); font-size: 1.85rem; line-height: 0.9;
  color: var(--gold); letter-spacing: 0.02em;
}

.user-chip { display: flex; align-items: center; gap: 9px; }
.user-name {
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.logout-btn {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-dim);
  width: 34px; height: 34px; border-radius: var(--r); cursor: pointer; font-size: 0.95rem;
  transition: color .15s, border-color .15s;
}
.logout-btn:hover { color: var(--gold); border-color: var(--gold); }
.logout-btn:active { transform: scale(0.93); }

/* --- Jauges --- */
.bar {
  position: relative; height: 20px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
/* crantage facon jauge d'energie */
.bar-fill::after {
  content: ''; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.28) 0 1px, transparent 1px 9px);
}
.bar-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 0.66rem; font-weight: 500; color: var(--ink);
  letter-spacing: 0.02em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); mix-blend-mode: difference;
}

/* --- Layout --- */
main { padding: 18px; max-width: 760px; margin: 0 auto; position: relative; z-index: 2; }
.tab { display: none; }
.tab.active { display: block; animation: rise 0.3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 500px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
h2 {
  font-family: var(--display); font-weight: 400; font-size: 0.95rem;
  letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 14px; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
}
h2 .ic-sm { color: var(--gold); }

/* --- Carte discipline --- */
.disc-card { position: relative; overflow: hidden; animation: rise 0.35s ease both; }
.disc-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 38px; height: 2px; background: var(--gold);
}
.grid .disc-card:nth-child(2) { animation-delay: 0.05s; }
.grid .disc-card:nth-child(3) { animation-delay: 0.1s; }
.grid .disc-card:nth-child(4) { animation-delay: 0.15s; }
.disc-head { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.disc-icon { color: var(--gold); display: flex; }
.disc-icon .ic { width: 25px; height: 25px; }
.disc-name { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em; }
.disc-level {
  margin-left: auto; font-family: var(--mono); font-size: 0.66rem; font-weight: 500;
  color: var(--gold); border: 1px solid var(--gold-soft); background: var(--gold-soft);
  padding: 4px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em;
}
.disc-total {
  font-family: var(--mono); font-size: 0.66rem; color: var(--ink-faint);
  margin-top: 9px; letter-spacing: 0.01em;
}

/* --- Formulaire seance --- */
.form-card .hint { color: var(--ink-dim); font-size: 0.82rem; margin-bottom: 16px; }
.log-inputs { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.log-row {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-panel-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 11px;
}
.lr-icon { color: var(--ink-dim); display: flex; }
.lr-icon .ic { width: 21px; height: 21px; }
.lr-label { flex: 1; font-size: 0.9rem; font-weight: 500; }
.lr-unit { font-family: var(--mono); font-size: 0.64rem; color: var(--ink-faint); width: 34px; text-transform: uppercase; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 32px; height: 32px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--bg-panel);
  color: var(--ink); font-size: 1.05rem; cursor: pointer; line-height: 1;
  transition: border-color .15s, color .15s;
}
.stepper button:hover { border-color: var(--gold); color: var(--gold); }
.stepper button:active { transform: scale(0.9); }
.stepper input {
  width: 62px; text-align: center; font-family: var(--mono); font-weight: 500;
  background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--ink); padding: 8px 4px; font-size: 0.92rem;
}
.note-input, .auth-input {
  width: 100%; background: var(--bg-panel-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 13px; color: var(--ink); font-family: var(--body); font-size: 0.92rem;
  transition: border-color .15s;
}
.note-input { margin-bottom: 14px; }
.note-input:focus, .auth-input:focus { outline: none; border-color: var(--gold); }
.note-input::placeholder, .auth-input::placeholder { color: var(--ink-faint); }

/* --- Boutons --- */
.btn {
  border: none; border-radius: var(--r); padding: 13px 16px;
  font-family: var(--body); font-size: 0.82rem; font-weight: 800; cursor: pointer; width: 100%;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.btn-primary { background: var(--gold); color: #161208; transition: background .15s, transform .05s; }
.btn-primary:hover { background: var(--gold-bright); }
.btn-primary:active { transform: translateY(1px); }
.feedback { margin-top: 13px; text-align: center; font-size: 0.84rem; min-height: 18px; font-weight: 600; }
.feedback.ok { color: var(--gold); }
.feedback.err { color: var(--danger); }

/* --- Quetes --- */
.quest-group { margin-bottom: 24px; }
.quest-list { display: flex; flex-direction: column; gap: 10px; }
.quest {
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 15px; transition: border-color .2s;
}
.quest.done { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), transparent); }
.quest-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.quest-top > span:first-child { color: var(--ink-dim); display: flex; }
.quest-top .ic { width: 19px; height: 19px; }
.quest.done .quest-top > span:first-child { color: var(--gold); }
.quest-title { font-weight: 600; font-size: 0.88rem; }
.quest-reward {
  margin-left: auto; font-family: var(--mono); font-size: 0.68rem; color: var(--gold); font-weight: 500;
}
.quest .bar { height: 16px; }
.quest-badge { margin-left: 5px; }

/* --- Classement --- */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 13px;
  background: var(--bg-panel-2); border: 1px solid var(--line); border-radius: var(--r);
}
.rank-row.me { border-color: var(--gold); background: linear-gradient(90deg, var(--gold-soft), transparent); }
.rank-pos { font-family: var(--display); font-size: 1rem; min-width: 34px; text-align: center; color: var(--ink-dim); display: flex; align-items: center; justify-content: center; }
.rank-pos .medal { display: flex; }
.rank-pos .medal .ic { width: 22px; height: 22px; }
.medal.m1 { color: var(--gold-bright); }
.medal.m2 { color: #cdd2da; }
.medal.m3 { color: #cf945c; }
.rank-name { flex: 1; font-weight: 600; font-size: 0.88rem; }
.rank-you { font-family: var(--mono); color: var(--gold); font-size: 0.66rem; }
.rank-lvl { font-family: var(--mono); font-size: 0.68rem; color: var(--gold); }
.rank-xp { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-dim); min-width: 84px; text-align: right; }

/* --- Historique --- */
.history-list { display: flex; flex-direction: column; gap: 2px; }
.hist-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: none; }
.hist-icon { color: var(--ink-dim); display: flex; }
.hist-icon .ic { width: 21px; height: 21px; }
.hist-main { flex: 1; }
.hist-amount { font-family: var(--mono); font-weight: 500; color: var(--gold); }
.hist-date { font-family: var(--mono); font-size: 0.64rem; color: var(--ink-faint); margin-top: 2px; }
.hist-note { font-size: 0.74rem; color: var(--ink-dim); font-style: italic; margin-top: 2px; }
.hist-del {
  border: 1px solid var(--line); background: transparent; color: var(--ink-faint);
  border-radius: var(--r); width: 30px; height: 30px; cursor: pointer; font-size: 0.85rem;
  transition: color .15s, border-color .15s;
}
.hist-del:hover { color: var(--danger); border-color: var(--danger); }
.empty { color: var(--ink-faint); text-align: center; padding: 26px 0; font-size: 0.84rem; }

/* --- Tabbar --- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(13, 13, 15, 0.94);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 6px 4px env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--ink-faint);
  padding: 9px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative; transition: color .15s;
}
.tab-btn .ic { width: 21px; height: 21px; }
.tab-btn span {
  font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em;
}
.tab-btn.active { color: var(--gold); }
.tab-btn.active::before {
  content: ''; position: absolute; top: 0; width: 26px; height: 2px; background: var(--gold);
}

/* --- Ecran d'authentification --- */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 22px;
  background: var(--bg);
  background-image: radial-gradient(800px 460px at 50% -120px, rgba(224, 169, 63, 0.1), transparent 70%);
}
.auth-card {
  width: 100%; max-width: 350px; position: relative;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 24px;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 24px; width: 46px; height: 2px; background: var(--gold);
}
.auth-logo {
  font-family: var(--display); font-weight: 400; font-size: 1.6rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.auth-logo .ic { width: 25px; height: 25px; color: var(--gold); }
.auth-tagline { text-align: center; color: var(--ink-dim); font-size: 0.82rem; margin: 8px 0 22px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--r); padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: none; background: none; color: var(--ink-dim);
  padding: 9px 0; border-radius: 5px; font-family: var(--mono); font-weight: 500;
  font-size: 0.72rem; cursor: pointer; text-transform: uppercase; letter-spacing: 0.05em; transition: all .15s;
}
.auth-tab.active { background: var(--gold); color: #161208; }
.auth-input { margin-bottom: 11px; }
.auth-card .btn { margin-top: 6px; }

/* --- Toast montee de niveau --- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(16px);
  background: var(--gold); color: #161208;
  font-family: var(--display); font-weight: 400; font-size: 0.92rem; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 12px 22px; border-radius: var(--r);
  opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 50;
  text-align: center; max-width: 90vw; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
