/* N5-5 CSS Gridで自作する簡易ガントチャート デモ用スタイル */

.cg-demo {
  margin: 20px 0 10px;
}

.cg-card {
  min-width: 0;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.cg-card__head {
  padding: 14px 16px;
  border-bottom: 1px solid #d8e0ea;
  background: #ffffff;
}

.cg-card__title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a2332;
}

.cg-card__note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #5a6a7a;
}

.cg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 16px;
  border-bottom: 1px solid #d8e0ea;
  background: #ffffff;
  font-size: 0.8rem;
  color: #334155;
}

.cg-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cg-legend__swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
  background: #2b7fe8;
}

.cg-legend__swatch--weekend {
  background: rgba(148, 163, 184, 0.28);
}

.cg-legend__swatch--today {
  width: 3px;
  height: 14px;
  border-radius: 0;
  background: #e5484d;
}

/* ===== ここからガントチャート本体（コピペ対象） ===== */

.cg-chart-wrap {
  overflow-x: auto;
  padding: 12px;
}

.cg-chart {
  --cg-name-w: 116px;
  --cg-day-w: 34px;
  display: grid;
  /* grid-template-columns / rows はJS側で日数・行数に応じて設定する */
  position: relative;
  min-width: max-content;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #334155;
}

/* 左上の角（工程ヘッダー）。横スクロールしても左に固定 */
.cg-corner {
  position: sticky;
  left: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f4f7fb;
  border-right: 1px solid #d8e0ea;
  border-bottom: 1px solid #d8e0ea;
  font-weight: 700;
  color: #1a2332;
}

/* 月ヘッダー（上段） */
.cg-month {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: #f4f7fb;
  border-right: 1px solid #d8e0ea;
  border-bottom: 1px solid #d8e0ea;
  font-weight: 700;
  color: #1a2332;
  white-space: nowrap;
}

/* 日ヘッダー（下段） */
.cg-day {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid #d8e0ea;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.cg-day--weekend {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

/* 本体の縦罫線＋土日の背景（1日=1列ぶんの帯） */
.cg-col {
  border-right: 1px solid #eef2f7;
}

.cg-col--weekend {
  background: rgba(148, 163, 184, 0.14);
}

/* 各タスク行の横罫線（日付エリアぶん） */
.cg-lane {
  border-bottom: 1px solid #eef2f7;
}

/* タスク名（左固定列） */
.cg-name {
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #ffffff;
  border-right: 1px solid #d8e0ea;
  border-bottom: 1px solid #eef2f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #334155;
}

/* 予定バー：grid-column: 開始列 / span 日数 で置く */
.cg-bar {
  align-self: center;
  z-index: 2;
  height: 24px;
  margin: 0 3px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  background: #2b7fe8;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
  overflow: hidden;
}

.cg-bar__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 今日線：1列ぶんの左端に縦線を引く */
.cg-today {
  z-index: 3;
  pointer-events: none;
  border-left: 2px solid #e5484d;
  justify-self: start;
}

.cg-today__pill {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 0 4px 4px 0;
  background: #e5484d;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

/* コードブロックのコピーボタン（この記事専用） */
.cg-code {
  position: relative;
  margin: 24px 0;
}

.cg-code > .article-pre {
  margin: 0;
}

.cg-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cg-copy-btn:hover {
  opacity: 1;
  background: #f4f7fb;
}

.cg-copy-btn:focus-visible {
  outline: 2px solid #2b7fe8;
  outline-offset: 2px;
  opacity: 1;
}

.cg-copy-btn.is-done {
  color: #ffffff;
  background: #16a34a;
  border-color: #16a34a;
  opacity: 1;
}

/* Frappe Ganttとの比較表 */
.cg-compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.88rem;
}

.cg-compare-table th,
.cg-compare-table td {
  border: 1px solid #d8e0ea;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.cg-compare-table th {
  background: #f4f7fb;
  color: #1a2332;
  font-weight: 700;
}

.cg-compare-table td {
  color: #334155;
}

.cg-compare-table td:first-child {
  font-weight: 700;
  color: #1a2332;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .cg-chart {
    --cg-name-w: 96px;
    --cg-day-w: 30px;
  }

  .cg-compare-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
