/* ABOUTME: Dark-theme styling for the git-branching course: layout, the SVG
   commit graph, terminal console, and the interactive-rebase modal. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --line: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --commit: #3b82f6;
  --merge: #a855f7;
  --head: #f59e0b;
  --branch: #238636;
  --remote: #db6d28;
  --tag: #8957e5;
  --ok: #2ea043;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column;
}
code, .mono, #cmd, #log { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--accent); }
#level-title { font-weight: 600; }
#progress { color: var(--muted); margin-left: auto; }
#topbar button, #toolbar button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
#topbar button:hover, #toolbar button:hover { border-color: var(--accent); }

main { flex: 1; display: grid; grid-template-columns: 1fr 420px; grid-template-rows: 1fr; min-height: 0; }
#sidebar {
  position: fixed; top: 49px; left: 0; bottom: 0; width: 320px; z-index: 20;
  background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 12px 16px;
}
#sidebar.hidden { display: none; }
#sidebar h2 { font-size: 13px; text-transform: uppercase; color: var(--muted); }
.seq-title { margin: 14px 0 6px; color: var(--accent); font-weight: 600; }
.seq-label { display: flex; align-items: baseline; gap: 8px; }
.seq-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}
.seq-bar {
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--panel-2);
  overflow: hidden;
}
.seq-bar-fill { height: 100%; background: var(--ok); border-radius: 2px; }
.seq-title.complete .seq-count { color: var(--ok); }
.lvl-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; }
.lvl-item:hover { background: var(--panel-2); }
.lvl-item.done::before { content: "\2713"; color: var(--ok); }
.lvl-item.current { background: var(--panel-2); outline: 1px solid var(--accent); }

#stage {
  grid-column: 1;
  overflow: auto;
  padding: 16px;
  /* Fill the column so the graph can take the space that is left over,
     rather than leaving a void under the content. */
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 16px; color: var(--muted); white-space: pre-line;
  flex: 0 0 auto;
}
/* The graph is the centrepiece: it takes whatever height is left and centres
   itself in it, at whatever size fits. */
