/* ===================================================================
   Affaire Licorne — thème sombre contemporain
   =================================================================== */

:root {
  --fond: #0b0e1c;
  --fond-2: #10142a;
  --carte: #151a33;
  --carte-2: #1b2142;
  --bord: #262d52;
  --texte: #e6e9f5;
  --texte-2: #9aa3c7;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #ef4444;
  --ok: #22c55e;
  --ambre: #f59e0b;
  --radius: 14px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, .14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, .10), transparent 60%),
    var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
}

button { font-family: inherit; }
code { font-family: var(--mono); background: rgba(139, 92, 246, .15); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
pre { font-family: var(--mono); }

/* ---------------- Écran de chargement ---------------- */
#chargement {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--fond);
}
.chargement-carte { text-align: center; color: var(--texte-2); }
.chargement-logo { font-size: 56px; animation: flotte 1.6s ease-in-out infinite; }
.chargement-carte h1 { color: var(--texte); letter-spacing: .06em; margin: 10px 0 6px; }
@keyframes flotte { 50% { transform: translateY(-8px); } }

/* ---------------- Barre du haut ---------------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  height: 64px; padding: 0 20px;
  background: rgba(16, 20, 42, .85);
  border-bottom: 1px solid var(--bord);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 30px; filter: drop-shadow(0 0 12px rgba(139, 92, 246, .8)); }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .05em; text-transform: uppercase; }
.brand-sub { font-size: 12px; color: var(--texte-2); }

.progress-wrap { flex: 1; max-width: 420px; margin-left: auto; }
.progress-label { font-size: 12px; color: var(--texte-2); display: block; margin-bottom: 5px; }
.progress-label strong { color: var(--accent-2); }
.progress-bar {
  height: 8px; border-radius: 99px; overflow: hidden;
  background: var(--carte-2); border: 1px solid var(--bord);
}
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width .6s cubic-bezier(.2, .9, .3, 1.2);
}

.topbar-actions { display: flex; gap: 10px; }

/* ---------------- Boutons ---------------- */
.btn {
  border: 1px solid var(--bord); border-radius: 10px;
  background: var(--carte-2); color: var(--texte);
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); background: #232a52; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-color: transparent;
}
.btn-primary:hover { box-shadow: 0 4px 18px rgba(139, 92, 246, .45); background: linear-gradient(135deg, #9d71f8, #7c3aed); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: transparent; }
.btn-danger:hover { box-shadow: 0 4px 18px rgba(239, 68, 68, .4); }
.btn-ghost { background: transparent; }
.btn-mini { padding: 6px 10px; font-size: 13px; }
.btn-large { padding: 13px 30px; font-size: 16px; }

/* ---------------- Mise en page ---------------- */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 16px; padding: 16px;
  height: calc(100vh - 64px);
}
.workbench { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--bord);
  background: rgba(27, 33, 66, .6);
}
.card-head h2 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .1em; color: var(--texte-2); }
.card-head-actions { display: flex; align-items: center; gap: 10px; }
.kbd-hint { font-size: 11px; color: var(--texte-2); border: 1px solid var(--bord); border-radius: 6px; padding: 3px 7px; }

