/* timeline.css — 타임라인 영역: 컨트롤 바 (위) + 트랙 컨테이너 (아래)
   컨트롤 바 = 트랜스포트 + 도구 모음 한 줄 */

/* ─── 컨트롤 바 (트랜스포트 + 도구 모음 가로 정렬) ──────────────── */
.control-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
  min-width: 0;
}

/* ─── 도구 모음 (핀 찍기 / Phase / Undo / 삭제 / 줌) ───────────── */
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}
.toolbar-spacer { flex: 1; }

/* Tap/Hold 토글 버튼: 활성 시 primary 배경, 비활성 시 흐릿하게 */
#btnHoldMode { color: var(--dim); font-size: 20px; line-height: 1; }
#btnHoldMode:hover { color: var(--text); }
#btnHoldMode.active {
  background: var(--accent-dim);
  border-color: #3f8a72;
  color: #eaf6f1;
}

/* ─── 타임라인 본체 ─────────────────────────────────────────── */
.timeline {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.timeline::-webkit-scrollbar { width: 8px; }
.timeline::-webkit-scrollbar-track { background: transparent; }
.timeline::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.timeline::-webkit-scrollbar-thumb:hover { background: #404040; }

.tl-row {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--line-soft);
}
.tl-row:first-child { border-top: 0; }
.tl-row.ruler-row {
  height: 24px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
}
.tl-row.audio-track { height: 110px; }
.tl-row.pattern-track { height: 72px; }

.tl-label {
  width: 76px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
.tl-row.ruler-row .tl-label { font-size: 10px; color: var(--dim); font-weight: 500; }
.tl-row.track-row .tl-label .tl-tag {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #10161c;
}
.audio-track .tl-tag {
  background: transparent;
  color: var(--accent);
}

.tl-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 0;
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  transition: opacity 120ms, color 120ms, background 120ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tl-row.track-row:hover .tl-remove { opacity: 1; }
.tl-remove:hover { color: var(--danger); background: rgba(255,106,106,0.15); }

.tl-row.tl-add-row {
  flex: 0 0 auto;
  min-height: 36px;
}
.tl-add-row .tl-label { background: var(--bg-soft); }
.tl-add {
  width: 100%;
  height: 100%;
  min-height: 36px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 0;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tl-add:hover {
  background: rgba(108,224,182,0.05);
  border-color: var(--accent);
  color: var(--accent);
}

.tl-content {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  /* 가로 스크롤바 숨김 — 모든 행이 동기화되어 같이 움직이므로 시각적으로는 한 줄만 필요. */
  scrollbar-width: none;
}
.tl-content::-webkit-scrollbar { display: none; }
/* 마지막 패턴 추가 행에만 스크롤바를 노출해 가로 스크롤 위치를 시각화 */
.tl-add-row .tl-content {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.tl-add-row .tl-content::-webkit-scrollbar { display: block; height: 8px; }
.tl-add-row .tl-content::-webkit-scrollbar-track { background: transparent; }
.tl-add-row .tl-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* 줌 래퍼: 트랙 안쪽 콘텐츠가 가로로 늘어나는 본체. --zoom 배수만큼 폭. */
.tl-zoom {
  position: relative;
  width: calc(100% * var(--zoom, 1));
  height: 100%;
  min-width: 100%;
}

.audio-track .tl-content { background: transparent; }
.pattern-track .tl-content {
  background: rgba(255,255,255,0.015);
}
.pattern-track .tl-zoom { cursor: crosshair; }
.pattern-track .tl-content:hover { background: rgba(255,255,255,0.03); }

.ruler {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
  pointer-events: none;
}
.ruler .tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.12);
}
.ruler .tick.major { background: rgba(255,255,255,0.32); }
.ruler .tick .label {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
