/* =====================================================================
 * MPGlace - Design system  |  Charte plandematch.fr : Noir / Blanc / Rouge
 * ===================================================================== */

:root {
  --red:        #e30613;
  --red-bright: #ff2233;
  --red-deep:   #b00410;
  --red-glow:   rgba(227, 6, 19, .45);

  --bg:      #08080a;
  --bg-2:    #0e0e12;
  --surface: #15151b;
  --surface-2:#1c1c24;
  --surface-3:#26262f;
  --line:    rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.16);

  --text:    #f6f6f8;
  --muted:   #9b9baa;
  --muted-2: #82828f;

  --gk:  #ffb020;   /* gardien  */
  --def: #4a9cff;   /* defenseur*/
  --fwd: #ff5a5f;   /* attaquant*/

  --ok:   #33d17a;
  --warn: #ffb020;
  --err:  #ff4d4d;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0,0,0,.5);
  --shadow-red: 0 8px 26px var(--red-glow);
  --maxw: 1180px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(227,6,19,.14), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(227,6,19,.07), transparent 55%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; }
h1,h2,h3 { line-height: 1.15; letter-spacing: -.02em; }

/* ------------------------- Layout ------------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.view { padding: 28px 0 90px; }
.view.enter { animation: fade .3s ease; }          /* transition de route only, pas a chaque interaction */
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* focus clavier visible (accessibilite) */
:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .view.enter, .overlay, .toast { animation: none; } * { scroll-behavior: auto; } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { font-size: 26px; font-weight: 800; }
.section-head p { color: var(--muted); font-size: 14px; }

/* ------------------------- Header / Nav ------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(8,8,10,.92), rgba(8,8,10,.72));
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 22px; height: 66px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 20px; letter-spacing: -.03em; }
.brand .puck { width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #444 0%, #111 60%, #000 100%);
  box-shadow: 0 0 0 2px rgba(255,255,255,.08), inset 0 2px 3px rgba(255,255,255,.15); position: relative; }
.brand .puck::after { content:""; position:absolute; inset: 8px; border-radius:50%; border: 2px solid var(--red); opacity:.9; }
.brand b { color: var(--red); }

.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.nav a {
  padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  transition: .18s; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: #fff; background: var(--red); box-shadow: var(--shadow-red); }

.userbox { display: flex; align-items: center; gap: 10px; }
.userbox select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 600; cursor: pointer; max-width: 160px;
}
.chip-budget { display:flex; align-items:center; gap:7px; background: var(--surface-2); border:1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; }
.chip-budget .lbl { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing:.08em; }

/* mobile nav toggle */
.navtoggle { display:none; }

/* ------------------------- Buttons ------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 11px 18px; border-radius: 11px; font-weight: 700; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
  transition: .18s; white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); background: var(--surface-3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--red-bright), var(--red)); border-color: transparent; color: #fff; box-shadow: var(--shadow-red); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--err); border-color: rgba(255,77,77,.35); }
.btn.danger:hover { background: rgba(255,77,77,.1); }

/* ------------------------- Cards ------------------------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* stat tiles */
.stat { padding: 18px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 30px; font-weight: 900; margin-top: 6px; letter-spacing: -.03em; }
.stat .v small { font-size: 15px; color: var(--muted); font-weight: 700; }
.stat .sub { font-size: 12px; color: var(--muted-2); margin-top: 4px; }
.stat .v.red { color: var(--red-bright); }
.stat .v.ok { color: var(--ok); }

/* ------------------------- Badges / pos ------------------------- */
.pos { display:inline-flex; align-items:center; justify-content:center; width: 26px; height: 26px; border-radius: 7px;
  font-weight: 900; font-size: 12px; flex: none; }
