/* ============================================================
 * GitQuest — Feuille de style (style.css)
 * Thème : terminal sombre, accents par niveau.
 * ============================================================ */

:root {
  --bg: #0d1117;
  --bg-panel: #161b22;
  --bg-elevated: #1c2330;
  --border: #2d333b;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --orange: #db6d28;
  --pink: #f472b6;
  --purple: #bc8cff;
  --cyan: #39c5cf;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  overflow: hidden;
}

.screen { height: 100vh; width: 100vw; }

/* ============ BOUTONS ============ */
.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #4c8dff; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-elevated); }
.btn-hint {
  background: rgba(210, 153, 34, 0.12);
  border-color: rgba(210, 153, 34, 0.4);
  color: var(--yellow);
  width: 100%;
}
.mini-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  width: 22px; height: 22px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); }

/* ============ ÉCRAN ACCUEIL ============ */
#screen-home {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1a2332 0%, var(--bg) 70%);
  overflow-y: auto;
  padding: 40px 20px;
}
.home-card {
  max-width: 720px;
  width: 100%;
  text-align: center;
}
.logo {
  font-family: var(--font-mono);
  font-size: 52px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--green), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  color: var(--text-dim);
  font-size: 18px;
  margin-bottom: 24px;
}
.home-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.home-stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 22px;
  min-width: 130px;
}
.home-stat .num { font-size: 26px; font-weight: 700; font-family: var(--font-mono); }
.home-stat .lbl { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

/* Carte des niveaux */
.level-map {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 28px;
  text-align: left;
}
.level-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.level-node {
  flex: 1;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.level-node:hover:not(.locked) { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.level-node.locked { opacity: 0.45; cursor: not-allowed; }
.level-node.current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88,166,255,0.15); }
.level-node.done { border-color: var(--green); }
.level-node .lv-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 6px;
}
.level-node .lv-name { font-size: 16px; font-weight: 700; }
.level-node .lv-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.level-node .lv-progress { font-size: 11px; color: var(--text-dim); margin-top: 8px; font-family: var(--font-mono); }
.level-connector {
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  font-size: 18px;
}
.home-actions { display: flex; gap: 12px; justify-content: center; }
.home-footer { color: var(--text-dim); font-size: 12px; margin-top: 20px; }

/* ============ TOPBAR ============ */
#topbar {
  height: 52px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.scenario-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.level-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  white-space: nowrap;
}
.xp-block { display: flex; align-items: center; gap: 8px; }
.player-level {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.xp-bar {
  width: 120px;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 4px;
  transition: width 0.4s ease;
}
.xp-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.total-xp { font-family: var(--font-mono); font-size: 12px; color: var(--yellow); font-weight: 700; }

/* ============ LAYOUT JEU ============ */
#game-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  height: calc(100vh - 52px);
  overflow: hidden;
}
#sidebar, #state-pane {
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#sidebar { border-right: 1px solid var(--border); }
#state-pane { border-left: 1px solid var(--border); }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.panel h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mission */
#mission-story { font-size: 13px; line-height: 1.5; color: var(--text); }
.mission-goal {
  margin-top: 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(88,166,255,0.08);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
  min-height: 20px;
}
.btn-validate {
  width: 100%;
  margin-top: 10px;
  font-size: 14px;
  padding: 10px 16px;
}
.btn-validate-ready {
  animation: pulse-glow 1.5s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); }
}
.hint-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.btn-solution {
  background: rgba(244, 114, 182, 0.12);
  border-color: rgba(244, 114, 182, 0.4);
  color: var(--pink);
}
.btn-solution:disabled {
  opacity: 0.5;
  cursor: default;
}
.hint-box {
  margin-top: 8px;
  font-size: 12px;
  background: rgba(210,153,34,0.08);
  border: 1px dashed rgba(210,153,34,0.4);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--yellow);
  line-height: 1.5;
}

