/* ─── Zenkai BDD — thème « encre & sable » ─────────────────────────── */
:root {
  --bg: #14100b;
  --bg-raise: #1d1710;
  --bg-panel: #221a12;
  --line: #372c1e;
  --line-soft: #2a2115;
  --ink: #efe5d0;
  --ink-dim: #a4937a;
  --ink-faint: #6f6250;
  --sand: #dca94b;
  --sand-bright: #f0c06e;
  --sand-deep: #9a6f26;
  --suna: #dca94b;
  --konoha: #8fb35c;
  --danger: #c96f5a;
  --font-display: "Shippori Mincho", serif;
  --font-body: "Schibsted Grotesk", sans-serif;
  --font-mono: "Spline Sans Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(220, 169, 75, 0.07), transparent 60%),
    radial-gradient(900px 400px at 10% 0%, rgba(220, 169, 75, 0.04), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* dune décorative en haut de page */
.dune {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--sand) 30%, var(--sand-bright) 50%, var(--sand) 70%, transparent);
  opacity: 0.85;
  z-index: 50;
}

::selection { background: var(--sand-deep); color: var(--ink); }

/* ─── En-tête ──────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 28px 32px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 18px; }

.brand-kanji {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 800;
  color: var(--sand);
  line-height: 1;
  text-shadow: 0 0 30px rgba(220, 169, 75, 0.35);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  color: var(--ink-dim);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-meta { display: flex; align-items: center; gap: 16px; }

.sync-info { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); font-size: 13px; }

.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-faint);
}
.sync-dot.ok { background: var(--konoha); box-shadow: 0 0 8px rgba(143, 179, 92, 0.6); }
.sync-dot.busy { background: var(--sand); animation: pulse 1s ease-in-out infinite; }
.sync-dot.err { background: var(--danger); }

@keyframes pulse { 50% { opacity: 0.3; } }

.btn-sync {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--sand-bright);
  background: transparent;
  border: 1px solid var(--sand-deep);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-sync:hover { background: rgba(220, 169, 75, 0.12); }
.btn-sync:active { transform: scale(0.97); }
.btn-sync:disabled { opacity: 0.5; cursor: wait; }

/* ─── Bandeau statistiques ─────────────────────────────────────────── */
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 8px;
}

.stat {
  flex: 1 1 140px;
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--sand-bright);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─── Onglets ──────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  max-width: 1400px;
  margin: 14px auto 0;
  padding: 0 32px;
  border-bottom: 1px solid var(--line-soft);
}

.tab {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  transition: color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--sand-bright); border-bottom-color: var(--sand); }

main { max-width: 1400px; margin: 0 auto; padding: 20px 32px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
#panel-roster.active { display: flex; gap: 24px; align-items: flex-start; }

/* ─── Filtres ──────────────────────────────────────────────────────── */
.filters {
  flex: 0 0 250px;
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.filter-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

.filters input[type="search"],
.filters select,
#f-changes {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.filters input[type="search"]:focus,
.filters select:focus { border-color: var(--sand-deep); }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.chip:hover { border-color: var(--sand-deep); color: var(--ink); }
.chip.active {
  background: rgba(220, 169, 75, 0.15);
  border-color: var(--sand);
  color: var(--sand-bright);
}
.chip .n { opacity: 0.55; font-size: 11px; margin-left: 3px; }

.filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
}
.filter-check input { accent-color: var(--sand); width: 15px; height: 15px; }
.filter-check:hover { color: var(--ink); }

.btn-reset {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover { color: var(--danger); border-color: var(--danger); }

/* ─── Résultats ────────────────────────────────────────────────────── */
.results { flex: 1; min-width: 0; }

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--ink-dim);
  font-size: 13px;
}
.results-bar strong { color: var(--sand-bright); font-weight: 700; }

.page-size { display: flex; align-items: center; gap: 8px; }
.page-size select {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  padding: 4px 8px;
}

.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: var(--bg-raise);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: " ↕"; opacity: 0.35; }
th.sortable.asc::after { content: " ↑"; opacity: 1; color: var(--sand); }
th.sortable.desc::after { content: " ↓"; opacity: 1; color: var(--sand); }

tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(220, 169, 75, 0.05); }

tbody td { padding: 11px 16px; vertical-align: middle; }

.c-name { font-weight: 600; }
.c-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.rank-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}

.div-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.div-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  white-space: nowrap;
}
.div-tag.suna { border-color: rgba(220, 169, 75, 0.4); color: var(--suna); }
.div-tag.konoha { border-color: rgba(143, 179, 92, 0.4); color: var(--konoha); }
.div-tag .chief-star { color: var(--sand-bright); }