.pos.G { background: rgba(255,176,32,.16); color: var(--gk); box-shadow: inset 0 0 0 1px rgba(255,176,32,.35); }
.pos.D { background: rgba(74,156,255,.16); color: var(--def); box-shadow: inset 0 0 0 1px rgba(74,156,255,.35); }
.pos.F { background: rgba(255,90,95,.16); color: var(--fwd); box-shadow: inset 0 0 0 1px rgba(255,90,95,.35); }
.badge { display:inline-flex; align-items:center; gap:5px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge.red { background: rgba(227,6,19,.14); color: var(--red-bright); border-color: rgba(227,6,19,.3); }
.badge.ok  { background: rgba(51,209,122,.14); color: var(--ok); border-color: rgba(51,209,122,.3); }

/* note pill (rating) */
.note { font-weight: 900; font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 8px; font-size: 13px;
  background: var(--surface-3); }
.note.hi { color: #071; background: #b8f5cf; }
.note.mid { color: #4a3; background: rgba(51,209,122,.16); }
.note.lo { color: var(--muted); }

/* ------------------------- Player row / table ------------------------- */
.plist { display: flex; flex-direction: column; }
.prow { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 12px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--line); transition: background .15s; }
.prow:hover { background: var(--surface); }
.prow:last-child { border-bottom: none; }
.pinfo { min-width: 0; }
.pinfo .pn { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinfo .pm { font-size: 12px; color: var(--muted); display:flex; align-items:center; gap:6px; margin-top:1px; }
.pinfo .pm img { width: 16px; height: 16px; border-radius: 3px; }
.pstats { display:flex; gap: 14px; align-items:center; color: var(--muted); font-size: 12px; font-weight: 600; }
.pstats b { color: var(--text); font-size: 13px; }
.price { font-weight: 900; color: var(--red-bright); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* filters bar */
.filters { display:flex; gap: 10px; flex-wrap: wrap; align-items:center; margin-bottom: 16px; }
.filters input[type=search], .filters select {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; font-family: inherit;
}
.filters input[type=search] { min-width: 220px; flex: 1; }
.seg { display:flex; background: var(--surface); border:1px solid var(--line); border-radius: 10px; overflow:hidden; }
.seg button { padding: 9px 14px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--red); color: #fff; }

/* roster slots (progress) */
.slots { display:flex; gap: 12px; flex-wrap: wrap; }
.slot { flex:1; min-width: 130px; background: var(--surface); border:1px solid var(--line); border-radius: 12px; padding: 14px; }
.slot .st { display:flex; align-items:center; justify-content:space-between; font-size: 12px; color: var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.slot .sv { font-size: 22px; font-weight: 900; margin-top: 6px; }
.slot .sv.full { color: var(--ok); }
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.bar > i { display:block; height:100%; background: linear-gradient(90deg, var(--red), var(--red-bright)); border-radius: 999px; transition: width .3s; }
.bar > i.full { background: linear-gradient(90deg, #1e9e5a, var(--ok)); }

/* ------------------------- Ice rink (compo) ------------------------- */
.rink {
  position: relative; border-radius: 20px; padding: 22px;
  background:
    linear-gradient(180deg, rgba(74,156,255,.05), rgba(255,255,255,.02)),
    repeating-linear-gradient(0deg, transparent, transparent 58px, rgba(255,255,255,.03) 58px, rgba(255,255,255,.03) 60px),
    #0c1016;
  border: 1px solid var(--line-strong);
  overflow: hidden;
}
.rink::before { content:""; position:absolute; left:50%; top:0; bottom:0; width:2px; background: rgba(227,6,19,.5); transform: translateX(-50%); }
.rink::after { content:""; position:absolute; left:50%; top:50%; width:120px; height:120px; border:2px solid rgba(74,156,255,.3); border-radius:50%; transform: translate(-50%,-50%); }
.rink-lines { position: relative; z-index: 2; display:flex; flex-direction: column; gap: 16px; }
.rink-row { display:flex; justify-content:center; gap: 14px; flex-wrap: wrap; }
.rink-label { text-align:center; font-size: 11px; text-transform: uppercase; letter-spacing:.14em; color: var(--muted); font-weight: 800; margin-bottom: 4px; }

.slotcard {
  width: 128px; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border:1px solid var(--line-strong); border-radius: 12px; padding: 10px; text-align:center; position: relative;
  transition: .18s; cursor: pointer;
}
.slotcard:hover { border-color: var(--red); transform: translateY(-2px); }
.slotcard.empty { border-style: dashed; color: var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; min-height: 96px; }
.slotcard .sc-pos { position:absolute; top:8px; left:8px; }
.slotcard .sc-cap { position:absolute; top:8px; right:8px; width:22px;height:22px;border-radius:6px;background:var(--red);color:#fff;font-weight:900;font-size:12px; display:flex;align-items:center;justify-content:center; }
.slotcard .sc-name { font-weight: 800; font-size: 13px; margin-top: 20px; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.slotcard .sc-team { font-size: 11px; color: var(--muted); display:flex; gap:5px; align-items:center; justify-content:center; margin-top:2px; }
.slotcard .sc-team img { width:15px;height:15px; }
.slotcard .sc-note { margin-top: 8px; }
.slotcard .sc-plus { font-size: 26px; color: var(--red); font-weight: 300; }

/* ------------------------- Modal / picker ------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(3px); z-index: 100;
  display:flex; align-items:flex-start; justify-content:center; padding: 6vh 16px; animation: fade .2s; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border:1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow); max-height: 84vh; display:flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
.modal-head h3 { font-size: 18px; }
.modal-body { overflow-y: auto; }
.modal-close { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); font-size: 18px; }
.modal-close:hover { background: var(--surface-3); }

/* ------------------------- Standings ------------------------- */
.rank-table { width: 100%; border-collapse: collapse; }
.rank-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing:.08em; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.rank-table td { padding: 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table .rk { font-weight: 900; font-size: 16px; width: 44px; }
.rank-table .rk.top { color: var(--red-bright); }
.rank-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-table .me { background: rgba(227,6,19,.07); }

/* ------------------------- Onboarding / empty ------------------------- */
.hero { text-align:center; padding: 60px 20px 30px; }
.hero h1 { font-size: 46px; font-weight: 900; letter-spacing: -.04em; }
.hero h1 b { color: var(--red); }
.hero p { color: var(--muted); font-size: 17px; max-width: 560px; margin: 14px auto 0; }
.setup { max-width: 520px; margin: 0 auto; }
.field { margin-bottom: 16px; }
.field label { display:block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; background: var(--surface-2); border:1px solid var(--line-strong); color: var(--text);
  padding: 12px 14px; border-radius: 11px; font-size: 15px; font-family: inherit;
}
.field .hint { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
.empty { text-align:center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display:flex; flex-direction:column; gap:8px; }
.toast { background: var(--surface-3); border:1px solid var(--line-strong); padding: 12px 18px; border-radius: 12px;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow); animation: fade .2s; }
.toast.err { border-color: rgba(255,77,77,.4); color: #ffb3b3; }
.toast.ok { border-color: rgba(51,209,122,.4); color: #b8f5cf; }

.foot { text-align:center; color: var(--muted-2); font-size: 12px; padding: 30px 0 40px; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* ------------------------- Bannieres ------------------------- */
.banner { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 18px; font-weight: 600; font-size: 14px; }
.banner a { color: var(--red-bright); font-weight: 800; }
.banner.ok { background: rgba(51,209,122,.1); border-color: rgba(51,209,122,.35); }
.banner.err { background: rgba(255,77,77,.1); border-color: rgba(255,77,77,.4); color: #ffb3b3; }

/* ------------------------- Affiches (matchs) ------------------------- */
.affiches { display: flex; flex-wrap: wrap; gap: 8px; }
.affiche { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; font-weight: 700; }
.affiche .side { display: inline-flex; align-items: center; gap: 6px; }
.affiche .side img { width: 20px; height: 20px; }
.affiche .side.away { flex-direction: row-reverse; }
.affiche .vs { color: var(--muted); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.affiches.compact .affiche { padding: 5px 8px; font-size: 12px; }
.affiches.compact .affiche .side span { display: none; }   /* logos seuls en compact */
.affiches.compact .affiche .side img { width: 22px; height: 22px; }

/* ------------------------- Calendrier ------------------------- */
.cal-list { display: flex; flex-direction: column; }
.cal-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cal-row:last-child { border-bottom: none; }
.cal-row.current { background: rgba(227,6,19,.07); }
.cal-row.played { opacity: .62; }
.cal-j { display: flex; flex-direction: column; }
.cal-j b { font-size: 16px; font-weight: 900; }
.cal-j .muted { font-size: 12px; }
.cal-act { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }

/* etats compo */
.prow.off { opacity: .5; }
.slotcard.ineligible { opacity: .45; filter: grayscale(.5); }
.slotcard.ineligible:hover { opacity: .7; border-color: var(--warn); }

/* ------------------------- Responsive ------------------------- */
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2,1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 720px) {
  .nav { position: fixed; inset: 66px 0 auto 0; flex-direction: column; background: var(--bg-2);
    border-bottom: 1px solid var(--line); padding: 10px; gap: 4px; display: none; }
  .nav.open { display: flex; }
  .navtoggle { display: inline-flex; }
  .brand { flex: 1; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; }
  .userbox select { max-width: 120px; }
  .cal-row { grid-template-columns: 1fr; gap: 8px; }
  .cal-act { justify-content: flex-start; }
}
