/* ============================================================
   Interférences — Feuille de styles
   Jeu de puzzle ondulatoire basé sur la superposition d'ondes.

   Organisation :
     1. RESET & BASE        — Styles globaux (body, police, fond)
     2. HEADER              — Titre et sous-titre
     3. LAYOUT              — Grille principale (canvas + panneau)
     4. GRID                — La grille de jeu (canvas HTML5)
     5. PANEL               — Panneau latéral de contrôle
     6. EMITTER LIST        — Liste des émetteurs placés
     7. SLIDERS             — Contrôles fréquence/phase/amplitude
     8. BUTTONS             — Boutons d'action
     9. LEGEND              — Légende des couleurs
    10. MODAL               — Fenêtre modale des règles
   ============================================================ */

/* ──────────────────────────────────────────────
   1. RESET & BASE
   ────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0d1117;               /* Fond sombre GitHub-style */
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* ──────────────────────────────────────────────
   2. HEADER
   ────────────────────────────────────────────── */
h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  /* Dégradé de couleur sur le texte (bleu → violet → rose) */
  background: linear-gradient(90deg, #58a6ff, #bc8cff, #f778ba);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.85rem;
  color: #8b949e;
  margin-bottom: 16px;
}

/* ──────────────────────────────────────────────
   3. LAYOUT — Grille + Panneau côte à côte
   ────────────────────────────────────────────── */
.layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;                   /* Passe en colonne sur petit écran */
  justify-content: center;
}

/* ──────────────────────────────────────────────
   4. GRID — Canvas de jeu
   ────────────────────────────────────────────── */
.grid-container {
  position: relative;
}

canvas {
  border: 2px solid #30363d;
  border-radius: 8px;
  cursor: crosshair;                 /* Curseur en croix pour la précision */
  display: block;
}

.grid-label {
  text-align: center;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #8b949e;
}

/* ──────────────────────────────────────────────
   5. PANEL — Panneau de contrôle latéral
   ────────────────────────────────────────────── */
.panel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel h2 {
  font-size: 1rem;
  color: #58a6ff;
  margin-bottom: 2px;
}

/* ──────────────────────────────────────────────
   6. EMITTER LIST — Liste des émetteurs
   ────────────────────────────────────────────── */
.emitter-list {
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;                  /* Scroll si trop d'émetteurs */
}

/* Une ligne = un émetteur dans la liste */
.emitter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 0.8rem;
  border: 1px solid #30363d;
  cursor: pointer;
}

/* Surbrillance orange quand l'émetteur est sélectionné */
.emitter-row.selected {
  border-color: #f0883e;
  background: #1c2128;
}

/* Pastille de couleur indiquant l'émetteur */
.emitter-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Infos textuelles : position + paramètres */
.emitter-info {
  flex: 1;
}

/* Bouton × pour supprimer un émetteur */
.emitter-delete {
  background: none;
  border: none;
  color: #f85149;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  line-height: 1;
}

/* ──────────────────────────────────────────────
   7. SLIDERS — Contrôles de fréquence/phase/amplitude
   ────────────────────────────────────────────── */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-group label {
  display: flex;
  justify-content: space-between;     /* Nom à gauche, valeur à droite */
  font-size: 0.75rem;
  color: #8b949e;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: #58a6ff;             /* Curseur bleu */
}

/* ──────────────────────────────────────────────
   8. BUTTONS
   ────────────────────────────────────────────── */
.btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn:hover {
  background: #30363d;
}

/* Bouton principal (vert) */
.btn.primary {
  background: #238636;
  border-color: #2ea043;
  color: #fff;
}

.btn.primary:hover {
  background: #2ea043;
}

/* Groupe de boutons alignés horizontalement */
.btn-row {
  display: flex;
  gap: 6px;
}

/* ──────────────────────────────────────────────
   9. LEGEND — Légende des couleurs sous la grille
   ────────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 12px;
  font-size: 0.7rem;
  color: #8b949e;
  align-items: center;
  margin-top: 4px;
}

.legend span {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

/* ──────────────────────────────────────────────
   10. MODAL — Fenêtre modale des règles
   ────────────────────────────────────────────── */

/* Overlay semi-transparent couvrant tout l'écran */
.modal-overlay {
  display: none;                       /* Caché par défaut */
  position: fixed;
  inset: 0;                            /* top/right/bottom/left = 0 */
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

/* Affiché via la classe .show ajoutée en JS */
.modal-overlay.show {
  display: flex;
}

/* Boîte de la modale */
.modal {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 560px;
  max-height: 80vh;                    /* Limite la hauteur à 80% de l'écran */
  overflow-y: auto;                    /* Scroll si le contenu dépasse */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal h2 {
  color: #58a6ff;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.modal h3 {
  color: #bc8cff;
  margin: 14px 0 6px;
  font-size: 0.95rem;
}

.modal p,
.modal li {
  font-size: 0.82rem;
  line-height: 1.55;
  color: #8b949e;
}

.modal code {
  background: #21262d;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
  color: #f0883e;
}

/* Tableaux dans la modale (paramètres, commandes) */
.modal table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.78rem;
}

.modal th {
  text-align: left;
  color: #c9d1d9;
  padding: 4px 8px;
  border-bottom: 1px solid #30363d;
}

.modal td {
  padding: 4px 8px;
  border-bottom: 1px solid #21262d;
  color: #8b949e;
}

/* Bouton de fermeture (✕) */
.modal-close {
  float: right;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: #f85149;                      /* Rouge au survol */
}
