/* Neerya Purge — thème sombre d'Halloween */

:root {
  color-scheme: dark;
  --bg: #0b0810;
  --bg-2: #130d1a;
  --surface: #18121f;        /* cartes et graphiques */
  --surface-2: #211929;
  --surface-3: #2b2134;
  --line: #2f2539;           /* grilles et bordures : un cran au-dessus de la surface */
  --ink: #f1e8f6;
  --ink-2: #c0b1cc;
  --ink-3: #8f809c;
  --pumpkin: #e8650f;        /* série PvP (validée sur la surface sombre) */
  --pumpkin-glow: #ff8f33;
  --violet: #8f6be0;         /* autres morts */
  --toxic: #3fa84a;          /* joueurs connectés */
  --blood: #d23a4f;
  --mid: #4a4153;            /* point neutre des échelles divergentes */
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Creepster", "Inter", fantasy;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(232, 101, 15, .10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(143, 107, 224, .10), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pumpkin-glow); }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

/* --- Ciel : lune, brume, chauves-souris ---------------------------------------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.moon {
  position: absolute; top: 22px; right: 34vw; width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4d6, #f5d78e 55%, #d9a441);
  box-shadow: 0 0 60px 18px rgba(245, 215, 142, .18), 0 0 160px 60px rgba(232, 101, 15, .08);
  opacity: .85;
}
.fog {
  position: absolute; left: -10%; right: -10%; bottom: -40px; height: 220px;
  background: radial-gradient(60% 100% at 50% 100%, rgba(143, 107, 224, .12), transparent 70%);
  filter: blur(8px);
}
.bat { position: absolute; width: 40px; color: #05030a; opacity: .75; }
.bat-1 { top: 70px; right: 14vw; animation: flit 9s ease-in-out infinite; }
.bat-2 { top: 120px; right: 22vw; width: 26px; animation: flit 11s ease-in-out -3s infinite; }
.bat-3 { top: 40px; right: 30vw; width: 18px; animation: flit 13s ease-in-out -6s infinite; }
@keyframes flit {
  0%, 100% { transform: translate(0, 0) scaleY(1); }
  25% { transform: translate(-30px, 12px) scaleY(.7); }
  50% { transform: translate(-10px, -10px) scaleY(1); }
  75% { transform: translate(20px, 6px) scaleY(.75); }
}
@media (prefers-reduced-motion: reduce) { .bat { animation: none; } }

/* --- En-tête et filtres ---------------------------------------------------------- */
.site-header, .filters, main, .site-footer { position: relative; z-index: 1; max-width: 1320px; margin: 0 auto; padding: 0 20px; }

.site-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 36px; }
.home-link { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--ink-3); text-decoration: none; }
.home-link:hover, .home-link:focus-visible { color: var(--ink); }
.brand h1 {
  margin: 0; font: 400 clamp(40px, 6vw, 64px)/1 var(--font-display); letter-spacing: 2px; color: var(--ink);
  text-shadow: 0 0 24px rgba(232, 101, 15, .35);
}
.brand h1 em { font-style: normal; color: var(--pumpkin-glow); }
.brand-pumpkin { font-size: .8em; }
.tagline { margin: 8px 0 0; color: var(--ink-2); }

