/* ══════════════════════════════════════════
   LinuxShell — NSI Games
══════════════════════════════════════════ */

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

:root {
  --bg:      #0d1117;
  --bg2:     #161b22;
  --bg3:     #1c2128;
  --border:  #30363d;
  --text:    #c9d1d9;
  --muted:   #8b949e;
  --blue:    #58a6ff;
  --green:   #3fb950;
  --yellow:  #e3b341;
  --orange:  #f0883e;
  --red:     #f85149;
  --purple:  #d2a8ff;
  --cyan:    #79c0ff;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; }

body { background: var(--bg); color: var(--text); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.hidden { display: none !important; }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: .72rem;
  font-family: 'Courier New', monospace;
  background: #21262d;
  color: var(--cyan);
  border: 1px solid #30363d;
}

/* ════════════════════════════════════════════
   ÉCRAN D'ACCUEIL
════════════════════════════════════════════ */
#screen-start { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ──── */
.start-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 40px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.start-brand {
  font-family: 'Courier New', monospace;
  font-size: .9rem;
  color: var(--green);
  letter-spacing: .04em;
}

.btn-back {
  font-size: .85rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.btn-back:hover { color: var(--text); background: var(--bg3); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--blue); }

/* ── Hero ──── */
.start-hero {
  padding: 52px 64px 44px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  flex-shrink: 0;
}

.start-hero::after {
  content: '';
  position: absolute;
  top: -100px;
  left: -100px;
  width: 520px;
  height: 520px;
  background: radial-gradient(ellipse, rgba(63,185,80,.07) 0%, transparent 65%);
  pointer-events: none;
}

.hero-left { position: relative; z-index: 1; }

.hero-prompt {
  font-family: 'Courier New', monospace;
  font-size: .9rem;
  color: var(--green);
  opacity: .65;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.hero-cursor {
  display: inline-block;
  width: 9px;
  height: 1em;
  background: var(--green);
  vertical-align: middle;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.start-hero h1 {
  font-family: 'Courier New', monospace;
  font-size: 4rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .04em;
  line-height: 1;
  text-shadow: 0 0 80px rgba(63,185,80,.2);
}

.hero-sub {
  margin-top: 14px;
  color: var(--muted);
  font-size: .95rem;
  max-width: 400px;
  line-height: 1.5;
}

/* ── Stats ──── */
.hero-stats {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 2px solid var(--green);
  border-radius: 6px;
  padding: 20px 28px;
  min-width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-stats-title {
  font-family: 'Courier New', monospace;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

.hero-stats-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hero-stats-num {
  font-family: 'Courier New', monospace;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}

.hero-stats-denom {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  color: var(--muted);
}

.hero-stats-sub {
  font-size: .82rem;
  color: var(--muted);
  margin-top: -4px;
}

.hero-progress-track {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.hero-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(63,185,80,.4);
  transition: width .6s ease;
  min-width: 2px;
}

/* ── Map ──── */
.start-map-wrap {
  flex: 1;
  padding: 40px 40px 64px;
  overflow-x: auto;
}

.level-grid {
  display: flex;
  align-items: flex-start;
  min-width: max-content;
}

/* ── Connecteur entre groupes ──── */
.group-connector {
  width: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 16px;
  color: var(--border);
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  user-select: none;
}

/* ── Groupe de niveaux ──── */
.level-group { flex: 1; min-width: 185px; }

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(63,185,80,.06);
  border: 1px solid rgba(63,185,80,.18);
  border-bottom: 2px solid var(--green);
  border-radius: 6px 6px 0 0;
}

.group-header-name {
  font-family: 'Courier New', monospace;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--green);
  font-weight: 700;
}

.group-header-badge {
  font-family: 'Courier New', monospace;
  font-size: .72rem;
  color: var(--muted);
}

/* ── Carte de niveau ──── */
.lc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.lc:last-child { border-radius: 0 0 6px 6px; }

.lc:hover:not(.lc-locked) { background: var(--bg3); border-color: rgba(63,185,80,.35); }
.lc:hover:not(.lc-locked) .lc-num { color: var(--green); }

.lc-locked { opacity: .35; cursor: not-allowed; }
.lc-done   { background: rgba(63,185,80,.04); }

/* ── Point de statut ──── */
.lc-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: transparent;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.lc:not(.lc-locked):not(.lc-done) .lc-status { border-color: var(--blue); }
.lc-done .lc-status {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 5px rgba(63,185,80,.5);
}

/* ── Contenu de la carte ──── */
.lc-num {
  font-family: 'Courier New', monospace;
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 22px;
  transition: color .15s;
}
.lc-done .lc-num { color: var(--green); }

.lc-body { flex: 1; min-width: 0; }

.lc-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lc-done .lc-title { color: var(--muted); }

.lc-tags { margin-top: 3px; display: flex; gap: 3px; flex-wrap: wrap; }

.lc-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.lc-diff  { color: var(--yellow); font-size: .72rem; letter-spacing: 1px; }
.lc-check { color: var(--green);  font-size: .85rem; font-weight: 700; }
.lc-lock  { color: var(--muted);  font-size: .82rem; }

/* ════════════════════════════════════════════
   ÉCRAN DE JEU
════════════════════════════════════════════ */
#screen-game {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Volet terminal (gauche) ──── */
.terminal-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #0a0e14;
  min-width: 0;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-exit {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-exit:hover { color: var(--text); border-color: var(--blue); }

#mission-title {
  flex: 1;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sortie terminal ──── */
#terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.05rem;
  line-height: 1.6;
}

.tl-out { white-space: pre-wrap; word-break: break-all; min-height: 1.6em; }
.tl-prompt-echo { /* transparent passthrough */ }

/* ── Ligne de saisie ──── */
.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border-top: 2px solid var(--green);
  background: #111820;
  flex-shrink: 0;
}

#prompt {
  font-family: 'Courier New', monospace;
  font-size: 1.05rem;
  white-space: nowrap;
  margin-right: 6px;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 1.05rem;
  caret-color: var(--green);
}

/* ── Couleurs terminal ──── */
.t-prompt { color: var(--blue); }
.t-input  { color: var(--text); }
.t-ok     { color: var(--green); }
.t-root   { color: var(--red); font-weight: 700; }
.t-err    { color: var(--red); }
.t-warn   { color: var(--orange); }
.t-danger { color: var(--red); font-weight: 700; }
.t-locked { color: var(--muted); }
.t-perm   { color: var(--muted); }
.t-dir    { color: var(--blue); font-weight: 600; }
.t-exec   { color: var(--green); }
.t-file   { color: var(--text); }
.t-cmd    { color: var(--cyan); }
.t-muted  { color: var(--muted); }

/* ── Volet info (droite) ──── */
.info-pane {
  flex: 0 0 36%;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  min-width: 0;
}

.section-title {
  font-size: .85rem;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--green);
  padding: 11px 18px 7px;
  border-bottom: 1px solid var(--border);
}

