/* The history panel, and the base of the other panels (page, header, rows). Colours and fonts
   come from brand.css. */

/* Room for the scrollbar always, so the layout doesn't shift when one appears. */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-text);
  font-size: var(--vscode-font-size, 13px);
}

.header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header .rev {
  font-weight: 700;
  color: var(--accent-text);
}

.header .count {
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 160px) 130px 70px;
  gap: 12px;
  align-items: center;
  height: var(--row-height);
  padding-left: var(--graph-width);
  white-space: nowrap;
  cursor: default;
}

.row:hover {
  background: var(--hover);
}

.row.selected {
  background: var(--selected);
  box-shadow: inset 2px 0 0 var(--accent);
}

.row > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.error {
  padding: 12px;
  color: var(--vscode-errorForeground, var(--rose));
}

/* The map: an SVG grid of lanes, one grid cell per character of `sundgren graph --format text`,
   newest on top, beside a table of the commits with each lane's label on its row. */
.empty {
  padding: 12px;
  color: var(--muted);
}

.header .status {
  color: var(--muted);
  font-style: italic;
}

.map {
  position: relative;
  margin: 12px;
}

.map.updating {
  opacity: 0.55;
}

.map-svg {
  display: block;
  overflow: visible;
}

/* Lane colour: its family (the remote twin a turned hue), or ink for protected lanes. */
.lane,
.commit,
.connector,
.lane-label {
  --color: var(--text);
}

.family-0 {
  --color: var(--lane-0);
}

.family-0.remote {
  --color: var(--lane-0-remote);
}

.family-1 {
  --color: var(--lane-1);
}

.family-1.remote {
  --color: var(--lane-1-remote);
}

.family-2 {
  --color: var(--lane-2);
}

.family-2.remote {
  --color: var(--lane-2-remote);
}

.family-3 {
  --color: var(--lane-3);
}

.family-3.remote {
  --color: var(--lane-3-remote);
}

.family-4 {
  --color: var(--lane-4);
}

.family-4.remote {
  --color: var(--lane-4-remote);
}

.family-5 {
  --color: var(--lane-5);
}

.family-5.remote {
  --color: var(--lane-5-remote);
}

.family-6 {
  --color: var(--lane-6);
}

.family-6.remote {
  --color: var(--lane-6-remote);
}

.family-7 {
  --color: var(--lane-7);
}

.family-7.remote {
  --color: var(--lane-7-remote);
}

.family-8 {
  --color: var(--lane-8);
}

.family-8.remote {
  --color: var(--lane-8-remote);
}

.family-9 {
  --color: var(--lane-9);
}

.family-9.remote {
  --color: var(--lane-9-remote);
}

.family-10 {
  --color: var(--lane-10);
}

.family-10.remote {
  --color: var(--lane-10-remote);
}

.family-11 {
  --color: var(--lane-11);
}

.family-11.remote {
  --color: var(--lane-11-remote);
}

.protected {
  --color: var(--text);
}