.status {
  display: flex; flex-direction: column; gap: 2px; text-align: right; font-size: 13px; color: var(--ink-2);
  background: rgba(24, 18, 31, .7); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.status strong { color: var(--ink); font-weight: 600; }
.status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--toxic); margin-right: 6px; box-shadow: 0 0 8px var(--toxic); }
.status.stale .dot { background: var(--blood); box-shadow: 0 0 8px var(--blood); }
.status .warn { color: #ffb36b; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 24px; margin-bottom: 20px; }

.tz-note { margin: 0 0 0 auto; font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 640px) { .tz-note { margin-left: 0; } }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  font: 500 13px var(--font); color: var(--ink-2); background: transparent; border: 0; border-radius: 7px;
  padding: 7px 12px; cursor: pointer; min-height: 32px;
}
.segmented button:hover { color: var(--ink); background: var(--surface-2); }
.segmented button[aria-checked="true"] { color: #1a0d05; background: var(--pumpkin); font-weight: 600; }
.segmented.small button { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.segmented .count { margin-left: 3px; opacity: .75; font-variant-numeric: tabular-nums; }
/* Bouton de l'événement : mis en avant, à part du sélecteur de période */
.purge-btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 8px 18px 9px; border-radius: 10px; cursor: pointer; text-align: left; color: #fff;
  border: 1px solid #ff5a6e; background: linear-gradient(135deg, #6e1120, #c62f45);
  box-shadow: 0 8px 26px -10px rgba(210, 58, 79, .9);
  transition: filter .15s ease, box-shadow .15s ease;
}
.purge-btn[hidden] { display: none; }
.purge-btn:hover { filter: brightness(1.15); }
.purge-btn[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #ff8a9a, 0 8px 26px -10px rgba(210, 58, 79, .9); }
.purge-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.purge-name { font: 400 24px/1 var(--font-display); letter-spacing: 1.5px; }
.purge-when { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1.2 var(--font); color: #ffd6dc; }
.purge-when .live { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; animation: live 1.4s ease-in-out infinite; }
@keyframes live { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .purge-when .live { animation: none; } }
@media (max-width: 640px) { .purge-btn { width: 100%; } }

/* --- KPI ------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi.hero { border-color: rgba(232, 101, 15, .45); box-shadow: inset 0 0 40px rgba(232, 101, 15, .08); }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.kpi-value { font-size: 32px; font-weight: 700; line-height: 1.15; margin-top: 4px; color: var(--ink); }
.kpi.hero .kpi-value { font-size: 40px; color: var(--pumpkin-glow); }
.kpi-value.is-name { font-size: 22px; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.kpi-sub .up { color: #ffb36b; }
.kpi-sub .down { color: #b9a3f2; }
.kpi-sub .warn { color: #ffb36b; }

/* --- Grille de cartes ------------------------------------------------------------ */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  min-width: 0;
}
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1000px) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}
.card-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.card-head h2::before { content: "✦"; color: var(--pumpkin); margin-right: 8px; font-size: 12px; vertical-align: 2px; }
.card-head .sub { margin: 4px 0 14px; font-size: 13px; color: var(--ink-3); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

.footnote { font-size: 12.5px; color: var(--ink-2); margin: 10px 0 0; }

.data-view { margin-top: 12px; font-size: 13px; }
.data-view summary { cursor: pointer; color: var(--ink-3); }
.data-view summary:hover { color: var(--ink-2); }
.data-view[open] summary { margin-bottom: 8px; }

/* --- Tableaux -------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; position: sticky; top: 0; background: var(--surface); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: rgba(255, 255, 255, .025); }
td.rank { color: var(--ink-3); width: 1%; font-variant-numeric: tabular-nums; }
td.muted { color: var(--ink-3); }
.empty { color: var(--ink-3); font-style: italic; padding: 18px 4px; }

.player-link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(255, 143, 51, .35); text-underline-offset: 3px;
}
.player-link:hover, .player-link:focus-visible { color: var(--pumpkin-glow); text-decoration-color: var(--pumpkin-glow); }
.wings { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; image-rendering: pixelated; }
.wings.none { display: inline-block; }
.lvl { color: var(--ink-3); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.vs { color: var(--blood); margin: 0 6px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; line-height: 1; padding: 4px 7px; border-radius: 999px;
  border: 1px solid currentColor; letter-spacing: .02em;
}
.badge.pvp { color: var(--pumpkin-glow); }
.badge.monster { color: #b9a3f2; }
.badge.suicide { color: var(--ink-3); }
.badge.suspect { color: #ffb36b; border-style: solid; }
.badge.todo { color: var(--ink-2); border-style: dashed; }
.gap-pos { color: #ffb36b; }
.gap-neg { color: #b9a3f2; }

/* --- Connectés maintenant -------------------------------------------------------- */
.online-list { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; columns: 2 180px; column-gap: 16px; }
.online-list li { break-inside: avoid; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.online-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Heatmap --------------------------------------------------------------------- */
.heatmap { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10.5px; color: var(--ink-3); }
.heatmap .cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); min-height: 10px; }
.heatmap .cell:hover, .heatmap .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.heatmap .rowlabel { display: flex; align-items: center; }
.heatmap .collabel { text-align: center; }
.scale-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.scale-legend .sw { width: 18px; height: 10px; border-radius: 2px; }

