/* =====================================================================
   cards.css — Branch cards, badges, footers, skeletons
   ===================================================================== */

.branch-card {
  position: relative;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), box-shadow var(--t-base), border-color var(--t-base);
  display: flex; flex-direction: column; gap: var(--sp-2);
  outline: none;
}
.branch-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}
.branch-card:focus-visible { box-shadow: var(--shadow-focus); border-color: var(--color-primary); }
.branch-card.is-updated { animation: flash-update 1.4s var(--ease); }
.branch-card.is-pinned { border-left: 3px solid var(--color-warning); }

/* status edge (pipeline based) */
.branch-card::before {
  content: ""; position: absolute; top: 10px; right: 0; width: 3px; height: 22px;
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
  background: var(--status-color, transparent);
}

/* ---- Card head: branch name + actions ---- */
.card-head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.branch-icon { color: var(--text-faint); flex-shrink: 0; margin-top: 1px; }
.branch-name {
  font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-strong);
  word-break: break-word; line-height: 1.35; flex: 1; min-width: 0;
}
.card-pin {
  flex-shrink: 0; color: var(--text-faint); width: 24px; height: 24px;
  border-radius: 6px; display: grid; place-items: center;
  transition: color var(--t-fast), background var(--t-fast);
}
.card-pin:hover { color: var(--color-warning); background: var(--color-warning-soft); }
.card-pin.is-pinned { color: var(--color-warning); }

/* ---- Badges row ---- */
.badge-row { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  padding: 2px 8px; border-radius: var(--radius-pill);
  white-space: nowrap; line-height: 1.5;
}
.badge svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge-default  { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-protected{ background: var(--color-warning-soft); color: #9a7700; }
.badge-env      { background: var(--color-info-soft); color: #0c6f80; }
.badge-mr       { background: var(--color-success-soft); color: #1c7a32; }
.badge-tag      { background: var(--color-muted-soft); color: var(--text-muted); }
.badge-commits  { background: var(--color-muted-soft); color: var(--text-muted); }
.badge-site {
  background: var(--color-primary-soft); color: var(--color-primary);
  text-decoration: none; cursor: pointer;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.badge-site:hover { background: var(--color-primary); color: #fff; text-decoration: none; box-shadow: var(--shadow-xs); }
.badge-site:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.badge-success  { background: var(--color-success-soft); color: #1c7a32; }
.badge-failed   { background: var(--color-danger-soft); color: #b02a37; }
.badge-running  { background: var(--color-info-soft); color: #0c6f80; }
.badge-pending  { background: var(--color-warning-soft); color: #9a7700; }
.badge-canceled { background: var(--color-muted-soft); color: var(--text-muted); }
.badge-skipped  { background: var(--color-muted-soft); color: var(--text-muted); }
.badge-created  { background: var(--color-muted-soft); color: var(--text-muted); }

.badge-running .dot-spin {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid currentColor; border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

/* ---- Commit block ---- */
.commit-block {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-2); border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.commit-msg {
  font-size: var(--fs-md); color: var(--text-default); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.commit-meta { display: flex; align-items: center; gap: var(--sp-2); }
.commit-sha {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--color-muted-soft); color: var(--text-muted);
  padding: 1px 6px; border-radius: 5px;
}
.commit-verified { color: var(--color-success); display: inline-flex; }

/* ---- Author row ---- */
.author-row { display: flex; align-items: center; gap: var(--sp-2); }
.avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background: var(--color-primary-soft);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--color-primary);
  text-transform: uppercase; overflow: hidden;
  border: 1px solid var(--color-border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.author-name { font-size: var(--fs-sm); color: var(--text-default); font-weight: var(--fw-medium); }
.author-time { font-size: var(--fs-xs); color: var(--text-faint); margin-left: auto; white-space: nowrap; }

/* ---- Stats strip (ahead/behind, age, health) ---- */
.card-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.mini-stat {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-xs); color: var(--text-muted);
}
.mini-stat svg { width: 12px; height: 12px; }
.mini-stat.ahead { color: var(--color-success); }
.mini-stat.behind { color: var(--color-danger); }

.health-bar {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); color: var(--text-muted);
}
.health-track { width: 44px; height: 5px; border-radius: var(--radius-pill); background: var(--color-border); overflow: hidden; }
.health-fill { height: 100%; border-radius: var(--radius-pill); transition: width var(--t-slow) var(--ease); }
.health-fill.good { background: var(--color-success); }
.health-fill.mid  { background: var(--color-warning); }
.health-fill.bad  { background: var(--color-danger); }

/* Pipeline progress (running) */
.pipe-progress { height: 4px; border-radius: var(--radius-pill); background: var(--color-border); overflow: hidden; margin-top: 2px; }
.pipe-progress .bar { height: 100%; width: 40%; background: var(--color-info); border-radius: inherit; animation: indeterminate 1.3s infinite var(--ease); }

/* ---- Footer actions ---- */
.card-footer {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding-top: var(--sp-2); border-top: 1px dashed var(--color-border);
}
.card-action {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted);
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.card-action svg { width: 13px; height: 13px; }
.card-action:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.card-action:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.card-action.copied { color: var(--color-success); background: var(--color-success-soft); }

/* =====================================================================
   Skeleton loaders
   ===================================================================== */
.skeleton {
  position: relative; overflow: hidden;
  background: #e9edf3; border-radius: 6px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
  animation: shimmer 1.3s infinite;
}
.skeleton-card {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.sk-line { height: 12px; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-40 { width: 40%; }
.sk-line.w-80 { width: 80%; }
.sk-line.w-100 { width: 100%; }
.sk-block { height: 46px; border-radius: var(--radius-sm); }
.sk-row { display: flex; gap: var(--sp-2); align-items: center; }
.sk-avatar { width: 24px; height: 24px; border-radius: 50%; }
.sk-chip { height: 18px; width: 56px; border-radius: var(--radius-pill); }

.stat-card.skeleton-stat { box-shadow: var(--shadow-xs); }
.stat-card.skeleton-stat::after { content: none; }
