:root {
  --bg: #0b0f17;
  --bg-glow: #12203a;
  --surface: #121826;
  --surface-2: #182033;
  --border: #232d44;
  --text: #e8edf7;
  --muted: #8d99b3;
  --accent: #3fa6c6;
  --ok: #3ccf8e;
  --warn: #f5b041;
  --bad: #ef5b5b;
  --none: #2c3550;
  --players: #3fa6c6;
  --matches: #a78bfa;
  --input: #0e1420;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --gutter: clamp(16px, 3vw, 32px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-glow: #dfe9fb;
    --surface: #ffffff;
    --surface-2: #f2f5fb;
    --border: #e1e6f0;
    --text: #141a28;
    --muted: #5d6882;
    --none: #d9dfeb;
    --input: #f7f9fc;
    --shadow: 0 10px 30px rgba(20, 30, 60, 0.08);
  }
}

/* L'attribut hidden doit toujours l'emporter sur le display des classes (sections, panneaux, info-bulles). */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(1200px 500px at 50% -10%, var(--bg-glow), transparent 70%), var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
}

/* En-tête */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.wordmark {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.wordmark:hover {
  text-decoration: none;
}

.wordmark-mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--matches));
  box-shadow: 0 0 18px rgba(63, 166, 198, 0.45);
}

.wordmark-text {
  font-weight: 800;
  letter-spacing: 0.22em;
  font-size: 17px;
}

.wordmark-sub {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

/* Boutons et champs */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--muted);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121a;
}

.button-ghost {
  background: transparent;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.field textarea {
  resize: vertical;
  min-height: 110px;
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Champ piège : invisible et hors du parcours clavier, seuls les robots le remplissent. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 91, 91, 0.12);
  color: var(--bad);
  font-size: 14px;
}

/* Disposition générale */

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

/* Placement automatique : une section masquée (incidents, signalements) ne laisse ni rangée vide ni espacement. */
.area-hero,
.area-incidents,
.area-signals,
.area-metrics,
.area-chart,
.area-history {
  grid-column: 1 / -1;
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Bandeau d'état */

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(18px, 2.4vw, 23px);
  font-weight: 700;
}

.hero p {
  margin: 2px 0 0;
  color: var(--muted);
}

.hero-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--none);
  position: relative;
}

.hero-icon::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
}

.hero[data-state="operational"] {
  border-color: rgba(60, 207, 142, 0.45);
}

.hero[data-state="operational"] .hero-icon {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(60, 207, 142, 0.15);
}

.hero[data-state="degraded"] {
  border-color: rgba(245, 176, 65, 0.5);
}

.hero[data-state="degraded"] .hero-icon {
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(245, 176, 65, 0.15);
}

.hero[data-state="outage"],
.hero[data-state="unreachable"] {
  border-color: rgba(239, 91, 91, 0.5);
}

.hero[data-state="outage"] .hero-icon,
.hero[data-state="unreachable"] .hero-icon {
  background: var(--bad);
  box-shadow: 0 0 0 6px rgba(239, 91, 91, 0.15);
}

@media (prefers-reduced-motion: no-preference) {
  .hero[data-state="operational"] .hero-icon {
    animation: pulse 2.4s ease-in-out infinite;
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 6px rgba(60, 207, 142, 0.15);
  }

  50% {
    box-shadow: 0 0 0 11px rgba(60, 207, 142, 0.05);
  }
}

/* Bandeau des signalements de joueurs */

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(245, 176, 65, 0.45);
  background: rgba(245, 176, 65, 0.08);
}

/* Compteurs */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Cartes */

.card {
  min-width: 0;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
}

.card-alert {
  border-color: rgba(239, 91, 91, 0.45);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.legend,
.uptime-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 13px;
}

.uptime-legend {
  margin-top: 12px;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch-players {
  background: var(--players);
}

.swatch-matches {
  background: var(--matches);
}

.swatch-ok {
  background: var(--ok);
}

.swatch-warn {
  background: var(--warn);
}

.swatch-bad {
  background: var(--bad);
}

.swatch-none {
  background: var(--none);
}

/* Courbe */

.chart {
  position: relative;
  min-height: 200px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 200px;
  overflow: visible;
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--muted);
  font-size: 11px;
}

.chart .area {
  fill: var(--players);
  opacity: 0.16;
}

.chart .line-players {
  fill: none;
  stroke: var(--players);
  stroke-width: 2;
}

.chart .line-matches {
  fill: none;
  stroke: var(--matches);
  stroke-width: 2;
}

.chart .cursor {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
}

.chart-tip {
  position: absolute;
  top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.empty {
  margin: 0;
  padding: 70px 0;
  text-align: center;
  color: var(--muted);
}

/* Services */

.components {
  list-style: none;
  margin: 0;
  padding: 0;
}

.component {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.component:first-child {
  border-top: none;
  padding-top: 0;
}

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pill-operational {
  color: var(--ok);
  background: rgba(60, 207, 142, 0.12);
}

.pill-degraded {
  color: var(--warn);
  background: rgba(245, 176, 65, 0.14);
}

.pill-outage {
  color: var(--bad);
  background: rgba(239, 91, 91, 0.14);
}

.pill-info {
  color: var(--accent);
  background: rgba(63, 166, 198, 0.14);
}

/* Disponibilité */

.uptime-total {
  color: var(--muted);
  font-size: 13px;
}

.uptime {
  display: grid;
  grid-template-columns: repeat(90, minmax(0, 1fr));
  gap: 2px;
  height: 36px;
}

.uptime-day {
  border-radius: 2px;
  background: var(--none);
  cursor: default;
}

.uptime-day[data-level="ok"] {
  background: var(--ok);
}

.uptime-day[data-level="warn"] {
  background: var(--warn);
}

.uptime-day[data-level="bad"] {
  background: var(--bad);
}

.uptime-day:hover,
.uptime-day:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.uptime-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.uptime-tip {
  position: absolute;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* Incidents */

.incident-list {
  display: grid;
  gap: 14px;
}

.incident {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.incident-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 4px;
}

.incident-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.incident-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 10px;
}

.timeline li {
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.timeline-status {
  font-weight: 650;
  font-size: 13px;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}

.timeline-message {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

/* Fenêtre « Signaler un problème » */

.dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.dialog::backdrop {
  background: rgba(5, 8, 14, 0.6);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog-body h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-body p {
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Pied de page */

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 2px 0;
}

/* Petits écrans */

@media (max-width: 720px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    padding: 18px;
    gap: 14px;
  }

  .hero-icon {
    width: 36px;
    height: 36px;
  }

  .hero-icon::after {
    inset: 11px;
  }

  .card {
    padding: 18px 16px;
  }

  .uptime {
    gap: 1px;
  }
}

@media (max-width: 520px) {
  .wordmark-sub {
    display: none;
  }

  .wordmark-text {
    letter-spacing: 0.14em;
    font-size: 15px;
  }

  .topbar .button {
    padding: 8px 12px;
    font-size: 14px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
  }
}