/* --- Exclusions ------------------------------------------------------------------ */
.exclusions { margin-top: 16px; }
.excl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.excl-toolbar input[type="search"] {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  font: 13.5px var(--font); padding: 8px 10px; min-width: 220px;
}
.excl-toolbar input[type="search"]:focus { outline: 2px solid var(--pumpkin); outline-offset: 1px; }
.excl-pending { font-size: 13px; color: #ffb36b; margin-left: auto; }
.btn {
  font: 600 13px var(--font); color: #1a0d05; background: var(--pumpkin); border: 1px solid var(--pumpkin);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; min-height: 32px;
}
.btn:hover { background: var(--pumpkin-glow); }
.btn.ghost { color: var(--ink-2); background: transparent; border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink-3); }
.btn.mini { font-size: 12px; padding: 4px 9px; min-height: 26px; }
.btn:disabled { opacity: .4; cursor: default; }
td .local { font-size: 11px; color: #ffb36b; margin-left: 6px; }

/* --- Bandeau d'erreur, pied de page, infobulle ----------------------------------- */
.error-banner { background: rgba(210, 58, 79, .12); border: 1px solid rgba(210, 58, 79, .5); color: #ffc7cf; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.event-notice {
  background: var(--surface); border: 1px solid rgba(210, 58, 79, .45); border-left: 4px solid var(--blood);
  color: var(--ink-2); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
}
.event-notice strong { color: #ff8a9a; }
.site-footer { color: var(--ink-3); font-size: 12.5px; padding-top: 28px; padding-bottom: 40px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: #0f0b14; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.tooltip strong { color: var(--ink); }

/* --- Fiche joueur ---------------------------------------------------------------- */
dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, .7);
}
dialog::backdrop { background: rgba(5, 3, 10, .72); backdrop-filter: blur(2px); }
.dialog-inner { padding: 22px 24px; }
.pd-head { display: flex; align-items: center; gap: 14px; }
.pd-head img { width: 32px; height: 32px; image-rendering: pixelated; }
.pd-head h2 { margin: 0; font: 400 34px/1.1 var(--font-display); letter-spacing: 1px; color: var(--pumpkin-glow); }
.pd-head .meta { color: var(--ink-2); font-size: 13px; }
.pd-close { margin-left: auto; align-self: flex-start; }
.pd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 18px 0; }
.pd-stats .kpi { padding: 12px 14px; }
.pd-stats .kpi-value { font-size: 26px; }
.pd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pd-cols h3, .dialog-inner h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 16px 0 6px; }
@media (max-width: 640px) { .pd-cols { grid-template-columns: 1fr; } }
.pd-event { margin-top: 20px; padding: 4px 16px 14px; border: 1px solid rgba(210, 58, 79, .45); border-radius: 12px; background: rgba(210, 58, 79, .05); }
.dialog-inner .pd-event > h3 { color: #ff8a9a; }
.pd-event > h3 span { margin-left: 6px; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; }
.pd-event .pd-stats { margin: 10px 0 4px; }
.kpi-value .of { font-size: .55em; font-weight: 500; color: var(--ink-3); }

@media (max-width: 640px) {
  .site-header, .filters, main, .site-footer { padding: 0 16px; }
  .site-header { padding-top: 24px; }
  .status { text-align: left; }
  .moon { width: 52px; height: 52px; top: 14px; right: 16px; }
  .bat-2, .bat-3 { display: none; }
  .card { padding: 16px; }
  .heatmap { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 1px; font-size: 9px; }
  .excl-pending { margin-left: 0; }
  .segmented { flex-wrap: wrap; }
}
