/* ═══════════════════════════════════════════════════════════════════════════
   Polymarché — design system « Modernist » (tokens issus de design/_ds)
   ═══════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-accent-2: #e15b47;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff2ef;
  --color-accent-200: #ffe0d9;
  --color-accent-300: #ffc4b8;
  --color-accent-400: #ff9783;
  --color-accent-500: #ff563c;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;
  --color-accent-900: #4d170e;

  --font-heading: 'Archivo', system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: 'Archivo', system-ui, sans-serif;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px;
  --radius-sm: 0; --radius-md: 0; --radius-lg: 0;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55; font-weight: 400;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: clamp(30px, 5vw, 42px); }
h2 { font-size: clamp(25px, 4vw, 32px); }
h3 { font-size: 22px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
button { font-family: inherit; }

.hr { height: 2px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

/* — boutons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
  transition: background .15s ease, transform .1s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* — formulaires — */
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit;
  font-size: 16px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 90px; resize: vertical; }
.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); }
.seg-opt {
  display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0;
  padding: 7px 12px; font-size: 13px; cursor: pointer; color: var(--color-text);
  font-family: var(--font-heading); font-weight: 800;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt.on { background: var(--color-text); color: var(--color-bg); }
.seg-opt:not(.on):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }

/* — cartes / tags — */
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.elev-lg { box-shadow: var(--shadow-lg); }
.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; border-radius: 0;
}
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* — tableaux — */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 2px solid var(--color-divider);
}
.table td { padding: var(--space-2); border-bottom: 1px solid var(--color-divider); }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

/* — dialog — */
.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4); z-index: 90; overflow: hidden;
  background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}
.dialog {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
  padding: 32px; background: var(--color-surface); box-shadow: var(--shadow-lg);
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes fb-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes fb-blink { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes fb-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fb-pop { 0% { transform: scale(.85); opacity: 0; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fb-fall { from { transform: translate3d(0, -12vh, 0) rotate(0); } to { transform: translate3d(var(--dx, 0), 112vh, 0) rotate(540deg); } }
@keyframes fb-tick { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes fb-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.rise { animation: fb-rise .35s ease both; }
.pop { animation: fb-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.shake { animation: fb-shake .3s ease 2; }
.blink { animation: fb-blink 1.6s infinite; }
.tick { animation: fb-tick 2.4s infinite; }

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

/* ═══════════════════════════════════════════════════════════════════════════
   Structure applicative
   ═══════════════════════════════════════════════════════════════════════ */

#app { min-height: 100vh; min-height: 100dvh; padding-bottom: 64px; }

/* — bandeau téléscripteur — */
.ticker {
  overflow: hidden; border-bottom: 2px solid var(--color-divider); height: 32px;
  display: flex; align-items: center; background: var(--color-text);
  padding-top: env(safe-area-inset-top);
  height: calc(32px + env(safe-area-inset-top));
}
.ticker-track {
  display: flex; gap: 32px; white-space: nowrap;
  animation: fb-marquee 40s linear infinite;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  padding-left: 16px; color: var(--color-bg);
}
.ticker-track span { display: flex; gap: 8px; align-items: center; }
.ticker-track b { font-weight: 800; }

/* — barre de navigation — */
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--color-bg);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-divider);
}
.brand {
  display: flex; align-items: center; gap: 10px; margin-right: auto;
  font-family: var(--font-heading); font-weight: 800; font-size: 18px;
  cursor: pointer;
}
.brand-mark {
  width: 28px; height: 28px; background: var(--color-accent); color: var(--color-bg);
  display: grid; place-items: center; font-size: 16px; font-weight: 800;
}
.brand-sub {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-neutral-600); font-weight: 400;
}
.balance-box {
  display: flex; align-items: center; gap: 10px;
  border-left: 2px solid var(--color-divider); padding-left: 16px;
}
.balance-dot { width: 7px; height: 7px; background: var(--color-accent); animation: fb-blink 1.6s infinite; }
.balance-num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.balance-unit { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--color-neutral-600); }
.avatar {
  width: 32px; height: 32px; background: var(--color-text); color: var(--color-bg);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none;
}
.userbox { display: flex; align-items: center; gap: 9px; cursor: pointer; }

/* — onglets — */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 2px solid var(--color-divider); }
.tab {
  border: 0; border-right: 1px solid var(--color-divider); border-radius: 0;
  padding: 10px 16px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  background: transparent; color: var(--color-text); cursor: pointer;
  font-family: var(--font-heading); font-weight: 800;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--color-neutral-200); }
.tab.on { background: var(--color-text); color: var(--color-bg); }
.tab .badge {
  min-width: 17px; height: 17px; padding: 0 4px; background: var(--color-accent); color: var(--color-bg);
  display: grid; place-items: center; font-size: 10px; line-height: 1;
}
.tab.on .badge { background: var(--color-accent); }

.shell { max-width: 1400px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 32px) 0; }

/* — grille de stats — */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider);
  margin-bottom: 28px;
}
.stat-cell { padding: 16px 18px; border-right: 1px solid var(--color-divider); }
.stat-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--color-neutral-600); }
.stat-value { font-size: clamp(24px, 3vw, 30px); font-weight: 800; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--color-neutral-700); }

/* — grille de marchés (direction A : cartes) — */
.market-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  border-top: 2px solid var(--color-divider); border-left: 2px solid var(--color-divider);
}
.market-card {
  cursor: pointer; background: var(--color-bg); padding: 20px; transition: background .15s ease;
  border-right: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider);
}
.market-card:hover { background: var(--color-surface); }
.market-q {
  font-size: 19px; font-weight: 800; font-family: var(--font-heading);
  line-height: 1.2; min-height: 70px; text-wrap: pretty;
}
.opt-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.opt-bar { height: 10px; background: var(--color-neutral-300); }
.opt-bar > div { height: 100%; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.market-foot {
  display: flex; justify-content: space-between; margin-top: 14px; padding-top: 10px;
  border-top: 1px solid var(--color-divider);
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--color-neutral-600);
}