.c-played { font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.c-played.recent { color: var(--konoha); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-kanji { font-family: var(--font-display); font-size: 64px; display: block; opacity: 0.3; margin-bottom: 8px; }

/* ─── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
}
.pagination button {
  min-width: 34px;
  padding: 7px 10px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}
.pagination button:hover:not(:disabled) { border-color: var(--sand-deep); color: var(--ink); }
.pagination button.current { background: var(--sand-deep); color: var(--ink); border-color: var(--sand-deep); font-weight: 700; }
.pagination button:disabled { opacity: 0.35; cursor: default; }
.pagination .ellipsis { color: var(--ink-faint); padding: 0 2px; }

/* ─── Activité ─────────────────────────────────────────────────────── */
.activity-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.activity-head h2 { font-family: var(--font-display); font-size: 20px; }
#f-changes { max-width: 260px; }

.feed { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.feed li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
}
.feed li:hover { background: var(--bg-raise); }
.feed li.f-rang { border-left-color: var(--sand); }
.feed li.f-arrivee { border-left-color: var(--konoha); }
.feed li.f-division_rejointe { border-left-color: #7ba7c9; }
.feed li.f-division_quittee { border-left-color: var(--danger); }

.feed .f-time { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.feed .f-name { font-weight: 600; }
.feed .f-desc { color: var(--ink-dim); font-size: 13px; }
.feed .f-old { text-decoration: line-through; opacity: 0.6; }
.feed .f-new { color: var(--sand-bright); }

/* ─── Doc API ──────────────────────────────────────────────────────── */
#panel-api h2 { font-family: var(--font-display); font-size: 20px; margin-bottom: 8px; }
.api-intro { color: var(--ink-dim); margin-bottom: 20px; max-width: 760px; }
.api-intro code, .endpoint code { font-family: var(--font-mono); font-size: 13px; color: var(--sand-bright); }

.endpoint {
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.endpoint-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.method {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(143, 179, 92, 0.15);
  color: var(--konoha);
  border: 1px solid rgba(143, 179, 92, 0.35);
}
.method.post { background: rgba(220, 169, 75, 0.14); color: var(--sand-bright); border-color: rgba(220, 169, 75, 0.4); }
.endpoint-head a { color: var(--ink-faint); font-size: 12px; text-decoration: none; margin-left: auto; }
.endpoint-head a:hover { color: var(--sand); }
.endpoint p { color: var(--ink-dim); font-size: 13px; margin-top: 6px; }
.endpoint .params { margin-top: 8px; font-size: 13px; color: var(--ink-dim); }
.endpoint .params code { color: var(--ink); background: var(--bg); padding: 1px 6px; border-radius: 4px; margin-right: 4px; }

/* ─── Modale ───────────────────────────────────────────────────────── */
.modal-backdrop[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 4, 0.75);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 30px;
  width: min(680px, 100%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
}
.modal-close:hover { color: var(--danger); }

.modal h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 2px;
}
.modal .m-discord { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin-bottom: 18px; }

.m-char { border-top: 1px solid var(--line-soft); padding: 16px 0; }
.m-char-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.m-char-head .c-name { font-size: 16px; }

.btn-hide {
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-hide:hover { color: var(--danger); border-color: var(--danger); }
.btn-hide:disabled { opacity: 0.5; cursor: wait; }

.hidden-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 1px 7px;
}
.hidden-badge.inactive { color: var(--ink-faint); border-color: var(--ink-faint); }

.hidden-count { color: var(--sand); font-weight: 600; }
.m-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--ink-dim); margin: 8px 0; }
.m-meta b { color: var(--ink); font-weight: 600; }

.m-divs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.m-div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 7px 12px;
}
.m-div .grade { color: var(--ink-dim); }
.m-div .joined { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }

.m-history { margin-top: 12px; }
.m-history summary { cursor: pointer; font-size: 13px; color: var(--ink-dim); user-select: none; }
.m-history summary:hover { color: var(--sand); }
.m-history ul { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.m-history li { font-size: 12px; color: var(--ink-dim); display: flex; gap: 10px; align-items: baseline; }
.m-history .f-time { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap; }

.loading { text-align: center; color: var(--ink-faint); padding: 40px; }

/* ─── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #panel-roster.active { flex-direction: column; }
  .filters { position: static; flex: none; width: 100%; max-height: none; }
  .site-header, .stats-strip, .tabs, main { padding-left: 16px; padding-right: 16px; }
}