.trace {
  fill: none;
  stroke: var(--color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Remote: thinner and dashed. Colours used again (past the 12th family): dotted. */
.remote .trace {
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  stroke-linecap: butt;
}

.dotted .trace {
  stroke-dasharray: 0.1 4;
}

.dotted.remote .trace {
  stroke-dasharray: 5 3 0.1 3;
  stroke-linecap: round;
}

/* Merged: faded. Opacity on the whole group, so overlapping pieces don't darken. */
.lane.merged,
.commit.merged,
.connector.merged,
.lane-label.merged .lane-name {
  opacity: 0.45;
}

/* A wide invisible stroke, so a lane is easy to point at. */
.hit {
  fill: none;
  stroke: transparent;
  stroke-width: 8;
  stroke-dasharray: none;
  pointer-events: stroke;
  cursor: pointer;
}

/* Protected: the text colour, and heavier, so a pale lane can't be taken for it. */
.protected .trace {
  stroke-width: 3;
}

.protected.remote .trace {
  stroke-width: 2;
}

.lane.hot .trace,
.lane.selected .trace {
  stroke-width: 3;
}

.protected.hot .trace,
.protected.selected .trace {
  stroke-width: 4;
}

.node {
  fill: var(--bg);
  stroke: var(--color);
  stroke-width: 2;
}

.node.filled {
  fill: var(--color);
}

/* A folded run: a second ring around the node. */
.node.stack {
  fill: var(--bg);
  stroke-width: 1.5;
}

.commit {
  cursor: pointer;
  outline: none;
}

.commit .focus {
  fill: none;
  stroke: none;
  stroke-width: 2;
}

.commit:hover .node,
.commit.hot .node {
  stroke-width: 3;
}

.commit:focus-visible .focus,
.commit.selected .focus {
  stroke: var(--accent);
}

/* An off-board connector: a pad with a hole, like on a circuit board. */
.connector .pad {
  fill: var(--bg);
  stroke: var(--color);
  stroke-width: 2;
}

.connector .pad-hole {
  fill: var(--color);
}

/* The table: one row per commit (or label) row of the grid: the time axis, the graph's column,
   the labels, the hash, the subject, the author. The columns have fixed widths, so nothing moves
   sideways while scrolling or loading more. */
.hrow {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns:
    var(--axis-width) var(--graph-width) var(--refs-width) 7ch
    minmax(120px, 1fr) 110px;
  gap: 0 12px;
  align-items: center;
  white-space: nowrap;
  border-radius: 3px;
  cursor: default;
}

.hrow:hover {
  background: var(--hover);
}

.hrow.selected {
  background: var(--selected);
}

.hrow > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hrow .author {
  color: var(--muted);
}

.hrow .hash {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* The time axis: a line down the left with a tick per commit, the time beside each, and the day
   where one starts (a longer tick, and a faint line across the row). */
.map::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--axis-width) - 12px);
  border-left: 1px solid var(--border);
}

.hrow .axis {
  position: relative;
  display: flex;
  gap: 1ch;
  justify-content: flex-end;
  align-items: center;
  align-self: stretch;
  padding-right: 18px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hrow .axis.tick::after,
.hrow .axis.day::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 4px;
  border-top: 1px solid var(--muted);
}

.hrow .axis.day::after {
  right: 4px;
  width: 8px;
  border-top-color: var(--text);
}

.axis-day {
  color: var(--text);
  font-weight: 600;
}

.hrow.day-start {
  box-shadow: inset 0 1px 0 var(--border);
}