/* ── Objectifs ──── */
.objectives-section {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.objectives-list {
  list-style: none;
  padding: 10px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.objectives-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 1rem;
  line-height: 1.45;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.obj-done { color: var(--green); text-decoration: line-through; opacity: .7; }
.obj-todo { color: var(--text); }

.obj-icon {
  flex-shrink: 0;
  font-weight: 700;
  width: 14px;
  text-align: center;
  margin-top: 1px;
}

/* ── Arbre de fichiers ──── */
.tree-section {
  flex: 1;
  overflow-y: auto;
}

#file-tree {
  padding: 12px 18px 24px;
  font-family: 'Courier New', monospace;
  font-size: .95rem;
  line-height: 1.8;
}

.tl {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.tl-root { padding-bottom: 2px; }

.tl-cwd {
  background: rgba(63,185,80,.12);
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 -4px;
}

.tl-pre { color: var(--border); user-select: none; white-space: pre; }
.tl-icon { color: var(--muted); font-size: .8rem; user-select: none; }

.tn-dir  { color: var(--blue); font-weight: 600; }
.tn-exec { color: var(--green); }
.tn-file { color: var(--text); }

.tn-badge {
  font-family: 'Segoe UI', sans-serif;
  font-size: .65rem;
  padding: 1px 5px;
  border-radius: 8px;
  flex-shrink: 0;
}
.tn-root { background: #5a1f1f; color: var(--red); }
.tn-www  { background: #1f3a5a; color: var(--cyan); }

.tl-perms { margin-left: auto; flex-shrink: 0; font-size: .88rem; padding-left: 10px; }

.tp-ok   { color: var(--muted); }
.tp-warn { color: var(--orange); }

.tl-empty { color: var(--muted); font-size: .82rem; font-style: italic; }

.tl-outside-notice {
  font-size: .82rem;
  color: #ffa0a0;
  background: rgba(248,81,73,.15);
  border: 1px solid rgba(248,81,73,.3);
  border-radius: 5px;
  padding: 7px 10px;
  margin-bottom: 10px;
}

/* ════════════════════════════════════════════
   SUCCÈS INLINE
════════════════════════════════════════════ */
.t-link {
  color: #58a6ff;
  text-decoration: underline;
}
.t-link:hover { color: #79b8ff; }

.t-cours {
  color: var(--orange);
  white-space: pre;
}

.t-success-line {
  color: var(--green);
  font-weight: 700;
  font-size: 1rem;
}

.success-bar {
  display: flex;
  gap: 8px;
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(63, 185, 80, .25);
  background: rgba(63, 185, 80, .05);
}

.btn-success-replay {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s, border-color .15s;
}
.btn-success-replay:hover { color: var(--text); border-color: var(--blue); }

.btn-success-next {
  flex: 1;
  background: var(--green);
  color: #0d1117;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}
.btn-success-next:hover { opacity: .85; }

.title-success { color: var(--green) !important; }

/* ════════════════════════════════════════════
   ÉCRAN DE FIN
════════════════════════════════════════════ */
#screen-end {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

#matrix-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
  pointer-events: none;
}

.end-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.85);
  backdrop-filter: blur(4px);
}

.end-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 28px;
  text-align: center;
}

.end-terminal-decor {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 2px;
}

.end-blink {
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.end-title {
  font-size: 3rem;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -.5px;
}

.end-sub {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 480px;
}

.end-stats-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}

.end-stats-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.end-stats-num {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--green);
  font-family: 'Courier New', monospace;
}

.end-stats-denom {
  font-size: 1.6rem;
  color: var(--muted);
}

.end-stats-label {
  font-size: .9rem;
  color: var(--muted);
}

.end-cmds { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.end-cmds-title { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.end-cmds-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 480px; }

.end-actions { margin-top: 8px; }

.btn-end-menu {
  padding: 12px 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
}
.btn-end-menu:hover { border-color: var(--green); color: var(--green); }

/* ════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */
@media (max-width: 700px) {
  .game-layout { flex-direction: column; }
  .terminal-pane { flex: none; height: 55vh; border-right: none; border-bottom: 1px solid var(--border); }
  .info-pane { flex: none; height: 45vh; }
  .start-hero { flex-direction: column; padding: 32px 24px 28px; gap: 24px; }
  .start-topbar { padding: 12px 20px; }
  .start-hero h1 { font-size: 2.4rem; }
  .hero-stats { min-width: unset; width: 100%; }
  .start-map-wrap { padding: 24px 20px 48px; }
}

/* ── Footer ─────────────────────────────── */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 24px;
  font-size: .75rem;
  color: #7d8590;
  border-top: 1px solid #21262d;
  background: var(--bg);
  z-index: 1;
}
