/* ==========================================================================
   Expériences : `git log --graph` (une mission = un commit)
   ========================================================================== */

.git-log {
  --graph-main: color-mix(in srgb, var(--color-fg) 32%, transparent);
  --graph-branch: var(--color-swift-orange);
  --git-sha: #c99a06;
  --git-hunk: #2a9db0;
  --git-green: var(--color-build-green);
}

.git-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 20px;
  border: 1px solid var(--color-line);
  border-radius: 20px 20px 0 0;
  color: var(--color-muted);
  font: 500 12px var(--font-mono);
}

.git-header b {
  color: var(--git-green);
}

.git-header em {
  color: var(--color-fg);
  font-style: normal;
}

.git-commits {
  padding: 10px 20px 16px 14px;
  border: 1px solid var(--color-line);
  border-top: 0;
  border-radius: 0 0 20px 20px;
}

.commit {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  column-gap: 6px;
}

/* ---- Graphe : branche principale (lane 0) et branches étrangères (lane 1) ---- */
.commit-graph {
  position: relative;
}

.graph-line {
  position: absolute;
  width: 2px;
  margin-left: -1px;
  background: var(--graph-main);
}

.graph-line.lane-1 {
  background: var(--graph-branch);
}

.graph-line--up {
  top: 0;
  height: 24px;
}

.graph-line--down {
  top: 24px;
  bottom: 0;
}

.graph-line--through {
  top: 0;
  bottom: 0;
}

/* Courbe de fusion entre deux lanes */
.commit-graph svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  height: 24px;
  overflow: visible;
}

.commit-graph path {
  fill: none;
  stroke: var(--graph-branch);
  stroke-width: 2;
}

.graph-node {
  position: absolute;
  z-index: 1;
  top: 24px;
  width: 13px;
  height: 13px;
  margin: -6.5px;
  border: 2px solid var(--color-fg);
  border-radius: 50%;
  background: var(--color-bg);
}

.commit.is-branch .graph-node {
  border-color: var(--graph-branch);
}

.commit.is-head .graph-node {
  border-color: var(--graph-branch);
  background: var(--graph-branch);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--graph-branch) 25%, transparent);
}

/* ---- Ligne de commit (cliquable) ---- */
.commit summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 2px 14px;
  padding: 12px 12px 12px 6px;
  border-radius: 12px;
  list-style: none;
  cursor: pointer;
  transition: background 0.2s;
}

.commit summary::-webkit-details-marker {
  display: none;
}

.commit summary:hover {
  background: color-mix(in srgb, var(--color-fg) 5%, transparent);
}

.commit summary:focus-visible {
  outline: 2px solid var(--color-fg);
}

.commit-sha {
  color: var(--git-sha);
  font: 500 12px var(--font-mono);
}

.commit-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.commit-title b {
  font: 600 17px/1.3 var(--font-sans);
  letter-spacing: -0.02em;
}

.commit-company {
  color: var(--color-muted);
  font-size: 14px;
}

.git-ref {
  align-self: center;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 99px;
  font: 600 10.5px/1.4 var(--font-mono);
}

.git-ref--head {
  border-color: var(--graph-branch);
  background: var(--graph-branch);
  color: #fff;
}

.git-ref--branch {
  color: var(--graph-branch);
}

.git-ref--main {
  color: var(--git-green);
}

.git-ref--root {
  color: var(--color-muted);
}

.commit time {
  color: var(--color-muted);
  font: 500 11.5px var(--font-mono);
  white-space: nowrap;
}

/* Aperçu du message, masqué quand le diff est déplié */
.commit-preview {
  grid-column: 2 / 4;
  overflow: hidden;
  color: var(--color-muted);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.commit details[open] .commit-preview {
  display: none;
}

/* ---- Diff déplié ---- */
.diff {
  margin: 0 0 14px 6px;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: 12px;
}

.diff-hunk {
  padding: 7px 14px;
  background: color-mix(in srgb, var(--git-hunk) 10%, transparent);
  color: var(--git-hunk);
  font: 500 11.5px var(--font-mono);
}

.diff p {
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 4px 14px;
  background: color-mix(in srgb, var(--git-green) 7%, transparent);
  font-size: 14px;
}

.diff p::before {
  content: "+";
  flex: none;
  color: var(--git-green);
  font: 600 13px/1.6 var(--font-mono);
}

.diff-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--color-line);
}

.diff-stack em {
  margin-right: 4px;
  color: var(--color-muted);
  font: 500 10px var(--font-mono);
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.diff-stack span {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--color-line);
  font: 500 11px var(--font-mono);
}

.git-hint {
  margin: 12px 0 0;
  color: var(--color-muted);
  font: 500 11px var(--font-mono);
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .git-commits {
    padding: 8px 10px 12px 6px;
  }

  .commit {
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 2px;
  }

  .commit summary {
    grid-template-columns: auto 1fr;
  }

  .commit time {
    justify-self: end;
  }

  .commit-title,
  .commit-preview {
    grid-column: 1 / 3;
  }

  .commit-company {
    font-size: 13px;
  }
}