/* — direction C : liste — */
.market-list { display: flex; flex-direction: column; border-top: 2px solid var(--color-divider); max-width: 900px; }
.market-line {
  cursor: pointer; display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  padding: 22px 4px; border-bottom: 2px solid var(--color-divider);
}
.market-line:hover { background: var(--color-surface); }
.lead-block {
  width: 92px; height: 92px; flex: none; background: var(--color-text); color: var(--color-bg);
  display: flex; flex-direction: column; justify-content: center; padding-left: 12px;
}

/* — détail marché — */
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 2px; background: var(--color-divider); border: 2px solid var(--color-divider);
}
.pane { background: var(--color-bg); padding: clamp(16px, 3vw, 26px); }
.pane-alt { background: var(--color-surface); }
.opt-pick { cursor: pointer; padding: 14px; margin-bottom: 2px; border-left: 4px solid var(--color-divider); background: var(--color-surface); transition: background .15s ease; }
.opt-pick.on { border-left-color: var(--color-accent); background: var(--color-accent-100); }
.feed-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; gap: 8px; }
.stake-display {
  display: flex; align-items: baseline; gap: 8px; background: var(--color-bg);
  border: 1px solid var(--color-divider); padding: 14px; margin-bottom: 2px;
}
.stake-num { font-size: 36px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
input.stake-num {
  border: none; background: transparent; color: inherit; font-family: inherit;
  width: 100%; min-width: 0; padding: 0; outline: none; appearance: textfield; -moz-appearance: textfield;
}
input.stake-num::-webkit-outer-spin-button, input.stake-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.recap { background: var(--color-bg); border: 1px solid var(--color-divider); padding: 14px; margin: 16px 0; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.recap-row { display: flex; justify-content: space-between; }

/* — création — */
.form-section { border-top: 2px solid var(--color-divider); padding: 22px 0; }
.choice-btn {
  cursor: pointer; border: 2px solid var(--color-divider); background: transparent; color: var(--color-text);
  padding: 12px 16px; font-family: var(--font-heading); font-weight: 800; font-size: 13px;
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  transition: background .15s ease;
}
.choice-btn .desc { font-weight: 400; font-size: 12px; opacity: .75; }
.choice-btn.on { border-color: var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-700); }
.chip-btn {
  cursor: pointer; border: 2px solid var(--color-divider); background: transparent; color: var(--color-text);
  padding: 9px 14px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  font-family: var(--font-heading); font-weight: 800;
}
.chip-btn.on { border-color: var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-700); }
.char-count { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 6px; color: var(--color-neutral-600); }

/* — podium — */
.podium { display: flex; gap: 2px; align-items: flex-end; margin-bottom: 34px; }
.podium-col { flex: 1; min-width: 90px; display: flex; flex-direction: column; justify-content: flex-end; }
.podium-bar {
  display: flex; align-items: flex-start; padding: 12px; font-size: 34px; font-weight: 800; line-height: 1;
  transition: height 1s cubic-bezier(.2, .9, .2, 1);
}

/* — portefeuille — */
.wallet-hero { background: var(--color-accent); color: var(--color-bg); padding: 24px; margin-bottom: 2px; }
.wallet-num { font-size: clamp(40px, 6vw, 52px); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 2px; background: var(--color-divider); }
.mini-stat { background: var(--color-surface); padding: 14px; }

/* — toast — */
.toast {
  position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); left: 16px; right: 16px; z-index: 95;
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--color-text); color: var(--color-bg);
  animation: fb-rise .25s ease both; box-shadow: var(--shadow-lg);
  max-width: 420px;
}
.toast.err { background: var(--color-accent-700); }
.toast .dot { width: 8px; height: 8px; background: var(--color-accent); flex: none; }
.toast.err .dot { background: var(--color-bg); }
@media (min-width: 900px) { .toast { bottom: 24px; left: 24px; right: auto; } }

/* — confetti — */
.confetti { position: absolute; top: 0; }

/* — barre d'onglets mobile — */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: none; background: var(--color-text);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; border: 0; background: transparent; color: var(--color-neutral-400);
  padding: 9px 2px 7px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 9px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  position: relative;
}
.bottom-nav button.on { color: var(--color-bg); }
.bottom-nav button.on::before { content: ''; position: absolute; top: 0; left: 20%; right: 20%; height: 3px; background: var(--color-accent); }
.bottom-nav .ico { font-size: 19px; line-height: 1; }
.bottom-nav .badge {
  position: absolute; top: 3px; right: calc(50% - 20px);
  min-width: 15px; height: 15px; padding: 0 3px; background: var(--color-accent); color: #fff;
  display: grid; place-items: center; font-size: 9px;
}

@media (max-width: 899px) {
  .tabs { display: none; }
  .bottom-nav { display: flex; }
  #app { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .brand-sub { display: none; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .userbox .uname { display: none; }
  .market-q { min-height: 0; }
  .shell { padding-top: 18px; }
}

/* — auth — */
.auth-wrap { max-width: 980px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 32px); }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 32px; align-items: start; }
.auth-panel { border: 2px solid var(--color-divider); padding: clamp(18px, 3vw, 24px); }
.rule-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; line-height: 1.45; }
.rule-dash { color: var(--color-accent); font-weight: 800; }

.member-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-divider); }

.empty-block { border: 2px dashed var(--color-divider); padding: 40px 24px; text-align: center; color: var(--color-neutral-600); }