.hrow .refs {
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.hrow .subject {
  display: flex;
  gap: 6px;
  align-items: center;
}

.subject-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The graph is drawn over the rows' graph column, right of the time axis. */
.map-svg {
  position: absolute;
  top: 0;
  left: var(--axis-width);
  z-index: 1;
  pointer-events: none;
}

.map-svg .lane,
.map-svg .commit,
.map-svg .connector {
  pointer-events: auto;
}

/* A lane's label, in the refs column: name, ↑↓, where it is, the rest, in aligned columns. */
.lane-label {
  display: grid;
  grid-template-columns: minmax(6ch, var(--name-width)) 9ch 9ch minmax(0, 1fr);
  gap: 0 8px;
  align-items: center;
  height: 24px;
  padding: 0 2px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.lane-label > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lane-label:hover,
.lane-label.hot {
  background: var(--hover);
}

.lane-label.selected {
  background: var(--selected);
}

.lane-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.lane-name {
  font-weight: 600;
  color: var(--color);
}

.lane-counts,
.lane-where,
.lane-facts {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lane-extra {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Refs that aren't lanes (tags, a remote only behind), before the subject. */
.ref-chip {
  flex-shrink: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* The fold toggle: ×N, click to unfold or fold. */
.fold-toggle {
  flex-shrink: 0;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-text);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.fold-toggle:hover {
  background: var(--hover);
}

.control.older {
  margin: 0 12px 8px;
}

.control.older:disabled {
  opacity: 0.5;
  cursor: default;
}

/* The legend: what each marking means. */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  margin: 4px 12px 0;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9em;
}

.legend-item {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.legend-mark {
  color: var(--text);
  font-family: var(--font-mono);
}

.swatch {
  flex-shrink: 0;
  overflow: visible;
}

/* The toolbar's dropdowns, styled like its buttons. */
.control-select {
  padding: 0;
  border: none;
  color: var(--accent-text);
  background: transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* The lists under the toolbar's Branches, Authors and Dates: tick to show, untick to hide. */
.popover {
  position: fixed;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 340px;
  max-height: 70vh;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 30%);
}

.popover.authors {
  width: 420px;
}

.popover.dates {
  width: 292px;
}

.list-search {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: var(--hover);
  font: inherit;
}

.list-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.list-button {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-text);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.list-button:hover {
  background: var(--hover);
}

/* A group toggle with all its branches ticked. */
.list-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--selected);
}

.list-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.list-items {
  overflow-y: auto;
}

.list-item {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.list-item:hover {
  background: var(--hover);
}

.list-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.list-count {
  margin-left: auto;
  padding-left: 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.swatch-blank {
  flex-shrink: 0;
  width: 28px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.popover.authors .swatch-blank {
  display: none;
}

.list-divider {
  margin: 6px 4px 2px;
  color: var(--muted);
  font-size: 0.9em;
}

/* The date filter's calendar: a month, Monday first. */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.calendar-month {
  font-weight: 600;
}

.calendar-step {
  width: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.calendar-step:hover {
  background: var(--hover);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px 0;
  margin-top: 6px;
  text-align: center;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.85em;
}

.calendar-day {
  position: relative;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.calendar-day:hover {
  border-color: var(--accent);
}

.calendar-day.today {
  font-weight: 700;
}

.calendar-day.in-range {
  border-radius: 0;
  background: var(--selected);
}

.calendar-day.edge,
.calendar-day.pending {
  border-color: var(--accent);
  border-radius: 4px;
  color: var(--accent-text);
  font-weight: 700;
}

/* A day with commits on the page: a dot under the number. */
.calendar-day.busy::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--muted);
}

/* A commit by an author filtered out: small and faint, its row thin. */
.commit.thin {
  opacity: 0.35;
}

.commit.thin .node {
  r: 2.5;
}

.commit.thin .node.stack {
  r: 4;
}

.hrow.filtered > .axis,
.hrow.filtered > .hash,
.hrow.filtered > .subject,
.hrow.filtered > .author {
  opacity: 0.4;
}

/* Under the map: which lanes go on below this page, and by how much. */
.below-note {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  margin: 0 12px 8px;
  color: var(--muted);
  font-size: 0.9em;
}

.below-lane {
  font-family: var(--font-mono);
  font-size: 12px;
}

.below-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Badges in a lane label: room to read them. */
.lane-extra .badge {
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
}

/* Narrow panels: the labels keep their room (they never move or shrink); the subject gives way,
   then the author goes. */
@media (width <= 1300px) {
  .hrow {
    grid-template-columns:
      var(--axis-width) var(--graph-width) var(--refs-width) 7ch
      minmax(120px, 1fr);
  }

  .hrow .author {
    display: none;
  }
}

/* Narrower still (the docs demo): lane labels keep their name and counts (the rest is in their
   hover text), and the subject may get narrower. */
@media (width <= 820px) {
  .hrow {
    grid-template-columns:
      var(--axis-width) var(--graph-width) var(--refs-width-narrow) 7ch
      minmax(80px, 1fr);
  }

  .lane-label {
    grid-template-columns: minmax(6ch, var(--name-width)) 9ch;
  }

  .lane-where,
  .lane-extra {
    display: none;
  }
}
