/* 提交图（commit graph）组件
   用法：
   <div class="cgraph" style="--rows: N">
     <svg class="lanes" viewBox="0 0 80 (N*36)"> …线与点… </svg>
     <div class="row"><code>hash</code><span class="msg">…</span><span class="tag">…</span></div> × N
   </div>
   每行固定 36px，SVG 里第 i 行的圆心 y = 18 + i*36。
   泳道：lane0 x=20（主线，蓝），lane1 x=52（侧线，琥珀）。
   合并提交用空心大圆 .merge，普通提交用实心小圆。 */

.cgraph {
  --row-h: 36px;
  display: grid;
  grid-template-columns: 80px 1fr;
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  overflow: hidden;
}

.cgraph .lanes {
  grid-column: 1;
  grid-row: 1 / span var(--rows);
  width: 80px;
  height: calc(var(--row-h) * var(--rows));
  display: block;
}

:is(.cgraph, .shapes) .lane0 { stroke: var(--blue); }
:is(.cgraph, .shapes) .lane1 { stroke: var(--amber); }
:is(.cgraph, .shapes) path,
:is(.cgraph, .shapes) line {
  fill: none;
  stroke-width: 2.5;
}

:is(.cgraph, .shapes) .dot { r: 4.5; stroke: none; }
:is(.cgraph, .shapes) .dot.lane0 { fill: var(--blue); }
:is(.cgraph, .shapes) .dot.lane1 { fill: var(--amber); }
:is(.cgraph, .shapes) .lane2 { stroke: var(--green); }
:is(.cgraph, .shapes) .dot.lane2 { fill: var(--green); }
/* 当前检出位置（IDEA 里的紫色空心点） */
:is(.cgraph, .shapes) .dot.here { r: 6.5; fill: white; stroke: #7a4fb5; stroke-width: 2.5; }
:is(.cgraph, .shapes) .dot.merge { r: 6.5; fill: white; stroke-width: 2.5; }

.cgraph .row {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--row-h);
  padding: 0 14px 0 4px;
  border-bottom: 1px solid #efece5;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
}

.cgraph .row:last-child { border-bottom: 0; }

.cgraph .row code {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--muted);
}

.cgraph .row .msg {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cgraph .row .who {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

/* 分支标签，模仿 IDEA 里的黄/绿标签 */
.cgraph .ref {
  flex: 0 0 auto;
  padding: 0.1em 0.55em;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 650;
  background: #fff1d6;
  color: #7a4a06;
  border: 1px solid #ecd39d;
}

/* 讲解编号，和正文里的 ① ② ③ 对应 */
.cgraph .note {
  flex: 0 0 auto;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 800;
  color: white;
  background: var(--red);
}

.cgraph .row.hot { background: var(--amber-soft); }
.cgraph .row.cool { background: var(--blue-soft); }

/* 三种形状的小卡片 */
.shapes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.shapes .shape {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.shapes .shape svg {
  display: block;
  width: 80px;
  height: 108px;
  margin: 0 auto 8px;
}

.shapes .shape svg.wide { width: 150px; height: 150px; }
.shapes text { font-size: 11px; fill: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; }
.shapes text.hi { fill: var(--red); font-weight: 700; }

.shapes .shape h3 { text-align: center; font-size: 1rem; }
.shapes .shape p { font-size: 0.88rem; color: #3e4955; margin: 0; }

@media (max-width: 700px) {
  .shapes { grid-template-columns: 1fr; }
  .cgraph .row .who { display: none; }
}

@media print {
  .cgraph, .shapes .shape { break-inside: avoid; }
}