.graph {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.repo-pane {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.repo-pane svg {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.pane-title { color: var(--muted); font-size: 12px; text-transform: uppercase; margin: 2px 6px 6px; }
.origin-pane { border-color: var(--remote); }
#goal-wrap { opacity: .95; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#goal-wrap.hidden { display: none; }
.graph.goal .repo-pane { border-style: dashed; }

/* SVG graph elements */
svg { display: block; }
.edge { stroke: var(--line); stroke-width: 2.5; }
.edge-merge { stroke: var(--merge); stroke-dasharray: 4 3; }
.commit circle { fill: var(--commit); stroke: #0d1117; stroke-width: 2; }
.commit-merge circle { fill: var(--merge); }
.commit-head circle { stroke: var(--head); stroke-width: 3.5; }
.commit-label { fill: #fff; font: 13px ui-monospace, monospace; text-anchor: middle; }
.lbl rect { fill: var(--branch); }
.lbl text { fill: #fff; font: 12px ui-monospace, monospace; text-anchor: middle; }
.lbl-current rect { fill: #2ea043; stroke: var(--head); stroke-width: 2; }
.lbl-remote rect { fill: var(--remote); }
.lbl-tag rect { fill: var(--tag); }
.lbl-head rect { fill: #21262d; stroke: var(--head); stroke-width: 2; }

#console {
  grid-column: 2; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
#log { flex: 1; overflow-y: auto; padding: 12px 14px; font-size: 13px; white-space: pre-wrap; }
.log-cmd { color: var(--accent); }
.log-out { color: var(--muted); }
.log-err { color: #f85149; }
.log-win { color: var(--ok); font-weight: 700; }
.log-info { color: #d2a8ff; }
#prompt-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); }
.prompt { color: var(--ok); font-weight: 700; }
#cmd { flex: 1; background: transparent; border: none; color: var(--text); font-size: 14px; outline: none; }
#toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--line); }
#toolbar button { font-size: 12px; padding: 4px 10px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
#modal.hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: 360px; max-height: 80vh; overflow: auto; }
.modal-card h3 { margin: 0 0 4px; }
.modal-sub { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
#rebase-list { list-style: none; padding: 0; margin: 0; }
#rebase-list li { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; background: var(--panel-2); }
#rebase-list li.dropped { opacity: .4; }
#rebase-list .rid { font-family: ui-monospace, monospace; flex: 1; }
#rebase-list button { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; width: 26px; height: 26px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal-actions .primary { background: var(--branch); border-color: var(--branch); color: #fff; }
.modal-actions button { padding: 6px 14px; border-radius: 6px; cursor: pointer; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

.hidden { display: none; }
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
  #console { grid-column: 1; border-left: none; border-top: 1px solid var(--line); }
}

/* ---- the three trees ---- */
#trees.hidden { display: none; }
#trees { flex: 0 0 auto; }
.trees-wrap { overflow-x: auto; }
table.trees {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
table.trees thead th {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.trees tbody th,
table.trees tbody td { padding: 7px 10px; border-bottom: 1px solid var(--panel-2); }
table.trees tbody tr:last-child th,
table.trees tbody tr:last-child td { border-bottom: none; }
.tpath {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.tcell .content {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  /* Conflict markers are multi-line and only make sense laid out as written. */
  white-space: pre-wrap;
  display: block;
}
.tcell.empty .dash { color: var(--muted); font-style: italic; opacity: 0.7; }
/* The staging column is the one people lose track of, so give it an edge. */
.tcell.index { background: rgba(88, 166, 255, 0.06); }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}
.badge-staged { background: rgba(46, 160, 67, 0.18); color: var(--ok); }
.badge-modified { background: rgba(245, 158, 11, 0.18); color: var(--head); }
.badge-untracked { background: rgba(139, 148, 158, 0.18); color: var(--muted); }
.badge-deleted { background: rgba(219, 109, 40, 0.20); color: var(--remote); }
.badge-ignored { background: transparent; color: var(--muted); opacity: 0.75; }
.trow.clean .tpath { color: var(--muted); font-weight: 500; }
.badge-conflict { background: rgba(248, 81, 73, 0.20); color: #f85149; }
.trow.conflict .tpath { color: #f85149; }
.trow.conflict .tcell.work { background: rgba(248, 81, 73, 0.07); }
.merge-banner {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.10);
  color: var(--text);
  font-size: 13px;
}
.merge-banner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
}

/* A cell that disagrees with the column to its right: that is where the
   change lives, so mark it rather than making people compare strings. */
.tcell.differs { position: relative; }
.tcell.work.differs { box-shadow: inset 3px 0 0 var(--head); }
.tcell.index.differs { box-shadow: inset 3px 0 0 var(--ok); }
.tcell.empty .dash { font-size: 12px; }
.cm { display: block; }
.cm-ours { color: var(--head); }
.cm-theirs { color: var(--merge); }
.cm-split { color: var(--muted); }

/* Work set aside. A stack you cannot see is how people lose things in it. */
.stash-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 8px; padding: 6px 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--tag); border-radius: 8px;
  font-size: 12px;
}
.stash-label {
  color: var(--tag); text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; font-size: 11px;
}
.stash-entry { color: var(--muted); }
.stash-entry code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); margin-right: 4px;
}
#rebase-list select.verb {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 4px; font-size: 12px;
}
#rebase-list .rmsg {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; font-size: 12px;
}

/* One repository, several places to stand. */
.wt-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 8px; padding: 6px 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px; font-size: 12px;
}
.wt-label {
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; font-size: 11px;
}
.wt-entry { color: var(--muted); }
.wt-entry code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); margin-right: 4px;
}
.wt-current { color: var(--text); font-weight: 600; }
.wt-current code { color: var(--accent); }
.gitlink .gl-tag {
  display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 999px;
  background: rgba(137, 87, 229, 0.20); color: var(--tag);
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