/* Arborescence fichiers */
.file-tree { font-family: var(--font-mono); font-size: 12px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.file-item:hover { background: var(--bg-panel); }
.file-item.modified { color: var(--yellow); }
.file-item.staged { color: var(--green); }
.file-item.untracked { color: var(--text-dim); }
.file-item.conflicted { color: var(--red); }
.file-item .f-icon { width: 14px; }
.file-item .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.file-item .f-badge { font-size: 9px; padding: 1px 5px; border-radius: 8px; background: var(--bg-panel); }

/* Branches */
.branch-list { font-family: var(--font-mono); font-size: 12px; }
.branch-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
}
.branch-item.current { background: rgba(63,185,80,0.12); color: var(--green); font-weight: 700; }
.branch-item .b-hash { color: var(--text-dim); font-size: 10px; }

/* ============ ÉTAT / STATUS ============ */
#terminal-pane {
  display: flex;
  flex-direction: column;
  background: #0a0e14;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.terminal {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
#terminal-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}
.t-line { white-space: pre-wrap; word-break: break-word; }
.t-cmd { color: var(--text); }
.t-cmd .t-prompt { color: var(--green); font-weight: 700; }
.t-out { color: var(--text-dim); }
.t-out.ok { color: var(--text); }
.t-out.err { color: var(--red); }
.t-out .diff-add { color: var(--green); display: block; }
.t-out .diff-del { color: var(--red); display: block; }
.t-out .diff-ctx { color: var(--text-dim); display: block; }
.t-out .diff-hunk { color: var(--cyan); display: block; }
.t-out .diff-meta { color: var(--purple); display: block; }
.t-info { color: var(--accent); }
.t-success { color: var(--green); font-weight: 700; }
.t-warn { color: var(--yellow); }

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.prompt { color: var(--green); font-weight: 700; white-space: nowrap; }
#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  caret-color: var(--green);
}

/* ============ ÉTAT / STATUS ============ */
.git-status { font-family: var(--font-mono); font-size: 11px; line-height: 1.7; }
.git-status .st-clean { color: var(--green); }
.git-status .st-branch { color: var(--accent); font-weight: 700; }
.git-status .st-staged { color: var(--green); }
.git-status .st-unstaged { color: var(--yellow); }
.git-status .st-untracked { color: var(--red); }
.git-status .st-conflict { color: var(--red); font-weight: 700; }

/* Graphe de commits */
.commit-graph {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}
.cg-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.cg-node { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cg-hash { color: var(--text-dim); }
.cg-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-deco { font-size: 9px; padding: 0 5px; border-radius: 8px; }

/* Diff */
.diff-view {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
}

/* ============ MODALES ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 13px;
}
#modal-file-content {
  flex: 1;
  min-height: 300px;
  background: #0a0e14;
  color: var(--text);
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  padding: 14px;
  resize: none;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Modale victoire */
.modal-win { text-align: center; padding: 30px; }
.win-emoji { font-size: 64px; margin-bottom: 10px; }
.modal-win h2 { margin-bottom: 10px; }
#win-message { color: var(--text-dim); line-height: 1.6; margin-bottom: 16px; }
.win-rewards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.reward-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.reward-chip.xp { color: var(--yellow); border-color: var(--yellow); }
.reward-chip.badge { color: var(--pink); border-color: var(--pink); }
.reward-chip.level { color: var(--accent); border-color: var(--accent); }

/* Badges */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}
.badge-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}
.badge-card.locked { opacity: 0.35; filter: grayscale(1); }
.badge-card .b-emoji { font-size: 32px; }
.badge-card .b-name { font-size: 12px; font-weight: 700; margin-top: 6px; }
.badge-card .b-desc { font-size: 10px; color: var(--text-dim); margin-top: 4px; line-height: 1.4; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  #game-layout { grid-template-columns: 220px 1fr 240px; }
}
@media (max-width: 860px) {
  #game-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  #sidebar, #state-pane { max-height: 200px; border: none; border-bottom: 1px solid var(--border); }
  #state-pane { border-bottom: none; border-top: 1px solid var(--border); }
  .xp-bar { width: 70px; }
}