/* ---------------- Éditeur ---------------- */
.editor-card { flex: 0 0 auto; }
.CodeMirror {
  height: 170px;
  background: #0d1226;
  color: #dde3f8;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 6px 2px;
}
.CodeMirror-gutters { background: #0d1226; border-right: 1px solid var(--bord); }
.CodeMirror-linenumber { color: #3d4670; }
.CodeMirror-cursor { border-left: 2px solid var(--accent-2); }
.CodeMirror-selected { background: rgba(139, 92, 246, .25) !important; }
.cm-s-licorne .cm-keyword { color: #c084fc; font-weight: 600; }
.cm-s-licorne .cm-string { color: #86efac; }
.cm-s-licorne .cm-number { color: #fbbf24; }
.cm-s-licorne .cm-comment { color: #64748b; font-style: italic; }
.cm-s-licorne .cm-operator { color: #22d3ee; }
.cm-s-licorne .cm-builtin, .cm-s-licorne .cm-atom { color: #f472b6; }
.cm-s-licorne .cm-variable-2 { color: #93c5fd; }

/* Historique */
#historique {
  display: none; max-height: 180px; overflow: auto;
  border-bottom: 1px solid var(--bord); background: var(--fond-2);
  padding: 8px;
}
#historique.open { display: block; }
.hist-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--texte-2);
  font-family: var(--mono); font-size: 12px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-item:hover { background: var(--carte-2); color: var(--texte); }
.hist-vide { color: var(--texte-2); font-size: 13px; padding: 6px 8px; }

/* ---------------- Résultats ---------------- */
.results-card { flex: 1; min-height: 0; }
#results { flex: 1; overflow: auto; padding: 0; }
#results-meta { font-size: 12px; color: var(--accent-2); }
.results-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.results-table th {
  position: sticky; top: 0;
  background: var(--carte-2); color: var(--accent-2);
  text-align: left; padding: 9px 12px;
  font-weight: 600; border-bottom: 1px solid var(--bord);
  white-space: nowrap;
}
.results-table td {
  padding: 7px 12px; border-bottom: 1px solid rgba(38, 45, 82, .5);
  color: var(--texte); max-width: 480px; overflow-wrap: break-word;
  font-family: var(--mono); font-size: 12.5px;
}
.results-table tr:hover td { background: rgba(139, 92, 246, .07); }
.results-table .nul { color: var(--texte-2); font-style: italic; }
.sql-error {
  margin: 16px; padding: 14px 16px; border-radius: 10px;
  background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5; font-size: 14px; line-height: 1.5;
}
.sql-empty { margin: 16px; color: var(--texte-2); font-size: 14px; }

/* ---------------- Panneaux (onglets) ---------------- */
.panels { min-height: 0; }
.tabs {
  display: flex; border-bottom: 1px solid var(--bord);
  background: rgba(27, 33, 66, .6);
}
.tabs button {
  flex: 1; padding: 12px 6px; border: none; background: none;
  color: var(--texte-2); font-size: 13px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tabs button:hover { color: var(--texte); }
.tabs button.active { color: var(--texte); border-bottom-color: var(--accent); }
.tab-badge {
  display: inline-block; min-width: 17px; padding: 1px 5px;
  border-radius: 99px; background: var(--accent);
  color: white; font-size: 10.5px; text-align: center;
}
.tab-badge:empty { display: none; }
.tab-panel { display: none; overflow: auto; flex: 1; padding: 14px; }
.tab-panel.active { display: block; }

/* ---------------- Carte ---------------- */
.carte-svg { width: 100%; height: auto; display: block; }
.carte-titre { fill: var(--texte-2); font-size: 13px; letter-spacing: .25em; font-weight: 700; }
.carte-nord { fill: var(--texte-2); font-size: 11px; }
.batiment { fill: rgba(27, 33, 66, .55); stroke: var(--bord); stroke-width: 1.5; }
.batiment.sous-sol { fill: rgba(16, 20, 42, .7); stroke-dasharray: 6 5; }
.rue rect { fill: #1a1f38; }
.rue line { stroke: #3d4670; stroke-width: 2; stroke-dasharray: 14 12; }
.rue text { fill: #5b6493; font-size: 9px; letter-spacing: .2em; text-transform: uppercase; }

.salle { cursor: pointer; }
.salle rect {
  fill: #10142a; stroke: #333c6b; stroke-width: 1.4;
  transition: fill .3s, stroke .3s;
}
.salle text { fill: #566093; font-size: 11.5px; pointer-events: none; transition: fill .3s; }
.salle:hover rect { stroke: var(--accent-2); }
.salle.lit rect { fill: rgba(139, 92, 246, .2); stroke: var(--accent); }
.salle.lit text { fill: #d6c6ff; }
.salle.crime rect {
  fill: rgba(239, 68, 68, .18); stroke: var(--danger);
  animation: pulse-crime 2.2s ease-in-out infinite;
}
.salle.crime text { fill: #fda4af; }
@keyframes pulse-crime {
  50% { stroke-width: 3; }
}
#map-caption {
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--bord); border-radius: 10px;
  background: var(--fond-2); color: var(--texte-2);
  font-size: 13px; line-height: 1.5; min-height: 42px;
}

/* ---------------- Suspects ---------------- */
#suspects { display: grid; grid-template-columns: 1fr; gap: 10px; }
.suspect {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px; border-radius: 12px;
  background: var(--fond-2); border: 1px solid var(--bord);
  transition: border-color .3s;
}
.suspect:not(.cache):hover { border-color: var(--accent); }
.suspect-avatar { width: 66px; flex: 0 0 66px; }
.suspect-avatar svg { width: 100%; height: auto; border-radius: 50%; }
.suspect.cache { opacity: .55; }
.suspect-nom { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.suspect-role { color: var(--texte-2); font-size: 13px; margin-top: 2px; }
.suspect-notes { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: #c7cdec; line-height: 1.5; }
.suspect-notes li { margin-bottom: 3px; }
.suspect-notes li::marker { color: var(--accent-2); }
.badge {
  font-size: 10px; padding: 2px 8px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.badge-victime { background: rgba(239, 68, 68, .2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, .5); }
.badge-temoin { background: rgba(34, 211, 238, .15); color: #67e8f9; border: 1px solid rgba(34, 211, 238, .4); }

/* ---------------- Carnet ---------------- */
.carnet-vide { color: var(--texte-2); text-align: center; padding: 46px 20px; line-height: 1.8; }
.carnet-liste { position: relative; padding-left: 8px; }
.carnet-item { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.carnet-item:not(:last-child)::before {
  content: ""; position: absolute; left: 15px; top: 34px; bottom: -2px;
  width: 2px; background: linear-gradient(var(--accent), rgba(139, 92, 246, .15));
}
.carnet-num {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  font-weight: 800; font-size: 14px; z-index: 1;
}
.carnet-titre { font-weight: 700; margin-bottom: 4px; }
.carnet-texte { color: #c7cdec; font-size: 13.5px; line-height: 1.6; }

/* ---------------- Schéma ---------------- */
.schema-note {
  font-size: 12.5px; color: var(--texte-2); line-height: 1.6;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond-2);
}
.schema-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.schema-table {
  border: 1px solid var(--bord); border-radius: 10px;
  background: var(--fond-2); padding: 10px 12px; cursor: pointer;
  transition: border-color .2s, transform .12s;
}
.schema-table:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.schema-nom { font-family: var(--mono); font-weight: 700; color: var(--accent-2); margin-bottom: 6px; }
.schema-table ul { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 11.5px; color: #aeb6da; line-height: 1.7; }
.schema-fks { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.fk-chip {
  font-size: 10px; font-family: var(--mono);
  background: rgba(139, 92, 246, .16); color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, .4);
  padding: 2px 7px; border-radius: 99px;
}

#memo-sql { margin-top: 18px; }
#memo-sql h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--texte-2); }
.memo-item {
  border: 1px solid var(--bord); border-radius: 10px; background: var(--fond-2);
  padding: 8px 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .2s;
}
.memo-item:hover { border-color: var(--accent); }
.memo-titre { font-size: 12px; font-weight: 700; color: var(--texte-2); margin-bottom: 4px; }
.memo-item pre { margin: 0; font-size: 12px; color: #b6dcfe; white-space: pre-wrap; }

/* ---------------- Modales ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: none; place-items: center;
  background: rgba(5, 7, 18, .75); backdrop-filter: blur(4px);
  padding: 20px;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow: auto;
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: 18px; box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modal-in { from { transform: translateY(14px) scale(.98); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--bord);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
  background: none; border: none; color: var(--texte-2);
  font-size: 16px; cursor: pointer; padding: 6px;
}
.modal-close:hover { color: var(--texte); }
.modal-body { padding: 20px 22px; line-height: 1.65; font-size: 14.5px; }
.modal-body p { margin: 0 0 12px; }
.modal-foot { padding: 0 22px 22px; text-align: center; }

.modal-intro { text-align: left; }
.intro-banniere {
  text-align: center; padding: 34px 20px 22px;
  background:
    radial-gradient(400px 160px at 50% 0%, rgba(139, 92, 246, .35), transparent 70%),
    linear-gradient(180deg, #1b2142, var(--carte));
  border-bottom: 1px solid var(--bord);
}
.intro-banniere span { font-size: 52px; display: block; filter: drop-shadow(0 0 18px rgba(139, 92, 246, .9)); }
.intro-banniere h2 { margin: 10px 0 4px; font-size: 26px; letter-spacing: .1em; text-transform: uppercase; }
.intro-sous-titre { color: var(--texte-2); margin: 0; font-size: 13px; }
.intro-piste { background: var(--fond-2); border: 1px solid var(--bord); border-radius: 10px; padding: 12px 14px; }

/* Aides */
.hint-niveau { margin-bottom: 14px; }
.hint-reveal {
  width: 100%; text-align: left;
  background: var(--fond-2); border: 1px dashed var(--bord);
  color: var(--texte); border-radius: 10px; padding: 12px 14px;
  font-size: 14px; cursor: pointer; transition: border-color .2s;
}
.hint-reveal:hover { border-color: var(--accent); }
.hint-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-2); margin-bottom: 5px; }
.hint-sql {
  background: #0d1226; border: 1px solid var(--bord); border-radius: 10px;
  padding: 12px 14px; font-size: 13px; color: #b6dcfe;
  white-space: pre-wrap; margin: 0 0 8px;
}
.hint-copier {
  background: none; border: 1px solid var(--bord); color: var(--accent-2);
  border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.hint-copier:hover { border-color: var(--accent-2); }

/* Accusation */
#accuse-form { display: flex; gap: 10px; margin: 14px 0; }
#accuse-input {
  flex: 1; background: var(--fond-2); border: 1px solid var(--bord);
  border-radius: 10px; color: var(--texte); padding: 11px 14px; font-size: 15px;
}
#accuse-input:focus { outline: none; border-color: var(--accent); }
#accuse-feedback { min-height: 24px; font-size: 14px; line-height: 1.6; color: #fca5a5; }
.shake { animation: shake .4s; }
@keyframes shake {
  20% { transform: translateX(-9px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(4px); }
}

/* Fins */
.recap { margin: 16px 0; border: 1px solid var(--bord); border-radius: 12px; overflow: hidden; }
.recap-item {
  display: flex; gap: 14px; padding: 10px 14px; font-size: 13.5px;
  border-bottom: 1px solid rgba(38, 45, 82, .5); align-items: baseline;
}
.recap-item:last-child { border-bottom: none; }
.recap-item:nth-child(odd) { background: var(--fond-2); }
.recap-quand { flex: 0 0 110px; font-family: var(--mono); color: var(--ambre); font-weight: 700; font-size: 12.5px; }
.ending-merci { color: var(--texte-2); font-size: 13px; }

/* ---------------- Toasts ---------------- */
#toasts {
  position: fixed; left: 18px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  background: var(--carte-2); border: 1px solid var(--accent);
  border-radius: 12px; padding: 12px 16px;
  font-size: 13.5px; line-height: 1.5; cursor: pointer;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5), 0 0 0 1px rgba(139, 92, 246, .2);
  animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2);
}
.toast:hover { border-color: var(--accent-2); }
.toast.bye { opacity: 0; transform: translateX(-16px); transition: all .4s; }
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } }

/* ---------------- Confettis ---------------- */
.confettis { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confettis i {
  position: absolute; top: -14px; width: 9px; height: 14px;
  display: block; border-radius: 2px;
  animation: tombe linear forwards;
}
@keyframes tombe {
  to { transform: translateY(110vh) rotate(720deg); opacity: .7; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; height: auto; }
  .panels { min-height: 480px; }
  .results-card { min-height: 300px; }
  .progress-wrap { display: none; }
  .brand-sub { display: none; }
}
